mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
2005-06-25 Alain Magloire
Fix PR 98788: Dealing with templates * model/org/eclipse/cdt/core/model/ICElement.java + model/org/eclipse/cdt/core/model/IFunctionTemplate.java + model/org/eclipse/cdt/core/model/IFunctionTemplateDeclaration.java + model/org/eclipse/cdt/core/model/IMethodTemplate.java + model/org/eclipse/cdt/core/model/IMethodTemplateDeclaration.java + model/org/eclipse/cdt/core/model/IStructureTemplate.java + model/org/eclipse/cdt/core/model/IStructureTemplateDeclaration.java * model/org/eclipse/cdt/core/model/ITemplate.java * model/org/eclipse/cdt/internal/core/model/CModelBuilder.java * model/org/eclipse/cdt/internal/core/model/Funtion.java * model/org/eclipse/cdt/internal/core/model/FunctionTemplate.java * model/org/eclipse/cdt/internal/core/model/Method.java * model/org/eclipse/cdt/internal/core/model/MethodTemplate.java + model/org/eclipse/cdt/internal/core/model/MethodTemplateDeclaration.java * model/org/eclipse/cdt/internal/core/model/StructureTemplate.java + model/org/eclipse/cdt/internal/core/model/StructureTemplateDeclaration.java * model/org/eclipse/cdt/internal/core/model/Template.java
This commit is contained in:
parent
a0dd64276b
commit
dd2d2f9a52
19 changed files with 647 additions and 281 deletions
|
@ -1,3 +1,24 @@
|
|||
2005-06-25 Alain Magloire
|
||||
Fix PR 98788: Dealing with templates
|
||||
* model/org/eclipse/cdt/core/model/ICElement.java
|
||||
+ model/org/eclipse/cdt/core/model/IFunctionTemplate.java
|
||||
+ model/org/eclipse/cdt/core/model/IFunctionTemplateDeclaration.java
|
||||
+ model/org/eclipse/cdt/core/model/IMethodTemplate.java
|
||||
+ model/org/eclipse/cdt/core/model/IMethodTemplateDeclaration.java
|
||||
+ model/org/eclipse/cdt/core/model/IStructureTemplate.java
|
||||
+ model/org/eclipse/cdt/core/model/IStructureTemplateDeclaration.java
|
||||
* model/org/eclipse/cdt/core/model/ITemplate.java
|
||||
|
||||
* model/org/eclipse/cdt/internal/core/model/CModelBuilder.java
|
||||
* model/org/eclipse/cdt/internal/core/model/Funtion.java
|
||||
* model/org/eclipse/cdt/internal/core/model/FunctionTemplate.java
|
||||
* model/org/eclipse/cdt/internal/core/model/Method.java
|
||||
* model/org/eclipse/cdt/internal/core/model/MethodTemplate.java
|
||||
+ model/org/eclipse/cdt/internal/core/model/MethodTemplateDeclaration.java
|
||||
* model/org/eclipse/cdt/internal/core/model/StructureTemplate.java
|
||||
+ model/org/eclipse/cdt/internal/core/model/StructureTemplateDeclaration.java
|
||||
* model/org/eclipse/cdt/internal/core/model/Template.java
|
||||
|
||||
2005-06-22 Vladimir Hirsl
|
||||
Fix for PR 93573: "[Indexer] endl references are not added to the DOM index"
|
||||
Fixed different encoding of functions references vs. declarations in the index.
|
||||
|
|
|
@ -71,134 +71,159 @@ public interface ICElement extends IAdaptable {
|
|||
*/
|
||||
static final int C_ENUMERATION = 63;
|
||||
|
||||
/**
|
||||
* Declaration of a class without the definition.
|
||||
* class C;
|
||||
*/
|
||||
static final int C_CLASS_DECLARATION = 64;
|
||||
|
||||
/**
|
||||
* Constant representing a class structure.
|
||||
*/
|
||||
static final int C_CLASS = 64;
|
||||
|
||||
/**
|
||||
* Constant representing a struct structure.
|
||||
*/
|
||||
static final int C_STRUCT = 65;
|
||||
|
||||
/**
|
||||
* Constant representing a union structure.
|
||||
*/
|
||||
static final int C_UNION = 66;
|
||||
|
||||
/**
|
||||
* A method definition part of a structure(class, struct, union).
|
||||
*/
|
||||
static final int C_METHOD = 67;
|
||||
|
||||
/**
|
||||
* A method declaration part of a structure(class, struct, union).
|
||||
*/
|
||||
static final int C_METHOD_DECLARATION = 68;
|
||||
|
||||
/**
|
||||
* A Field definition part of a structure(class, struct, union).
|
||||
*/
|
||||
static final int C_FIELD = 69;
|
||||
|
||||
/**
|
||||
* a C/C++ function prototype.
|
||||
*/
|
||||
static final int C_FUNCTION_DECLARATION = 70;
|
||||
|
||||
/**
|
||||
* a C/C++ function.
|
||||
*/
|
||||
static final int C_FUNCTION = 71;
|
||||
|
||||
/**
|
||||
* Preprocessor #include directive.
|
||||
*/
|
||||
static final int C_INCLUDE = 72;
|
||||
|
||||
/**
|
||||
* C++ template class.
|
||||
*/
|
||||
static final int C_TEMPLATE_CLASS = 73;
|
||||
|
||||
/**
|
||||
* Global variable.
|
||||
*/
|
||||
static final int C_VARIABLE = 74;
|
||||
|
||||
/**
|
||||
* variable Declaration.
|
||||
*/
|
||||
static final int C_VARIABLE_DECLARATION = 75;
|
||||
|
||||
/**
|
||||
* Local Variable.
|
||||
*/
|
||||
static final int C_VARIABLE_LOCAL = 76;
|
||||
|
||||
/**
|
||||
* A preprocessor macro.
|
||||
*/
|
||||
static final int C_MACRO = 77;
|
||||
|
||||
/**
|
||||
* a Typedef.
|
||||
*/
|
||||
static final int C_TYPEDEF = 78;
|
||||
|
||||
/**
|
||||
* Enumerator.
|
||||
*/
|
||||
static final int C_ENUMERATOR = 79;
|
||||
|
||||
/**
|
||||
* C++ template function.
|
||||
*/
|
||||
static final int C_TEMPLATE_FUNCTION = 80;
|
||||
|
||||
/**
|
||||
* C++ template method.
|
||||
*/
|
||||
static final int C_TEMPLATE_METHOD = 81;
|
||||
|
||||
/**
|
||||
* C++ template struct.
|
||||
*/
|
||||
static final int C_TEMPLATE_STRUCT = 82;
|
||||
|
||||
/**
|
||||
* C++ template union.
|
||||
*/
|
||||
static final int C_TEMPLATE_UNION = 83;
|
||||
|
||||
/**
|
||||
* C++ template variable.
|
||||
*/
|
||||
static final int C_TEMPLATE_VARIABLE = 84;
|
||||
static final int C_CLASS = 65;
|
||||
|
||||
/**
|
||||
* Declaration of a structure without the definition.
|
||||
* struct C;
|
||||
*/
|
||||
static final int C_STRUCT_DECLARATION = 85;
|
||||
static final int C_STRUCT_DECLARATION = 66;
|
||||
|
||||
/**
|
||||
* Declaration of a class without the definition.
|
||||
* class C;
|
||||
* Constant representing a struct structure.
|
||||
*/
|
||||
static final int C_CLASS_DECLARATION = 86;
|
||||
static final int C_STRUCT = 67;
|
||||
|
||||
/**
|
||||
* Declaration of a union without the definition.
|
||||
* struct C;
|
||||
*/
|
||||
static final int C_UNION_DECLARATION = 87;
|
||||
static final int C_UNION_DECLARATION = 68;
|
||||
|
||||
/**
|
||||
* Constant representing a union structure.
|
||||
*/
|
||||
static final int C_UNION = 69;
|
||||
|
||||
/**
|
||||
* A method definition part of a structure(class, struct, union).
|
||||
*/
|
||||
static final int C_METHOD = 70;
|
||||
|
||||
/**
|
||||
* A method declaration part of a structure(class, struct, union).
|
||||
*/
|
||||
static final int C_METHOD_DECLARATION = 71;
|
||||
|
||||
/**
|
||||
* A Field definition part of a structure(class, struct, union).
|
||||
*/
|
||||
static final int C_FIELD = 72;
|
||||
|
||||
/**
|
||||
* a C/C++ function prototype.
|
||||
*/
|
||||
static final int C_FUNCTION_DECLARATION = 73;
|
||||
|
||||
/**
|
||||
* a C/C++ function definition.
|
||||
*/
|
||||
static final int C_FUNCTION = 74;
|
||||
|
||||
/**
|
||||
* Preprocessor #include directive.
|
||||
*/
|
||||
static final int C_INCLUDE = 75;
|
||||
|
||||
/**
|
||||
* Global variable.
|
||||
*/
|
||||
static final int C_VARIABLE = 76;
|
||||
|
||||
/**
|
||||
* variable Declaration.
|
||||
*/
|
||||
static final int C_VARIABLE_DECLARATION = 77;
|
||||
|
||||
/**
|
||||
* Local Variable.
|
||||
*/
|
||||
static final int C_VARIABLE_LOCAL = 78;
|
||||
|
||||
/**
|
||||
* A preprocessor macro.
|
||||
*/
|
||||
static final int C_MACRO = 79;
|
||||
|
||||
/**
|
||||
* a Typedef.
|
||||
*/
|
||||
static final int C_TYPEDEF = 80;
|
||||
|
||||
/**
|
||||
* Enumerator.
|
||||
*/
|
||||
static final int C_ENUMERATOR = 81;
|
||||
|
||||
/**
|
||||
* C++ template class declaration without a definiton.
|
||||
*/
|
||||
static final int C_TEMPLATE_CLASS_DECLARATION = 82;
|
||||
|
||||
/**
|
||||
* C++ template class with definition.
|
||||
*/
|
||||
static final int C_TEMPLATE_CLASS = 83;
|
||||
|
||||
/**
|
||||
* C++ template struct.
|
||||
*/
|
||||
static final int C_TEMPLATE_STRUCT_DECLARATION = 84;
|
||||
|
||||
/**
|
||||
* C++ template struct.
|
||||
*/
|
||||
static final int C_TEMPLATE_STRUCT = 85;
|
||||
|
||||
/**
|
||||
* C++ template union.
|
||||
*/
|
||||
static final int C_TEMPLATE_UNION_DECLARATION = 86;
|
||||
|
||||
/**
|
||||
* C++ template union.
|
||||
*/
|
||||
static final int C_TEMPLATE_UNION = 87;
|
||||
|
||||
/**
|
||||
* C++ template function declaration.
|
||||
*/
|
||||
static final int C_TEMPLATE_FUNCTION_DECLARATION = 88;
|
||||
|
||||
/**
|
||||
* C++ template function.
|
||||
*/
|
||||
static final int C_TEMPLATE_FUNCTION = 89;
|
||||
|
||||
/**
|
||||
* C++ template method.
|
||||
*/
|
||||
static final int C_TEMPLATE_METHOD_DECLARATION = 90;
|
||||
|
||||
/**
|
||||
* C++ template method.
|
||||
*/
|
||||
static final int C_TEMPLATE_METHOD = 91;
|
||||
|
||||
/**
|
||||
* C++ template variable.
|
||||
*/
|
||||
static final int C_TEMPLATE_VARIABLE = 92;
|
||||
|
||||
/**
|
||||
* An unknown ICElement. Mainly used to determine what elements are not yet implemented.
|
||||
* i.e. the new DOM Parser supports open declaration on labels, while the old parser did not
|
||||
*/
|
||||
static final int C_UNKNOWN_DECLARATION = 88;
|
||||
static final int C_UNKNOWN_DECLARATION = 93;
|
||||
|
||||
/**
|
||||
* Modifier indicating a class constructor
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 QnX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Qnx Software Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.core.model;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Function template definition.
|
||||
*
|
||||
*/
|
||||
public interface IFunctionTemplate extends IFunctionTemplateDeclaration, IFunction {
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 QnX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Qnx Software Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.core.model;
|
||||
|
||||
/**
|
||||
*
|
||||
* Function template declaration.
|
||||
*
|
||||
*/
|
||||
public interface IFunctionTemplateDeclaration extends ITemplate, IFunctionDeclaration {
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 QnX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Qnx Software Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.core.model;
|
||||
|
||||
/**
|
||||
* Member template definition.
|
||||
* IMethodTemplate
|
||||
*
|
||||
*/
|
||||
public interface IMethodTemplate extends IMethodTemplateDeclaration, IMethod {
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 QnX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Qnx Software Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.core.model;
|
||||
|
||||
/**
|
||||
* Member template declaration.
|
||||
* IMethodTemplateDeclaration
|
||||
*
|
||||
*/
|
||||
public interface IMethodTemplateDeclaration extends ITemplate, IMethodDeclaration {
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 QnX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Qnx Software Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.core.model;
|
||||
|
||||
/**
|
||||
* Class template definition.
|
||||
* IStructureTemplate
|
||||
*
|
||||
*/
|
||||
public interface IStructureTemplate extends IStructureTemplateDeclaration, IStructure {
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 QnX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Qnx Software Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.core.model;
|
||||
|
||||
/**
|
||||
* Class template declaration.
|
||||
*
|
||||
* IStructureTemplateDeclaration
|
||||
*
|
||||
*/
|
||||
public interface IStructureTemplateDeclaration extends ITemplate, IStructureDeclaration {
|
||||
|
||||
}
|
|
@ -9,17 +9,13 @@ package org.eclipse.cdt.core.model;
|
|||
* Contributors:
|
||||
* Rational Software - initial implementation
|
||||
******************************************************************************/
|
||||
public interface ITemplate extends IDeclaration {
|
||||
public interface ITemplate {
|
||||
/**
|
||||
* Returns the template parameter types.
|
||||
* @return String
|
||||
*/
|
||||
String[] getTemplateParameterTypes();
|
||||
/**
|
||||
* Sets the template parameter types.
|
||||
* @param paramTypes
|
||||
*/
|
||||
void setTemplateParameterTypes(String[] templateParameterTypes);
|
||||
|
||||
/**
|
||||
* Returns the template signature
|
||||
* The signature depends on the type of template.
|
||||
|
@ -29,9 +25,9 @@ public interface ITemplate extends IDeclaration {
|
|||
* name, its template parameters, followed by its normal parameters.
|
||||
* @return String
|
||||
* @throws CModelException
|
||||
*/
|
||||
|
||||
*/
|
||||
String getTemplateSignature() throws CModelException;
|
||||
|
||||
/**
|
||||
* Returns the number of template parameters
|
||||
* @return int
|
||||
|
|
|
@ -19,7 +19,6 @@ import org.eclipse.cdt.core.model.CoreModel;
|
|||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.IParent;
|
||||
import org.eclipse.cdt.core.model.IProblemRequestor;
|
||||
import org.eclipse.cdt.core.model.ITemplate;
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
import org.eclipse.cdt.core.parser.IParser;
|
||||
import org.eclipse.cdt.core.parser.IProblem;
|
||||
|
@ -111,12 +110,11 @@ public class CModelBuilder {
|
|||
currentProject = translationUnit.getCProject().getProject();
|
||||
}
|
||||
// check the project's nature
|
||||
if( currentProject != null )
|
||||
{
|
||||
if (currentProject != null) {
|
||||
hasCppNature = CoreModel.hasCCNature(currentProject);
|
||||
}
|
||||
// get the code to parse
|
||||
try{
|
||||
try {
|
||||
code = translationUnit.getBuffer().getCharacters();
|
||||
} catch (CModelException e) {
|
||||
|
||||
|
@ -143,8 +141,7 @@ public class CModelBuilder {
|
|||
|
||||
// create the parser
|
||||
IParser parser = null;
|
||||
try
|
||||
{
|
||||
try {
|
||||
IScannerInfo scanInfo = new ScannerInfo();
|
||||
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(currentProject);
|
||||
if (provider != null){
|
||||
|
@ -179,9 +176,7 @@ public class CModelBuilder {
|
|||
mode,
|
||||
language,
|
||||
ParserUtil.getParserLogService() );
|
||||
}
|
||||
catch( ParserFactoryError pfe )
|
||||
{
|
||||
} catch(ParserFactoryError pfe) {
|
||||
throw new ParserException( CCorePlugin.getResourceString("CModelBuilder.Parser_Construction_Failure")); //$NON-NLS-1$
|
||||
}
|
||||
// call parse
|
||||
|
@ -200,27 +195,20 @@ public class CModelBuilder {
|
|||
|
||||
public Map parse(boolean quickParseMode) throws Exception {
|
||||
long startTime = System.currentTimeMillis();
|
||||
try
|
||||
{
|
||||
try {
|
||||
parse(quickParseMode, true);
|
||||
}
|
||||
|
||||
catch( ParserException e )
|
||||
{
|
||||
} catch( ParserException e ) {
|
||||
Util.debugLog( "Parse Exception in CModelBuilder", IDebugLogConstants.MODEL ); //$NON-NLS-1$
|
||||
//e.printStackTrace();
|
||||
}
|
||||
Util.debugLog("CModel parsing: "+ ( System.currentTimeMillis() - startTime ) + "ms", IDebugLogConstants.MODEL); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
startTime = System.currentTimeMillis();
|
||||
try
|
||||
{
|
||||
try {
|
||||
generateModelElements();
|
||||
// important to know if the unit has parse errors or not
|
||||
translationUnit.getElementInfo().setIsStructureKnown(hasNoErrors && quickParseCallback.hasNoProblems());
|
||||
}
|
||||
catch( NullPointerException npe )
|
||||
{
|
||||
} catch( NullPointerException npe ) {
|
||||
Util.debugLog( "NullPointer exception in CModelBuilder", IDebugLogConstants.MODEL); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
|
@ -314,47 +302,70 @@ public class CModelBuilder {
|
|||
|
||||
private void generateModelElements (Parent parent, IASTTemplateDeclaration templateDeclaration) throws CModelException, ASTNotImplementedException
|
||||
{
|
||||
CElement element = null;
|
||||
// Template Declaration
|
||||
IASTDeclaration declaration = templateDeclaration.getOwnedDeclaration();
|
||||
if (declaration instanceof IASTAbstractTypeSpecifierDeclaration){
|
||||
// Class Template Declation ?
|
||||
IASTAbstractTypeSpecifierDeclaration abstractDeclaration = (IASTAbstractTypeSpecifierDeclaration)declaration ;
|
||||
CElement element = createAbstractElement(parent, abstractDeclaration , true, true);
|
||||
if (element instanceof SourceManipulation) {
|
||||
SourceManipulation sourceRef = (SourceManipulation)element;
|
||||
// set the element position
|
||||
sourceRef.setPos(templateDeclaration.getStartingOffset(), templateDeclaration.getEndingOffset() - templateDeclaration.getStartingOffset());
|
||||
sourceRef.setLines( templateDeclaration.getStartingLine(), templateDeclaration.getEndingLine() );
|
||||
element = createAbstractElement(parent, abstractDeclaration , true, true);
|
||||
String[] parameterTypes = ASTUtil.getTemplateParameters(templateDeclaration);
|
||||
if (element instanceof StructureTemplate) {
|
||||
// set the template parameters
|
||||
String[] parameterTypes = ASTUtil.getTemplateParameters(templateDeclaration);
|
||||
ITemplate classTemplate = (ITemplate) element;
|
||||
StructureTemplate classTemplate = (StructureTemplate) element;
|
||||
classTemplate.setTemplateParameterTypes(parameterTypes);
|
||||
} else if (element instanceof StructureTemplate) {
|
||||
// set the template parameters
|
||||
StructureTemplateDeclaration classTemplate = (StructureTemplateDeclaration) element;
|
||||
classTemplate.setTemplateParameterTypes(parameterTypes);
|
||||
}
|
||||
} else if (declaration instanceof IASTClassSpecifier){
|
||||
// special case for Structural parse
|
||||
// Class template definiton ?
|
||||
IASTClassSpecifier classSpecifier = (IASTClassSpecifier)declaration ;
|
||||
CElement element = createClassSpecifierElement(parent, classSpecifier , true);
|
||||
if (element instanceof SourceManipulation) {
|
||||
SourceManipulation sourceRef = (SourceManipulation)element;
|
||||
// set the element position
|
||||
sourceRef.setPos(templateDeclaration.getStartingOffset(), templateDeclaration.getEndingOffset() - templateDeclaration.getStartingOffset());
|
||||
sourceRef.setLines( templateDeclaration.getStartingLine(), templateDeclaration.getEndingLine() );
|
||||
element = createClassSpecifierElement(parent, classSpecifier , true);
|
||||
String[] parameterTypes = ASTUtil.getTemplateParameters(templateDeclaration);
|
||||
if (element instanceof StructureTemplate) {
|
||||
// set the template parameters
|
||||
String[] parameterTypes = ASTUtil.getTemplateParameters(templateDeclaration);
|
||||
ITemplate classTemplate = (ITemplate) element;
|
||||
StructureTemplate classTemplate = (StructureTemplate) element;
|
||||
classTemplate.setTemplateParameterTypes(parameterTypes);
|
||||
} else if (element instanceof StructureTemplate) {
|
||||
// set the template parameters
|
||||
StructureTemplateDeclaration classTemplate = (StructureTemplateDeclaration) element;
|
||||
classTemplate.setTemplateParameterTypes(parameterTypes);
|
||||
}
|
||||
} else if (declaration instanceof IASTVariable) {
|
||||
// Template variable
|
||||
element = createSimpleElement(parent, declaration, true);
|
||||
// set the template parameters
|
||||
String[] parameterTypes = ASTUtil.getTemplateParameters(templateDeclaration);
|
||||
VariableTemplate varTemplate = (VariableTemplate) element;
|
||||
varTemplate.setTemplateParameterTypes(parameterTypes);
|
||||
} else if (declaration instanceof IASTFunction) {
|
||||
// Function template declaration/Definition
|
||||
element = createSimpleElement(parent, declaration, true);
|
||||
String[] parameterTypes = ASTUtil.getTemplateParameters(templateDeclaration);
|
||||
if (element instanceof FunctionTemplate) {
|
||||
// set the template parameters
|
||||
FunctionTemplate functionTemplate = (FunctionTemplate) element;
|
||||
functionTemplate.setTemplateParameterTypes(parameterTypes);
|
||||
} else if (element instanceof FunctionTemplateDeclaration) {
|
||||
// set the template parameters
|
||||
FunctionTemplateDeclaration functionTemplate = (FunctionTemplateDeclaration) element;
|
||||
functionTemplate.setTemplateParameterTypes(parameterTypes);
|
||||
} else if (element instanceof MethodTemplate) {
|
||||
MethodTemplate methodTemplate = (MethodTemplate) element;
|
||||
methodTemplate.setTemplateParameterTypes(parameterTypes);
|
||||
} else if (element instanceof MethodTemplateDeclaration) {
|
||||
MethodTemplateDeclaration methodTemplate = (MethodTemplateDeclaration) element;
|
||||
methodTemplate.setTemplateParameterTypes(parameterTypes);
|
||||
}
|
||||
}
|
||||
ITemplate template = null;
|
||||
template = (ITemplate) createSimpleElement(parent, declaration, true);
|
||||
|
||||
if (template instanceof SourceManipulation){
|
||||
SourceManipulation sourceRef = (SourceManipulation)template;
|
||||
if (element instanceof SourceManipulation){
|
||||
SourceManipulation sourceRef = (SourceManipulation)element;
|
||||
// set the element position
|
||||
sourceRef.setPos(templateDeclaration.getStartingOffset(), templateDeclaration.getEndingOffset() - templateDeclaration.getStartingOffset());
|
||||
sourceRef.setLines( templateDeclaration.getStartingLine(), templateDeclaration.getEndingLine() );
|
||||
// set the template parameters
|
||||
String[] parameterTypes = ASTUtil.getTemplateParameters(templateDeclaration);
|
||||
template.setTemplateParameterTypes(parameterTypes);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -388,16 +399,15 @@ public class CModelBuilder {
|
|||
IASTEnumerationSpecifier enumSpecifier = (IASTEnumerationSpecifier) typeSpec;
|
||||
IParent enumElement = createEnumeration (parent, enumSpecifier);
|
||||
element = (CElement) enumElement;
|
||||
}
|
||||
// IASTClassSpecifier
|
||||
else if (typeSpec instanceof IASTClassSpecifier) {
|
||||
} else if (typeSpec instanceof IASTClassSpecifier) {
|
||||
// IASTClassSpecifier
|
||||
IASTClassSpecifier classSpecifier = (IASTClassSpecifier) typeSpec;
|
||||
element = createClassSpecifierElement (parent, classSpecifier, isTemplate);
|
||||
} else if (isDeclaration && typeSpec instanceof IASTElaboratedTypeSpecifier) {
|
||||
// This is not a model element, so we don't create anything here.
|
||||
// However, do we need to do anything else?
|
||||
IASTElaboratedTypeSpecifier elabSpecifier = (IASTElaboratedTypeSpecifier) typeSpec;
|
||||
element = createElaboratedTypeSpecifier(parent, elabSpecifier);
|
||||
element = createElaboratedTypeSpecifier(parent, elabSpecifier, isTemplate);
|
||||
}
|
||||
}
|
||||
return element;
|
||||
|
@ -418,21 +428,27 @@ public class CModelBuilder {
|
|||
return element;
|
||||
}
|
||||
|
||||
private StructureDeclaration createElaboratedTypeSpecifier(Parent parent, IASTElaboratedTypeSpecifier typeSpec) throws CModelException{
|
||||
private StructureDeclaration createElaboratedTypeSpecifier(Parent parent, IASTElaboratedTypeSpecifier typeSpec, boolean isTemplate) throws CModelException{
|
||||
// create element
|
||||
ASTClassKind classkind = typeSpec.getClassKind();
|
||||
int kind = -1;
|
||||
if (classkind == ASTClassKind.CLASS) {
|
||||
kind = ICElement.C_CLASS_DECLARATION;
|
||||
kind = (isTemplate) ? ICElement.C_TEMPLATE_CLASS_DECLARATION : ICElement.C_CLASS_DECLARATION;
|
||||
} else if (classkind == ASTClassKind.STRUCT) {
|
||||
kind = ICElement.C_STRUCT_DECLARATION;
|
||||
kind = (isTemplate) ? ICElement.C_TEMPLATE_STRUCT_DECLARATION : ICElement.C_STRUCT_DECLARATION;
|
||||
} else if (classkind == ASTClassKind.UNION) {
|
||||
kind = ICElement.C_UNION_DECLARATION;
|
||||
kind = (isTemplate) ? ICElement.C_TEMPLATE_UNION_DECLARATION : ICElement.C_UNION_DECLARATION;
|
||||
}
|
||||
String className = (typeSpec.getName() == null)
|
||||
? "" //$NON-NLS-1$
|
||||
: typeSpec.getName().toString();
|
||||
StructureDeclaration element = new StructureDeclaration(parent, className, kind);
|
||||
: typeSpec.getName().toString();
|
||||
|
||||
StructureDeclaration element;
|
||||
if (isTemplate) {
|
||||
element = new StructureTemplateDeclaration(parent, kind, className);
|
||||
} else {
|
||||
element = new StructureDeclaration(parent, className, kind);
|
||||
}
|
||||
|
||||
// add to parent
|
||||
parent.addChild(element);
|
||||
|
@ -539,36 +555,18 @@ public class CModelBuilder {
|
|||
int kind = ICElement.C_CLASS;
|
||||
ASTClassKind classkind = classSpecifier.getClassKind();
|
||||
if(classkind == ASTClassKind.CLASS){
|
||||
if(!isTemplate)
|
||||
kind = ICElement.C_CLASS;
|
||||
else
|
||||
kind = ICElement.C_TEMPLATE_CLASS;
|
||||
kind = (isTemplate) ? ICElement.C_TEMPLATE_CLASS : ICElement.C_CLASS;
|
||||
type = "class"; //$NON-NLS-1$
|
||||
className = (classSpecifier.getName() == null )
|
||||
? "" //$NON-NLS-1$
|
||||
: classSpecifier.getName().toString();
|
||||
}
|
||||
if(classkind == ASTClassKind.STRUCT){
|
||||
if(!isTemplate)
|
||||
kind = ICElement.C_STRUCT;
|
||||
else
|
||||
kind = ICElement.C_TEMPLATE_STRUCT;
|
||||
} else if(classkind == ASTClassKind.STRUCT){
|
||||
kind = (isTemplate) ? ICElement.C_TEMPLATE_STRUCT : ICElement.C_STRUCT;
|
||||
type = "struct"; //$NON-NLS-1$
|
||||
className = (classSpecifier.getName() == null )
|
||||
? "" //$NON-NLS-1$
|
||||
: classSpecifier.getName().toString();
|
||||
}
|
||||
if(classkind == ASTClassKind.UNION){
|
||||
if(!isTemplate)
|
||||
kind = ICElement.C_UNION;
|
||||
else
|
||||
kind = ICElement.C_TEMPLATE_UNION;
|
||||
} else if(classkind == ASTClassKind.UNION){
|
||||
kind = (isTemplate) ? ICElement.C_TEMPLATE_UNION : ICElement.C_UNION;
|
||||
type = "union"; //$NON-NLS-1$
|
||||
className = (classSpecifier.getName() == null )
|
||||
? "" //$NON-NLS-1$
|
||||
: classSpecifier.getName().toString();
|
||||
}
|
||||
|
||||
className = (classSpecifier.getName() == null ) ? "" : classSpecifier.getName().toString(); //$NON-NLS-1$
|
||||
|
||||
Structure element;
|
||||
if(!isTemplate){
|
||||
Structure classElement = new Structure( parent, kind, className );
|
||||
|
@ -640,19 +638,17 @@ public class CModelBuilder {
|
|||
newElement.setMutable(fieldDeclaration.isMutable());
|
||||
newElement.setVisibility(fieldDeclaration.getVisiblity());
|
||||
element = newElement;
|
||||
}
|
||||
else {
|
||||
if(isTemplate){
|
||||
} else {
|
||||
if (isTemplate) {
|
||||
// variable
|
||||
VariableTemplate newElement = new VariableTemplate( parent, variableName );
|
||||
element = newElement;
|
||||
}else {
|
||||
} else {
|
||||
if(varDeclaration.isExtern()){
|
||||
// variableDeclaration
|
||||
VariableDeclaration newElement = new VariableDeclaration( parent, variableName );
|
||||
element = newElement;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// variable
|
||||
Variable newElement = new Variable( parent, variableName );
|
||||
element = newElement;
|
||||
|
@ -712,7 +708,7 @@ public class CModelBuilder {
|
|||
MethodDeclaration newElement = new MethodDeclaration( parent, name );
|
||||
methodElement = newElement;
|
||||
}else {
|
||||
MethodTemplate newElement = new MethodTemplate(parent, name);
|
||||
MethodTemplateDeclaration newElement = new MethodTemplateDeclaration(parent, name);
|
||||
methodElement = newElement;
|
||||
}
|
||||
|
||||
|
@ -754,7 +750,7 @@ public class CModelBuilder {
|
|||
FunctionDeclaration newElement = new FunctionDeclaration( parent, name );
|
||||
functionElement = newElement;
|
||||
} else {
|
||||
FunctionTemplate newElement = new FunctionTemplate( parent, name );
|
||||
FunctionTemplateDeclaration newElement = new FunctionTemplateDeclaration( parent, name );
|
||||
functionElement = newElement;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,11 @@ import org.eclipse.cdt.core.model.IFunction;
|
|||
public class Function extends FunctionDeclaration implements IFunction {
|
||||
|
||||
public Function(ICElement parent, String name) {
|
||||
super(parent, name, ICElement.C_FUNCTION);
|
||||
this(parent, name, ICElement.C_FUNCTION);
|
||||
}
|
||||
|
||||
public Function(ICElement parent, String name, int kind) {
|
||||
super(parent, name, kind);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,15 +13,15 @@ package org.eclipse.cdt.internal.core.model;
|
|||
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ITemplate;
|
||||
import org.eclipse.cdt.core.model.IFunctionTemplate;
|
||||
|
||||
public class FunctionTemplate extends FunctionDeclaration implements ITemplate{
|
||||
public class FunctionTemplate extends Function implements IFunctionTemplate {
|
||||
|
||||
protected String[] templateParameterTypes;
|
||||
protected Template fTemplate;
|
||||
|
||||
public FunctionTemplate(ICElement parent, String name) {
|
||||
super(parent, name, ICElement.C_TEMPLATE_FUNCTION);
|
||||
templateParameterTypes= fgEmptyStrings;
|
||||
fTemplate = new Template(name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -30,7 +30,7 @@ public class FunctionTemplate extends FunctionDeclaration implements ITemplate{
|
|||
* @return String[]
|
||||
*/
|
||||
public String[] getTemplateParameterTypes() {
|
||||
return templateParameterTypes;
|
||||
return fTemplate.getTemplateParameterTypes();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -38,13 +38,14 @@ public class FunctionTemplate extends FunctionDeclaration implements ITemplate{
|
|||
* @param fParameterTypes The fParameterTypes to set
|
||||
*/
|
||||
public void setTemplateParameterTypes(String[] templateParameterTypes) {
|
||||
this.templateParameterTypes = templateParameterTypes;
|
||||
fTemplate.setTemplateParameterTypes(templateParameterTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.core.model.ITemplate#getNumberOfTemplateParameters()
|
||||
*/
|
||||
public int getNumberOfTemplateParameters() {
|
||||
return templateParameterTypes == null ? 0 : templateParameterTypes.length;
|
||||
return fTemplate.getNumberOfTemplateParameters();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -59,32 +60,18 @@ public class FunctionTemplate extends FunctionDeclaration implements ITemplate{
|
|||
* return type.
|
||||
*/
|
||||
public String getTemplateSignature() throws CModelException {
|
||||
StringBuffer sig = new StringBuffer(getElementName());
|
||||
if(getNumberOfTemplateParameters() > 0){
|
||||
sig.append("<"); //$NON-NLS-1$
|
||||
String[] paramTypes = getTemplateParameterTypes();
|
||||
int i = 0;
|
||||
sig.append(paramTypes[i++]);
|
||||
while (i < paramTypes.length){
|
||||
sig.append(", "); //$NON-NLS-1$
|
||||
sig.append(paramTypes[i++]);
|
||||
}
|
||||
sig.append(">"); //$NON-NLS-1$
|
||||
}
|
||||
else{
|
||||
sig.append("<>"); //$NON-NLS-1$
|
||||
}
|
||||
StringBuffer sig = new StringBuffer(fTemplate.getTemplateSignature());
|
||||
sig.append(this.getParameterClause());
|
||||
if(isConst())
|
||||
if (isConst()) {
|
||||
sig.append(" const"); //$NON-NLS-1$
|
||||
if(isVolatile())
|
||||
}
|
||||
if (isVolatile()) {
|
||||
sig.append(" volatile"); //$NON-NLS-1$
|
||||
|
||||
if((this.getReturnType() != null) && (this.getReturnType().length() > 0)){
|
||||
}
|
||||
if ((this.getReturnType() != null) && (this.getReturnType().length() > 0)) {
|
||||
sig.append(" : "); //$NON-NLS-1$
|
||||
sig.append(this.getReturnType());
|
||||
}
|
||||
|
||||
return sig.toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 QnX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Qnx Software Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.model;
|
||||
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.IFunctionTemplateDeclaration;
|
||||
|
||||
public class FunctionTemplateDeclaration extends FunctionDeclaration implements IFunctionTemplateDeclaration {
|
||||
|
||||
protected Template fTemplate;
|
||||
|
||||
public FunctionTemplateDeclaration(ICElement parent, String name) {
|
||||
super(parent, name, ICElement.C_TEMPLATE_FUNCTION_DECLARATION);
|
||||
fTemplate = new Template(name);
|
||||
}
|
||||
|
||||
public String[] getTemplateParameterTypes() {
|
||||
return fTemplate.getTemplateParameterTypes();
|
||||
}
|
||||
|
||||
public String getTemplateSignature() throws CModelException {
|
||||
StringBuffer sig = new StringBuffer(fTemplate.getTemplateSignature());
|
||||
sig.append(this.getParameterClause());
|
||||
if(isConst())
|
||||
sig.append(" const"); //$NON-NLS-1$
|
||||
if(isVolatile())
|
||||
sig.append(" volatile"); //$NON-NLS-1$
|
||||
|
||||
if((this.getReturnType() != null) && (this.getReturnType().length() > 0)){
|
||||
sig.append(" : "); //$NON-NLS-1$
|
||||
sig.append(this.getReturnType());
|
||||
}
|
||||
|
||||
return sig.toString();
|
||||
}
|
||||
|
||||
public int getNumberOfTemplateParameters() {
|
||||
return fTemplate.getNumberOfTemplateParameters();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the fParameterTypes.
|
||||
* @param fParameterTypes The fParameterTypes to set
|
||||
*/
|
||||
public void setTemplateParameterTypes(String[] templateParameterTypes) {
|
||||
fTemplate.setTemplateParameterTypes(templateParameterTypes);
|
||||
}
|
||||
|
||||
}
|
|
@ -8,9 +8,13 @@ package org.eclipse.cdt.internal.core.model;
|
|||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.IMethod;
|
||||
|
||||
public class Method extends MethodDeclaration implements IMethod{
|
||||
public class Method extends MethodDeclaration implements IMethod {
|
||||
|
||||
public Method(ICElement parent, String name){
|
||||
super(parent, name, ICElement.C_METHOD);
|
||||
this(parent, name, ICElement.C_METHOD);
|
||||
}
|
||||
|
||||
public Method(ICElement parent, String name, int kind) {
|
||||
super(parent, name, kind);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,16 +13,15 @@ package org.eclipse.cdt.internal.core.model;
|
|||
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ITemplate;
|
||||
import org.eclipse.cdt.core.model.IMethodTemplate;
|
||||
|
||||
public class MethodTemplate extends MethodDeclaration implements ITemplate{
|
||||
|
||||
protected static final String[] fgEmptyList= new String[] {};
|
||||
protected String[] templateParameterTypes;
|
||||
public class MethodTemplate extends Method implements IMethodTemplate {
|
||||
|
||||
protected Template fTemplate;
|
||||
|
||||
public MethodTemplate(ICElement parent, String name) {
|
||||
super(parent, name, ICElement.C_TEMPLATE_METHOD);
|
||||
templateParameterTypes= fgEmptyList;
|
||||
fTemplate = new Template(name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -31,7 +30,7 @@ public class MethodTemplate extends MethodDeclaration implements ITemplate{
|
|||
* @return String[]
|
||||
*/
|
||||
public String[] getTemplateParameterTypes() {
|
||||
return templateParameterTypes;
|
||||
return fTemplate.getTemplateParameterTypes();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,13 +38,14 @@ public class MethodTemplate extends MethodDeclaration implements ITemplate{
|
|||
* @param fParameterTypes The fParameterTypes to set
|
||||
*/
|
||||
public void setTemplateParameterTypes(String[] templateParameterTypes) {
|
||||
this.templateParameterTypes = templateParameterTypes;
|
||||
fTemplate.setTemplateParameterTypes(templateParameterTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.core.model.ITemplate#getNumberOfTemplateParameters()
|
||||
*/
|
||||
public int getNumberOfTemplateParameters() {
|
||||
return templateParameterTypes == null ? 0 : templateParameterTypes.length;
|
||||
return fTemplate.getNumberOfTemplateParameters();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -61,21 +61,7 @@ public class MethodTemplate extends MethodDeclaration implements ITemplate{
|
|||
*/
|
||||
|
||||
public String getTemplateSignature() throws CModelException {
|
||||
StringBuffer sig = new StringBuffer(getElementName());
|
||||
if(getNumberOfTemplateParameters() > 0){
|
||||
sig.append("<"); //$NON-NLS-1$
|
||||
String[] paramTypes = getTemplateParameterTypes();
|
||||
int i = 0;
|
||||
sig.append(paramTypes[i++]);
|
||||
while (i < paramTypes.length){
|
||||
sig.append(", "); //$NON-NLS-1$
|
||||
sig.append(paramTypes[i++]);
|
||||
}
|
||||
sig.append(">"); //$NON-NLS-1$
|
||||
}
|
||||
else{
|
||||
sig.append("<>"); //$NON-NLS-1$
|
||||
}
|
||||
StringBuffer sig = new StringBuffer(fTemplate.getTemplateSignature());
|
||||
sig.append(this.getParameterClause());
|
||||
if(isConst())
|
||||
sig.append(" const"); //$NON-NLS-1$
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 QnX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Qnx Software Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.model;
|
||||
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.IMethodTemplateDeclaration;
|
||||
|
||||
public class MethodTemplateDeclaration extends MethodDeclaration implements IMethodTemplateDeclaration {
|
||||
|
||||
protected Template fTemplate;
|
||||
|
||||
public MethodTemplateDeclaration(ICElement parent, String name) {
|
||||
super(parent, name, ICElement.C_TEMPLATE_METHOD_DECLARATION);
|
||||
fTemplate = new Template(name);
|
||||
}
|
||||
|
||||
public String[] getTemplateParameterTypes() {
|
||||
return fTemplate.getTemplateParameterTypes();
|
||||
}
|
||||
|
||||
public String getTemplateSignature() throws CModelException {
|
||||
StringBuffer sig = new StringBuffer(fTemplate.getTemplateSignature());
|
||||
sig.append(this.getParameterClause());
|
||||
if(isConst())
|
||||
sig.append(" const"); //$NON-NLS-1$
|
||||
if(isVolatile())
|
||||
sig.append(" volatile"); //$NON-NLS-1$
|
||||
|
||||
if((this.getReturnType() != null) && (this.getReturnType().length() > 0)){
|
||||
sig.append(" : "); //$NON-NLS-1$
|
||||
sig.append(this.getReturnType());
|
||||
}
|
||||
|
||||
return sig.toString();
|
||||
|
||||
}
|
||||
|
||||
public int getNumberOfTemplateParameters() {
|
||||
return fTemplate.getNumberOfTemplateParameters();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the fParameterTypes.
|
||||
* @param fParameterTypes The fParameterTypes to set
|
||||
*/
|
||||
public void setTemplateParameterTypes(String[] templateParameterTypes) {
|
||||
fTemplate.setTemplateParameterTypes(templateParameterTypes);
|
||||
}
|
||||
|
||||
}
|
|
@ -11,16 +11,15 @@ package org.eclipse.cdt.internal.core.model;
|
|||
* Rational Software - Initial API and implementation
|
||||
***********************************************************************/
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ITemplate;
|
||||
import org.eclipse.cdt.core.model.IStructureTemplate;
|
||||
|
||||
public class StructureTemplate extends Structure implements ITemplate{
|
||||
|
||||
protected static final String[] fgEmptyList= new String[] {};
|
||||
protected String[] templateParameterTypes;
|
||||
public class StructureTemplate extends Structure implements IStructureTemplate {
|
||||
|
||||
protected Template fTemplate;
|
||||
|
||||
public StructureTemplate(ICElement parent, int kind, String name) {
|
||||
super(parent, kind, name);
|
||||
templateParameterTypes= fgEmptyList;
|
||||
fTemplate = new Template(name);
|
||||
}
|
||||
/**
|
||||
* Returns the parameterTypes.
|
||||
|
@ -28,7 +27,7 @@ public class StructureTemplate extends Structure implements ITemplate{
|
|||
* @return String[]
|
||||
*/
|
||||
public String[] getTemplateParameterTypes() {
|
||||
return templateParameterTypes;
|
||||
return fTemplate.getTemplateParameterTypes();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -36,36 +35,21 @@ public class StructureTemplate extends Structure implements ITemplate{
|
|||
* @param fParameterTypes The fParameterTypes to set
|
||||
*/
|
||||
public void setTemplateParameterTypes(String[] templateParameterTypes) {
|
||||
this.templateParameterTypes = templateParameterTypes;
|
||||
fTemplate.setTemplateParameterTypes(templateParameterTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.core.model.ITemplate#getNumberOfTemplateParameters()
|
||||
*/
|
||||
public int getNumberOfTemplateParameters() {
|
||||
return templateParameterTypes == null ? 0 : templateParameterTypes.length;
|
||||
return fTemplate.getNumberOfTemplateParameters();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateSignature()
|
||||
*/
|
||||
public String getTemplateSignature() {
|
||||
StringBuffer sig = new StringBuffer(getElementName());
|
||||
if(getNumberOfTemplateParameters() > 0){
|
||||
sig.append("<"); //$NON-NLS-1$
|
||||
String[] paramTypes = getTemplateParameterTypes();
|
||||
int i = 0;
|
||||
sig.append(paramTypes[i++]);
|
||||
while (i < paramTypes.length){
|
||||
sig.append(", "); //$NON-NLS-1$
|
||||
sig.append(paramTypes[i++]);
|
||||
}
|
||||
sig.append(">"); //$NON-NLS-1$
|
||||
}
|
||||
else{
|
||||
sig.append("<>"); //$NON-NLS-1$
|
||||
}
|
||||
return sig.toString();
|
||||
return fTemplate.getTemplateSignature();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 QnX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Qnx Software Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.model;
|
||||
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.IStructureTemplateDeclaration;
|
||||
|
||||
public class StructureTemplateDeclaration extends StructureDeclaration implements IStructureTemplateDeclaration {
|
||||
|
||||
Template fTemplate;
|
||||
|
||||
public StructureTemplateDeclaration(ICElement parent, int kind, String name) {
|
||||
super(parent, name, kind);
|
||||
fTemplate = new Template(name);
|
||||
}
|
||||
|
||||
public String[] getTemplateParameterTypes() {
|
||||
return fTemplate.getTemplateParameterTypes();
|
||||
}
|
||||
|
||||
public void setTemplateParameterTypes(String[] templateParameterTypes) {
|
||||
fTemplate.setTemplateParameterTypes(templateParameterTypes);
|
||||
}
|
||||
|
||||
public String getTemplateSignature() throws CModelException {
|
||||
return fTemplate.getTemplateSignature();
|
||||
}
|
||||
|
||||
public int getNumberOfTemplateParameters() {
|
||||
return fTemplate.getNumberOfTemplateParameters();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 QnX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Qnx Software Systems - initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.model;
|
||||
|
||||
import org.eclipse.cdt.core.model.ITemplate;
|
||||
|
||||
public class Template implements ITemplate {
|
||||
|
||||
protected static final String[] fgEmptyList= new String[] {};
|
||||
protected String[] templateParameterTypes;
|
||||
protected String fName;
|
||||
|
||||
public Template(String name) {
|
||||
fName = name;
|
||||
templateParameterTypes= fgEmptyList;
|
||||
}
|
||||
/**
|
||||
* Returns the parameterTypes.
|
||||
* @see org.eclipse.cdt.core.model.ITemplate#getParameters()
|
||||
* @return String[]
|
||||
*/
|
||||
public String[] getTemplateParameterTypes() {
|
||||
return templateParameterTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the fParameterTypes.
|
||||
* @param fParameterTypes The fParameterTypes to set
|
||||
*/
|
||||
public void setTemplateParameterTypes(String[] templateParameterTypes) {
|
||||
this.templateParameterTypes = templateParameterTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.core.model.ITemplate#getNumberOfTemplateParameters()
|
||||
*/
|
||||
public int getNumberOfTemplateParameters() {
|
||||
return templateParameterTypes == null ? 0 : templateParameterTypes.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateSignature()
|
||||
*/
|
||||
public String getTemplateSignature() {
|
||||
StringBuffer sig = new StringBuffer(fName);
|
||||
if(getNumberOfTemplateParameters() > 0){
|
||||
sig.append("<"); //$NON-NLS-1$
|
||||
String[] paramTypes = getTemplateParameterTypes();
|
||||
int i = 0;
|
||||
sig.append(paramTypes[i++]);
|
||||
while (i < paramTypes.length){
|
||||
sig.append(", "); //$NON-NLS-1$
|
||||
sig.append(paramTypes[i++]);
|
||||
}
|
||||
sig.append(">"); //$NON-NLS-1$
|
||||
}
|
||||
else{
|
||||
sig.append("<>"); //$NON-NLS-1$
|
||||
}
|
||||
return sig.toString();
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue