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
|
2005-06-22 Vladimir Hirsl
|
||||||
Fix for PR 93573: "[Indexer] endl references are not added to the DOM index"
|
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.
|
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;
|
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.
|
* Constant representing a class structure.
|
||||||
*/
|
*/
|
||||||
static final int C_CLASS = 64;
|
static final int C_CLASS = 65;
|
||||||
|
|
||||||
/**
|
|
||||||
* 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;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Declaration of a structure without the definition.
|
* Declaration of a structure without the definition.
|
||||||
* struct C;
|
* struct C;
|
||||||
*/
|
*/
|
||||||
static final int C_STRUCT_DECLARATION = 85;
|
static final int C_STRUCT_DECLARATION = 66;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Declaration of a class without the definition.
|
* Constant representing a struct structure.
|
||||||
* class C;
|
|
||||||
*/
|
*/
|
||||||
static final int C_CLASS_DECLARATION = 86;
|
static final int C_STRUCT = 67;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Declaration of a union without the definition.
|
* Declaration of a union without the definition.
|
||||||
* struct C;
|
* 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.
|
* 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
|
* 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
|
* 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:
|
* Contributors:
|
||||||
* Rational Software - initial implementation
|
* Rational Software - initial implementation
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
public interface ITemplate extends IDeclaration {
|
public interface ITemplate {
|
||||||
/**
|
/**
|
||||||
* Returns the template parameter types.
|
* Returns the template parameter types.
|
||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
String[] getTemplateParameterTypes();
|
String[] getTemplateParameterTypes();
|
||||||
/**
|
|
||||||
* Sets the template parameter types.
|
|
||||||
* @param paramTypes
|
|
||||||
*/
|
|
||||||
void setTemplateParameterTypes(String[] templateParameterTypes);
|
|
||||||
/**
|
/**
|
||||||
* Returns the template signature
|
* Returns the template signature
|
||||||
* The signature depends on the type of template.
|
* 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.
|
* name, its template parameters, followed by its normal parameters.
|
||||||
* @return String
|
* @return String
|
||||||
* @throws CModelException
|
* @throws CModelException
|
||||||
*/
|
*/
|
||||||
|
|
||||||
String getTemplateSignature() throws CModelException;
|
String getTemplateSignature() throws CModelException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of template parameters
|
* Returns the number of template parameters
|
||||||
* @return int
|
* @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.ICElement;
|
||||||
import org.eclipse.cdt.core.model.IParent;
|
import org.eclipse.cdt.core.model.IParent;
|
||||||
import org.eclipse.cdt.core.model.IProblemRequestor;
|
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.CodeReader;
|
||||||
import org.eclipse.cdt.core.parser.IParser;
|
import org.eclipse.cdt.core.parser.IParser;
|
||||||
import org.eclipse.cdt.core.parser.IProblem;
|
import org.eclipse.cdt.core.parser.IProblem;
|
||||||
|
@ -111,12 +110,11 @@ public class CModelBuilder {
|
||||||
currentProject = translationUnit.getCProject().getProject();
|
currentProject = translationUnit.getCProject().getProject();
|
||||||
}
|
}
|
||||||
// check the project's nature
|
// check the project's nature
|
||||||
if( currentProject != null )
|
if (currentProject != null) {
|
||||||
{
|
|
||||||
hasCppNature = CoreModel.hasCCNature(currentProject);
|
hasCppNature = CoreModel.hasCCNature(currentProject);
|
||||||
}
|
}
|
||||||
// get the code to parse
|
// get the code to parse
|
||||||
try{
|
try {
|
||||||
code = translationUnit.getBuffer().getCharacters();
|
code = translationUnit.getBuffer().getCharacters();
|
||||||
} catch (CModelException e) {
|
} catch (CModelException e) {
|
||||||
|
|
||||||
|
@ -143,8 +141,7 @@ public class CModelBuilder {
|
||||||
|
|
||||||
// create the parser
|
// create the parser
|
||||||
IParser parser = null;
|
IParser parser = null;
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
IScannerInfo scanInfo = new ScannerInfo();
|
IScannerInfo scanInfo = new ScannerInfo();
|
||||||
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(currentProject);
|
IScannerInfoProvider provider = CCorePlugin.getDefault().getScannerInfoProvider(currentProject);
|
||||||
if (provider != null){
|
if (provider != null){
|
||||||
|
@ -179,9 +176,7 @@ public class CModelBuilder {
|
||||||
mode,
|
mode,
|
||||||
language,
|
language,
|
||||||
ParserUtil.getParserLogService() );
|
ParserUtil.getParserLogService() );
|
||||||
}
|
} catch(ParserFactoryError pfe) {
|
||||||
catch( ParserFactoryError pfe )
|
|
||||||
{
|
|
||||||
throw new ParserException( CCorePlugin.getResourceString("CModelBuilder.Parser_Construction_Failure")); //$NON-NLS-1$
|
throw new ParserException( CCorePlugin.getResourceString("CModelBuilder.Parser_Construction_Failure")); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
// call parse
|
// call parse
|
||||||
|
@ -200,27 +195,20 @@ public class CModelBuilder {
|
||||||
|
|
||||||
public Map parse(boolean quickParseMode) throws Exception {
|
public Map parse(boolean quickParseMode) throws Exception {
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
parse(quickParseMode, true);
|
parse(quickParseMode, true);
|
||||||
}
|
} catch( ParserException e ) {
|
||||||
|
|
||||||
catch( ParserException e )
|
|
||||||
{
|
|
||||||
Util.debugLog( "Parse Exception in CModelBuilder", IDebugLogConstants.MODEL ); //$NON-NLS-1$
|
Util.debugLog( "Parse Exception in CModelBuilder", IDebugLogConstants.MODEL ); //$NON-NLS-1$
|
||||||
//e.printStackTrace();
|
//e.printStackTrace();
|
||||||
}
|
}
|
||||||
Util.debugLog("CModel parsing: "+ ( System.currentTimeMillis() - startTime ) + "ms", IDebugLogConstants.MODEL); //$NON-NLS-1$ //$NON-NLS-2$
|
Util.debugLog("CModel parsing: "+ ( System.currentTimeMillis() - startTime ) + "ms", IDebugLogConstants.MODEL); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
|
||||||
startTime = System.currentTimeMillis();
|
startTime = System.currentTimeMillis();
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
generateModelElements();
|
generateModelElements();
|
||||||
// important to know if the unit has parse errors or not
|
// important to know if the unit has parse errors or not
|
||||||
translationUnit.getElementInfo().setIsStructureKnown(hasNoErrors && quickParseCallback.hasNoProblems());
|
translationUnit.getElementInfo().setIsStructureKnown(hasNoErrors && quickParseCallback.hasNoProblems());
|
||||||
}
|
} catch( NullPointerException npe ) {
|
||||||
catch( NullPointerException npe )
|
|
||||||
{
|
|
||||||
Util.debugLog( "NullPointer exception in CModelBuilder", IDebugLogConstants.MODEL); //$NON-NLS-1$
|
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
|
private void generateModelElements (Parent parent, IASTTemplateDeclaration templateDeclaration) throws CModelException, ASTNotImplementedException
|
||||||
{
|
{
|
||||||
|
CElement element = null;
|
||||||
// Template Declaration
|
// Template Declaration
|
||||||
IASTDeclaration declaration = templateDeclaration.getOwnedDeclaration();
|
IASTDeclaration declaration = templateDeclaration.getOwnedDeclaration();
|
||||||
if (declaration instanceof IASTAbstractTypeSpecifierDeclaration){
|
if (declaration instanceof IASTAbstractTypeSpecifierDeclaration){
|
||||||
|
// Class Template Declation ?
|
||||||
IASTAbstractTypeSpecifierDeclaration abstractDeclaration = (IASTAbstractTypeSpecifierDeclaration)declaration ;
|
IASTAbstractTypeSpecifierDeclaration abstractDeclaration = (IASTAbstractTypeSpecifierDeclaration)declaration ;
|
||||||
CElement element = createAbstractElement(parent, abstractDeclaration , true, true);
|
element = createAbstractElement(parent, abstractDeclaration , true, true);
|
||||||
if (element instanceof SourceManipulation) {
|
String[] parameterTypes = ASTUtil.getTemplateParameters(templateDeclaration);
|
||||||
SourceManipulation sourceRef = (SourceManipulation)element;
|
if (element instanceof StructureTemplate) {
|
||||||
// set the element position
|
|
||||||
sourceRef.setPos(templateDeclaration.getStartingOffset(), templateDeclaration.getEndingOffset() - templateDeclaration.getStartingOffset());
|
|
||||||
sourceRef.setLines( templateDeclaration.getStartingLine(), templateDeclaration.getEndingLine() );
|
|
||||||
// set the template parameters
|
// set the template parameters
|
||||||
String[] parameterTypes = ASTUtil.getTemplateParameters(templateDeclaration);
|
StructureTemplate classTemplate = (StructureTemplate) element;
|
||||||
ITemplate classTemplate = (ITemplate) element;
|
classTemplate.setTemplateParameterTypes(parameterTypes);
|
||||||
|
} else if (element instanceof StructureTemplate) {
|
||||||
|
// set the template parameters
|
||||||
|
StructureTemplateDeclaration classTemplate = (StructureTemplateDeclaration) element;
|
||||||
classTemplate.setTemplateParameterTypes(parameterTypes);
|
classTemplate.setTemplateParameterTypes(parameterTypes);
|
||||||
}
|
}
|
||||||
} else if (declaration instanceof IASTClassSpecifier){
|
} else if (declaration instanceof IASTClassSpecifier){
|
||||||
// special case for Structural parse
|
// special case for Structural parse
|
||||||
|
// Class template definiton ?
|
||||||
IASTClassSpecifier classSpecifier = (IASTClassSpecifier)declaration ;
|
IASTClassSpecifier classSpecifier = (IASTClassSpecifier)declaration ;
|
||||||
CElement element = createClassSpecifierElement(parent, classSpecifier , true);
|
element = createClassSpecifierElement(parent, classSpecifier , true);
|
||||||
if (element instanceof SourceManipulation) {
|
String[] parameterTypes = ASTUtil.getTemplateParameters(templateDeclaration);
|
||||||
SourceManipulation sourceRef = (SourceManipulation)element;
|
if (element instanceof StructureTemplate) {
|
||||||
// set the element position
|
|
||||||
sourceRef.setPos(templateDeclaration.getStartingOffset(), templateDeclaration.getEndingOffset() - templateDeclaration.getStartingOffset());
|
|
||||||
sourceRef.setLines( templateDeclaration.getStartingLine(), templateDeclaration.getEndingLine() );
|
|
||||||
// set the template parameters
|
// set the template parameters
|
||||||
String[] parameterTypes = ASTUtil.getTemplateParameters(templateDeclaration);
|
StructureTemplate classTemplate = (StructureTemplate) element;
|
||||||
ITemplate classTemplate = (ITemplate) element;
|
classTemplate.setTemplateParameterTypes(parameterTypes);
|
||||||
|
} else if (element instanceof StructureTemplate) {
|
||||||
|
// set the template parameters
|
||||||
|
StructureTemplateDeclaration classTemplate = (StructureTemplateDeclaration) element;
|
||||||
classTemplate.setTemplateParameterTypes(parameterTypes);
|
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;
|
if (element instanceof SourceManipulation){
|
||||||
template = (ITemplate) createSimpleElement(parent, declaration, true);
|
SourceManipulation sourceRef = (SourceManipulation)element;
|
||||||
|
|
||||||
if (template instanceof SourceManipulation){
|
|
||||||
SourceManipulation sourceRef = (SourceManipulation)template;
|
|
||||||
// set the element position
|
// set the element position
|
||||||
sourceRef.setPos(templateDeclaration.getStartingOffset(), templateDeclaration.getEndingOffset() - templateDeclaration.getStartingOffset());
|
sourceRef.setPos(templateDeclaration.getStartingOffset(), templateDeclaration.getEndingOffset() - templateDeclaration.getStartingOffset());
|
||||||
sourceRef.setLines( templateDeclaration.getStartingLine(), templateDeclaration.getEndingLine() );
|
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;
|
IASTEnumerationSpecifier enumSpecifier = (IASTEnumerationSpecifier) typeSpec;
|
||||||
IParent enumElement = createEnumeration (parent, enumSpecifier);
|
IParent enumElement = createEnumeration (parent, enumSpecifier);
|
||||||
element = (CElement) enumElement;
|
element = (CElement) enumElement;
|
||||||
}
|
} else if (typeSpec instanceof IASTClassSpecifier) {
|
||||||
// IASTClassSpecifier
|
// IASTClassSpecifier
|
||||||
else if (typeSpec instanceof IASTClassSpecifier) {
|
|
||||||
IASTClassSpecifier classSpecifier = (IASTClassSpecifier) typeSpec;
|
IASTClassSpecifier classSpecifier = (IASTClassSpecifier) typeSpec;
|
||||||
element = createClassSpecifierElement (parent, classSpecifier, isTemplate);
|
element = createClassSpecifierElement (parent, classSpecifier, isTemplate);
|
||||||
} else if (isDeclaration && typeSpec instanceof IASTElaboratedTypeSpecifier) {
|
} else if (isDeclaration && typeSpec instanceof IASTElaboratedTypeSpecifier) {
|
||||||
// This is not a model element, so we don't create anything here.
|
// This is not a model element, so we don't create anything here.
|
||||||
// However, do we need to do anything else?
|
// However, do we need to do anything else?
|
||||||
IASTElaboratedTypeSpecifier elabSpecifier = (IASTElaboratedTypeSpecifier) typeSpec;
|
IASTElaboratedTypeSpecifier elabSpecifier = (IASTElaboratedTypeSpecifier) typeSpec;
|
||||||
element = createElaboratedTypeSpecifier(parent, elabSpecifier);
|
element = createElaboratedTypeSpecifier(parent, elabSpecifier, isTemplate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return element;
|
return element;
|
||||||
|
@ -418,21 +428,27 @@ public class CModelBuilder {
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
private StructureDeclaration createElaboratedTypeSpecifier(Parent parent, IASTElaboratedTypeSpecifier typeSpec) throws CModelException{
|
private StructureDeclaration createElaboratedTypeSpecifier(Parent parent, IASTElaboratedTypeSpecifier typeSpec, boolean isTemplate) throws CModelException{
|
||||||
// create element
|
// create element
|
||||||
ASTClassKind classkind = typeSpec.getClassKind();
|
ASTClassKind classkind = typeSpec.getClassKind();
|
||||||
int kind = -1;
|
int kind = -1;
|
||||||
if (classkind == ASTClassKind.CLASS) {
|
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) {
|
} 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) {
|
} 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)
|
String className = (typeSpec.getName() == null)
|
||||||
? "" //$NON-NLS-1$
|
? "" //$NON-NLS-1$
|
||||||
: typeSpec.getName().toString();
|
: typeSpec.getName().toString();
|
||||||
StructureDeclaration element = new StructureDeclaration(parent, className, kind);
|
|
||||||
|
StructureDeclaration element;
|
||||||
|
if (isTemplate) {
|
||||||
|
element = new StructureTemplateDeclaration(parent, kind, className);
|
||||||
|
} else {
|
||||||
|
element = new StructureDeclaration(parent, className, kind);
|
||||||
|
}
|
||||||
|
|
||||||
// add to parent
|
// add to parent
|
||||||
parent.addChild(element);
|
parent.addChild(element);
|
||||||
|
@ -539,36 +555,18 @@ public class CModelBuilder {
|
||||||
int kind = ICElement.C_CLASS;
|
int kind = ICElement.C_CLASS;
|
||||||
ASTClassKind classkind = classSpecifier.getClassKind();
|
ASTClassKind classkind = classSpecifier.getClassKind();
|
||||||
if(classkind == ASTClassKind.CLASS){
|
if(classkind == ASTClassKind.CLASS){
|
||||||
if(!isTemplate)
|
kind = (isTemplate) ? ICElement.C_TEMPLATE_CLASS : ICElement.C_CLASS;
|
||||||
kind = ICElement.C_CLASS;
|
|
||||||
else
|
|
||||||
kind = ICElement.C_TEMPLATE_CLASS;
|
|
||||||
type = "class"; //$NON-NLS-1$
|
type = "class"; //$NON-NLS-1$
|
||||||
className = (classSpecifier.getName() == null )
|
} else if(classkind == ASTClassKind.STRUCT){
|
||||||
? "" //$NON-NLS-1$
|
kind = (isTemplate) ? ICElement.C_TEMPLATE_STRUCT : ICElement.C_STRUCT;
|
||||||
: classSpecifier.getName().toString();
|
|
||||||
}
|
|
||||||
if(classkind == ASTClassKind.STRUCT){
|
|
||||||
if(!isTemplate)
|
|
||||||
kind = ICElement.C_STRUCT;
|
|
||||||
else
|
|
||||||
kind = ICElement.C_TEMPLATE_STRUCT;
|
|
||||||
type = "struct"; //$NON-NLS-1$
|
type = "struct"; //$NON-NLS-1$
|
||||||
className = (classSpecifier.getName() == null )
|
} else if(classkind == ASTClassKind.UNION){
|
||||||
? "" //$NON-NLS-1$
|
kind = (isTemplate) ? ICElement.C_TEMPLATE_UNION : ICElement.C_UNION;
|
||||||
: classSpecifier.getName().toString();
|
|
||||||
}
|
|
||||||
if(classkind == ASTClassKind.UNION){
|
|
||||||
if(!isTemplate)
|
|
||||||
kind = ICElement.C_UNION;
|
|
||||||
else
|
|
||||||
kind = ICElement.C_TEMPLATE_UNION;
|
|
||||||
type = "union"; //$NON-NLS-1$
|
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;
|
Structure element;
|
||||||
if(!isTemplate){
|
if(!isTemplate){
|
||||||
Structure classElement = new Structure( parent, kind, className );
|
Structure classElement = new Structure( parent, kind, className );
|
||||||
|
@ -640,19 +638,17 @@ public class CModelBuilder {
|
||||||
newElement.setMutable(fieldDeclaration.isMutable());
|
newElement.setMutable(fieldDeclaration.isMutable());
|
||||||
newElement.setVisibility(fieldDeclaration.getVisiblity());
|
newElement.setVisibility(fieldDeclaration.getVisiblity());
|
||||||
element = newElement;
|
element = newElement;
|
||||||
}
|
} else {
|
||||||
else {
|
if (isTemplate) {
|
||||||
if(isTemplate){
|
|
||||||
// variable
|
// variable
|
||||||
VariableTemplate newElement = new VariableTemplate( parent, variableName );
|
VariableTemplate newElement = new VariableTemplate( parent, variableName );
|
||||||
element = newElement;
|
element = newElement;
|
||||||
}else {
|
} else {
|
||||||
if(varDeclaration.isExtern()){
|
if(varDeclaration.isExtern()){
|
||||||
// variableDeclaration
|
// variableDeclaration
|
||||||
VariableDeclaration newElement = new VariableDeclaration( parent, variableName );
|
VariableDeclaration newElement = new VariableDeclaration( parent, variableName );
|
||||||
element = newElement;
|
element = newElement;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
// variable
|
// variable
|
||||||
Variable newElement = new Variable( parent, variableName );
|
Variable newElement = new Variable( parent, variableName );
|
||||||
element = newElement;
|
element = newElement;
|
||||||
|
@ -712,7 +708,7 @@ public class CModelBuilder {
|
||||||
MethodDeclaration newElement = new MethodDeclaration( parent, name );
|
MethodDeclaration newElement = new MethodDeclaration( parent, name );
|
||||||
methodElement = newElement;
|
methodElement = newElement;
|
||||||
}else {
|
}else {
|
||||||
MethodTemplate newElement = new MethodTemplate(parent, name);
|
MethodTemplateDeclaration newElement = new MethodTemplateDeclaration(parent, name);
|
||||||
methodElement = newElement;
|
methodElement = newElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -754,7 +750,7 @@ public class CModelBuilder {
|
||||||
FunctionDeclaration newElement = new FunctionDeclaration( parent, name );
|
FunctionDeclaration newElement = new FunctionDeclaration( parent, name );
|
||||||
functionElement = newElement;
|
functionElement = newElement;
|
||||||
} else {
|
} else {
|
||||||
FunctionTemplate newElement = new FunctionTemplate( parent, name );
|
FunctionTemplateDeclaration newElement = new FunctionTemplateDeclaration( parent, name );
|
||||||
functionElement = newElement;
|
functionElement = newElement;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,11 @@ import org.eclipse.cdt.core.model.IFunction;
|
||||||
public class Function extends FunctionDeclaration implements IFunction {
|
public class Function extends FunctionDeclaration implements IFunction {
|
||||||
|
|
||||||
public Function(ICElement parent, String name) {
|
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.CModelException;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
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) {
|
public FunctionTemplate(ICElement parent, String name) {
|
||||||
super(parent, name, ICElement.C_TEMPLATE_FUNCTION);
|
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[]
|
* @return String[]
|
||||||
*/
|
*/
|
||||||
public String[] getTemplateParameterTypes() {
|
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
|
* @param fParameterTypes The fParameterTypes to set
|
||||||
*/
|
*/
|
||||||
public void setTemplateParameterTypes(String[] templateParameterTypes) {
|
public void setTemplateParameterTypes(String[] templateParameterTypes) {
|
||||||
this.templateParameterTypes = templateParameterTypes;
|
fTemplate.setTemplateParameterTypes(templateParameterTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.core.model.ITemplate#getNumberOfTemplateParameters()
|
* @see org.eclipse.cdt.core.model.ITemplate#getNumberOfTemplateParameters()
|
||||||
*/
|
*/
|
||||||
public int 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.
|
* return type.
|
||||||
*/
|
*/
|
||||||
public String getTemplateSignature() throws CModelException {
|
public String getTemplateSignature() throws CModelException {
|
||||||
StringBuffer sig = new StringBuffer(getElementName());
|
StringBuffer sig = new StringBuffer(fTemplate.getTemplateSignature());
|
||||||
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$
|
|
||||||
}
|
|
||||||
sig.append(this.getParameterClause());
|
sig.append(this.getParameterClause());
|
||||||
if(isConst())
|
if (isConst()) {
|
||||||
sig.append(" const"); //$NON-NLS-1$
|
sig.append(" const"); //$NON-NLS-1$
|
||||||
if(isVolatile())
|
}
|
||||||
|
if (isVolatile()) {
|
||||||
sig.append(" volatile"); //$NON-NLS-1$
|
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(" : "); //$NON-NLS-1$
|
||||||
sig.append(this.getReturnType());
|
sig.append(this.getReturnType());
|
||||||
}
|
}
|
||||||
|
|
||||||
return sig.toString();
|
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.ICElement;
|
||||||
import org.eclipse.cdt.core.model.IMethod;
|
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){
|
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.CModelException;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
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{
|
public class MethodTemplate extends Method implements IMethodTemplate {
|
||||||
|
|
||||||
protected static final String[] fgEmptyList= new String[] {};
|
protected Template fTemplate;
|
||||||
protected String[] templateParameterTypes;
|
|
||||||
|
|
||||||
public MethodTemplate(ICElement parent, String name) {
|
public MethodTemplate(ICElement parent, String name) {
|
||||||
super(parent, name, ICElement.C_TEMPLATE_METHOD);
|
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[]
|
* @return String[]
|
||||||
*/
|
*/
|
||||||
public String[] getTemplateParameterTypes() {
|
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
|
* @param fParameterTypes The fParameterTypes to set
|
||||||
*/
|
*/
|
||||||
public void setTemplateParameterTypes(String[] templateParameterTypes) {
|
public void setTemplateParameterTypes(String[] templateParameterTypes) {
|
||||||
this.templateParameterTypes = templateParameterTypes;
|
fTemplate.setTemplateParameterTypes(templateParameterTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.core.model.ITemplate#getNumberOfTemplateParameters()
|
* @see org.eclipse.cdt.core.model.ITemplate#getNumberOfTemplateParameters()
|
||||||
*/
|
*/
|
||||||
public int 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 {
|
public String getTemplateSignature() throws CModelException {
|
||||||
StringBuffer sig = new StringBuffer(getElementName());
|
StringBuffer sig = new StringBuffer(fTemplate.getTemplateSignature());
|
||||||
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$
|
|
||||||
}
|
|
||||||
sig.append(this.getParameterClause());
|
sig.append(this.getParameterClause());
|
||||||
if(isConst())
|
if(isConst())
|
||||||
sig.append(" const"); //$NON-NLS-1$
|
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
|
* Rational Software - Initial API and implementation
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
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{
|
public class StructureTemplate extends Structure implements IStructureTemplate {
|
||||||
|
|
||||||
protected static final String[] fgEmptyList= new String[] {};
|
protected Template fTemplate;
|
||||||
protected String[] templateParameterTypes;
|
|
||||||
|
|
||||||
public StructureTemplate(ICElement parent, int kind, String name) {
|
public StructureTemplate(ICElement parent, int kind, String name) {
|
||||||
super(parent, kind, name);
|
super(parent, kind, name);
|
||||||
templateParameterTypes= fgEmptyList;
|
fTemplate = new Template(name);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Returns the parameterTypes.
|
* Returns the parameterTypes.
|
||||||
|
@ -28,7 +27,7 @@ public class StructureTemplate extends Structure implements ITemplate{
|
||||||
* @return String[]
|
* @return String[]
|
||||||
*/
|
*/
|
||||||
public String[] getTemplateParameterTypes() {
|
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
|
* @param fParameterTypes The fParameterTypes to set
|
||||||
*/
|
*/
|
||||||
public void setTemplateParameterTypes(String[] templateParameterTypes) {
|
public void setTemplateParameterTypes(String[] templateParameterTypes) {
|
||||||
this.templateParameterTypes = templateParameterTypes;
|
fTemplate.setTemplateParameterTypes(templateParameterTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.core.model.ITemplate#getNumberOfTemplateParameters()
|
* @see org.eclipse.cdt.core.model.ITemplate#getNumberOfTemplateParameters()
|
||||||
*/
|
*/
|
||||||
public int getNumberOfTemplateParameters() {
|
public int getNumberOfTemplateParameters() {
|
||||||
return templateParameterTypes == null ? 0 : templateParameterTypes.length;
|
return fTemplate.getNumberOfTemplateParameters();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateSignature()
|
* @see org.eclipse.cdt.core.model.ITemplate#getTemplateSignature()
|
||||||
*/
|
*/
|
||||||
public String getTemplateSignature() {
|
public String getTemplateSignature() {
|
||||||
StringBuffer sig = new StringBuffer(getElementName());
|
return fTemplate.getTemplateSignature();
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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