mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 14:15:23 +02:00
Patch for Hoda Amer:
- Change the C Model Builder to use the DOM - Minor changes to code model - Fixes for bugs 35781, 26467
This commit is contained in:
parent
7c0622e66b
commit
5b29e684d8
21 changed files with 670 additions and 88 deletions
|
@ -4,15 +4,17 @@ import java.util.Collections;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.internal.core.parser.Token;
|
||||
import org.eclipse.cdt.internal.core.parser.util.AccessSpecifier;
|
||||
import org.eclipse.cdt.internal.core.parser.util.ClassKey;
|
||||
import org.eclipse.cdt.internal.core.parser.util.Name;
|
||||
|
||||
public class ClassSpecifier extends TypeSpecifier implements IScope, IOffsettable {
|
||||
public class ClassSpecifier extends TypeSpecifier implements IScope, IOffsetable {
|
||||
|
||||
private AccessSpecifier access = new AccessSpecifier( AccessSpecifier.v_private );
|
||||
private ClassKey key = new ClassKey();
|
||||
private int startingOffset = 0, totalLength = 0;
|
||||
private int startingOffset = 0, totalLength = 0;
|
||||
private Token classKeyToken = null;
|
||||
|
||||
public int getClassKey() { return key.getClassKey(); }
|
||||
|
||||
|
@ -83,4 +85,20 @@ public class ClassSpecifier extends TypeSpecifier implements IScope, IOffsettabl
|
|||
totalLength = i;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the classKeyToken.
|
||||
* @return Token
|
||||
*/
|
||||
public Token getClassKeyToken() {
|
||||
return classKeyToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the classKeyToken.
|
||||
* @param classKeyToken The classKeyToken to set
|
||||
*/
|
||||
public void setClassKeyToken(Token classKeyToken) {
|
||||
this.classKeyToken = classKeyToken;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -59,6 +59,7 @@ public class DOMBuilder implements IParserCallback
|
|||
ClassSpecifier classSpecifier = new ClassSpecifier(kind, decl);
|
||||
classSpecifier.setCurrentVisibility( visibility );
|
||||
classSpecifier.setStartingOffset( classKey.getOffset() );
|
||||
classSpecifier.setClassKeyToken( classKey );
|
||||
decl.setTypeSpecifier(classSpecifier);
|
||||
return classSpecifier;
|
||||
}
|
||||
|
@ -156,7 +157,7 @@ public class DOMBuilder implements IParserCallback
|
|||
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#inclusionBegin(java.lang.String)
|
||||
*/
|
||||
public void inclusionBegin(String includeFile, int offset, int inclusionBeginOffset) {
|
||||
translationUnit.addInclusion( new Inclusion( includeFile, offset, inclusionBeginOffset, offset + includeFile.length() + 1 ) );
|
||||
translationUnit.addInclusion( new Inclusion( includeFile, offset, inclusionBeginOffset, offset - inclusionBeginOffset + includeFile.length() + 1 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -180,7 +181,7 @@ public class DOMBuilder implements IParserCallback
|
|||
((IScope)container).addDeclaration(decl);
|
||||
if( container instanceof ClassSpecifier )
|
||||
decl.setAccessSpecifier(new AccessSpecifier( ((ClassSpecifier)container).getCurrentVisibility() ));
|
||||
((IOffsettable)decl).setStartingOffset( firstToken.getOffset() );
|
||||
((IOffsetable)decl).setStartingOffset( firstToken.getOffset() );
|
||||
return decl;
|
||||
}
|
||||
|
||||
|
@ -188,7 +189,7 @@ public class DOMBuilder implements IParserCallback
|
|||
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#simpleDeclarationEnd(org.eclipse.cdt.internal.core.newparser.Token)
|
||||
*/
|
||||
public void simpleDeclarationEnd(Object declaration, Token lastToken) {
|
||||
IOffsettable offsetable = (IOffsettable)declaration;
|
||||
IOffsetable offsetable = (IOffsetable)declaration;
|
||||
offsetable.setTotalLength( lastToken.getOffset() + lastToken.getLength() - offsetable.getStartingOffset());
|
||||
}
|
||||
|
||||
|
@ -364,7 +365,10 @@ public class DOMBuilder implements IParserCallback
|
|||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#simpleDeclSpecifierName(java.lang.Object)
|
||||
*/
|
||||
public Object simpleDeclSpecifierName(Object declaration) {
|
||||
return declaration;
|
||||
DeclSpecifier.Container decl = (DeclSpecifier.Container)declaration;
|
||||
DeclSpecifier declSpec = decl.getDeclSpecifier();
|
||||
declSpec.setName( currName );
|
||||
return declSpec;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -520,7 +524,8 @@ public class DOMBuilder implements IParserCallback
|
|||
public Object namespaceDefinitionBegin(Object container, Token namespace) {
|
||||
IScope ownerScope = (IScope)container;
|
||||
NamespaceDefinition namespaceDef = new NamespaceDefinition(ownerScope);
|
||||
((IOffsettable)namespaceDef).setStartingOffset( namespace.getOffset() );
|
||||
namespaceDef.setStartToken(namespace);
|
||||
((IOffsetable)namespaceDef).setStartingOffset( namespace.getOffset() );
|
||||
return namespaceDef;
|
||||
|
||||
}
|
||||
|
@ -637,8 +642,9 @@ public class DOMBuilder implements IParserCallback
|
|||
public Object enumSpecifierBegin(Object container, Token enumKey) {
|
||||
SimpleDeclaration decl = (SimpleDeclaration)container;
|
||||
EnumerationSpecifier es = new EnumerationSpecifier( decl );
|
||||
es.setStartToken(enumKey);
|
||||
decl.setTypeSpecifier(es);
|
||||
((IOffsettable)decl).setStartingOffset( enumKey.getOffset() );
|
||||
((IOffsetable)es).setStartingOffset( enumKey.getOffset() );
|
||||
return es;
|
||||
}
|
||||
|
||||
|
@ -663,7 +669,7 @@ public class DOMBuilder implements IParserCallback
|
|||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierEnd(java.lang.Object)
|
||||
*/
|
||||
public void enumSpecifierEnd(Object enumSpec, Token closingBrace) {
|
||||
IOffsettable offsetable = (IOffsettable)enumSpec;
|
||||
IOffsetable offsetable = (IOffsetable)enumSpec;
|
||||
offsetable.setTotalLength( closingBrace.getOffset() + closingBrace.getLength() - offsetable.getStartingOffset());
|
||||
}
|
||||
|
||||
|
@ -683,7 +689,7 @@ public class DOMBuilder implements IParserCallback
|
|||
public Object enumeratorId(Object enumDefn) {
|
||||
EnumeratorDefinition definition = (EnumeratorDefinition)enumDefn;
|
||||
definition.setName( currName );
|
||||
((IOffsettable)enumDefn).setStartingOffset( currName.getStartOffset() );
|
||||
((IOffsetable)enumDefn).setStartingOffset( currName.getStartOffset() );
|
||||
return definition;
|
||||
}
|
||||
|
||||
|
@ -691,7 +697,7 @@ public class DOMBuilder implements IParserCallback
|
|||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionEnd(java.lang.Object)
|
||||
*/
|
||||
public void enumeratorEnd(Object enumDefn, Token lastToken) {
|
||||
IOffsettable offsetable = (IOffsettable)enumDefn;
|
||||
IOffsetable offsetable = (IOffsetable)enumDefn;
|
||||
offsetable.setTotalLength( lastToken.getOffset() + lastToken.getLength() - offsetable.getStartingOffset());
|
||||
}
|
||||
|
||||
|
|
|
@ -16,13 +16,14 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.internal.core.parser.Token;
|
||||
import org.eclipse.cdt.internal.core.parser.util.Name;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class EnumerationSpecifier extends TypeSpecifier implements IOffsettable {
|
||||
public class EnumerationSpecifier extends TypeSpecifier implements IOffsetable {
|
||||
|
||||
public EnumerationSpecifier(SimpleDeclaration declaration) {
|
||||
super(declaration);
|
||||
|
@ -31,6 +32,7 @@ public class EnumerationSpecifier extends TypeSpecifier implements IOffsettable
|
|||
private Name name = null;
|
||||
private List enumeratorDefinitions = new ArrayList();
|
||||
private int startingOffset = 0, totalLength = 0;
|
||||
private Token startToken = null;
|
||||
|
||||
public void addEnumeratorDefinition( EnumeratorDefinition def )
|
||||
{
|
||||
|
@ -88,4 +90,20 @@ public class EnumerationSpecifier extends TypeSpecifier implements IOffsettable
|
|||
totalLength = i;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the startToken.
|
||||
* @return Token
|
||||
*/
|
||||
public Token getStartToken() {
|
||||
return startToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the startToken.
|
||||
* @param startToken The startToken to set
|
||||
*/
|
||||
public void setStartToken(Token startToken) {
|
||||
this.startToken = startToken;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import org.eclipse.cdt.internal.core.parser.util.Name;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class EnumeratorDefinition implements IExpressionOwner, IOffsettable {
|
||||
public class EnumeratorDefinition implements IExpressionOwner, IOffsetable {
|
||||
|
||||
private Expression initialValue = null;
|
||||
private Name name = null;
|
||||
|
|
|
@ -17,7 +17,7 @@ package org.eclipse.cdt.internal.core.dom;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public interface IOffsettable {
|
||||
public interface IOffsetable {
|
||||
|
||||
/**
|
||||
* @return
|
|
@ -16,18 +16,20 @@ import java.util.Collections;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.internal.core.parser.Token;
|
||||
import org.eclipse.cdt.internal.core.parser.util.Name;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class NamespaceDefinition extends Declaration implements IScope, IOffsettable {
|
||||
public class NamespaceDefinition extends Declaration implements IScope, IOffsetable {
|
||||
|
||||
private List declarations = new LinkedList();
|
||||
private IScope ownerScope;
|
||||
private Name name = null;
|
||||
private int startingOffset = 0, totalLength = 0;
|
||||
private Token startToken = null;
|
||||
|
||||
public NamespaceDefinition( IScope owner )
|
||||
{
|
||||
|
@ -100,4 +102,20 @@ public class NamespaceDefinition extends Declaration implements IScope, IOffsett
|
|||
totalLength = i;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the startToken.
|
||||
* @return Token
|
||||
*/
|
||||
public Token getStartToken() {
|
||||
return startToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the startToken.
|
||||
* @param startToken The startToken to set
|
||||
*/
|
||||
public void setStartToken(Token startToken) {
|
||||
this.startToken = startToken;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,11 +16,11 @@ package org.eclipse.cdt.internal.core.dom;
|
|||
* @author jcamelon
|
||||
*
|
||||
*/
|
||||
public class PreprocessorStatement {
|
||||
public class PreprocessorStatement implements IOffsetable {
|
||||
|
||||
private final int startingOffset, totalLength;
|
||||
final private int nameOffset;
|
||||
final private String name;
|
||||
private int startingOffset, totalLength;
|
||||
private final int nameOffset;
|
||||
private final String name;
|
||||
|
||||
public PreprocessorStatement( String name, int nameOffset, int startingOffset, int totalLength )
|
||||
{
|
||||
|
@ -62,5 +62,17 @@ public class PreprocessorStatement {
|
|||
public int getNameLength() {
|
||||
return name.length();
|
||||
}
|
||||
/**
|
||||
* @see org.eclipse.cdt.internal.core.dom.IOffsettable#setStartingOffset(int)
|
||||
*/
|
||||
public void setStartingOffset(int i) {
|
||||
startingOffset = i;
|
||||
}
|
||||
/**
|
||||
* @see org.eclipse.cdt.internal.core.dom.IOffsettable#setTotalLength(int)
|
||||
*/
|
||||
public void setTotalLength(int i) {
|
||||
totalLength = i;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import java.util.List;
|
|||
import org.eclipse.cdt.internal.core.parser.util.AccessSpecifier;
|
||||
import org.eclipse.cdt.internal.core.parser.util.DeclSpecifier;
|
||||
|
||||
public class SimpleDeclaration extends Declaration implements DeclSpecifier.Container, IOffsettable, TypeSpecifier.IOwner {
|
||||
public class SimpleDeclaration extends Declaration implements DeclSpecifier.Container, IOffsetable, TypeSpecifier.IOwner {
|
||||
|
||||
private int startingOffset = 0, totalLength = 0;
|
||||
private AccessSpecifier accessSpecifier = null;
|
||||
|
|
|
@ -13,9 +13,11 @@ public class TranslationUnit implements IScope {
|
|||
private List declarations = new LinkedList();
|
||||
private List macros = new ArrayList();
|
||||
private List inclusions = new ArrayList();
|
||||
private List offsetables = new ArrayList();
|
||||
|
||||
public void addDeclaration(Declaration declaration) {
|
||||
declarations.add(declaration);
|
||||
offsetables.add(declaration);
|
||||
}
|
||||
|
||||
public List getDeclarations() {
|
||||
|
@ -38,11 +40,21 @@ public class TranslationUnit implements IScope {
|
|||
|
||||
public void addMacro(Macro macro) {
|
||||
macros.add(macro);
|
||||
offsetables.add(macro);
|
||||
}
|
||||
|
||||
public void addInclusion(Inclusion inclusion) {
|
||||
inclusions.add(inclusion);
|
||||
offsetables.add(inclusion);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the offsetables.
|
||||
* @return List
|
||||
*/
|
||||
public List getOffsetables() {
|
||||
return Collections.unmodifiableList( offsetables );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,4 +8,6 @@ package org.eclipse.cdt.core.model;
|
|||
* Represents a package declaration in a C translation unit.
|
||||
*/
|
||||
public interface INamespace extends ICElement, IParent, ISourceManipulation, ISourceReference {
|
||||
|
||||
String getTypeName();
|
||||
}
|
||||
|
|
|
@ -9,4 +9,9 @@ package org.eclipse.cdt.core.model;
|
|||
* Represents a field declared in a type.
|
||||
*/
|
||||
public interface ITypeDef extends ICElement, ISourceManipulation, ISourceReference {
|
||||
/**
|
||||
* Returns the type of the typedef item
|
||||
* @return String
|
||||
*/
|
||||
String getTypeName();
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ package org.eclipse.cdt.internal.core.model;
|
|||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.IField;
|
||||
|
||||
public class Field extends SourceManipulation implements IField {
|
||||
public class Field extends VariableDeclaration implements IField {
|
||||
|
||||
public Field(ICElement parent, String name) {
|
||||
super(parent, name, CElement.C_FIELD);
|
||||
|
@ -66,23 +66,10 @@ public class Field extends SourceManipulation implements IField {
|
|||
getFieldInfo().setVisibility(visibility);
|
||||
}
|
||||
|
||||
|
||||
public FieldInfo getFieldInfo(){
|
||||
return (FieldInfo) getElementInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the member as class scope.
|
||||
* For example static methods in C++ have class scope
|
||||
*
|
||||
* @see IMember
|
||||
* @exception CModelException if this element does not exist or if an
|
||||
* exception occurs while accessing its corresponding resource.
|
||||
*/
|
||||
public boolean hasClassScope(){
|
||||
return false;
|
||||
}
|
||||
|
||||
protected CElementInfo createElementInfo () {
|
||||
return new FieldInfo(this);
|
||||
}
|
||||
|
|
|
@ -65,6 +65,10 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction
|
|||
else{
|
||||
sig += "()";
|
||||
}
|
||||
if(isConst())
|
||||
sig += " const";
|
||||
if(isVolatile())
|
||||
sig += " volatile";
|
||||
return sig;
|
||||
}
|
||||
|
||||
|
@ -105,7 +109,11 @@ public class FunctionDeclaration extends SourceManipulation implements IFunction
|
|||
* @see org.eclipse.cdt.core.model.IDeclaration#isConst()
|
||||
*/
|
||||
public boolean isConst(){
|
||||
return false;
|
||||
return getFunctionInfo().isConst();
|
||||
}
|
||||
|
||||
public void setConst(boolean isConst){
|
||||
getFunctionInfo().setConst(isConst);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,6 +10,7 @@ class FunctionInfo extends SourceManipulationInfo {
|
|||
protected int flags;
|
||||
protected boolean isStatic;
|
||||
protected boolean isVolatile;
|
||||
protected boolean isConst;
|
||||
|
||||
|
||||
protected FunctionInfo (CElement element) {
|
||||
|
@ -67,4 +68,20 @@ class FunctionInfo extends SourceManipulationInfo {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the isConst.
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isConst() {
|
||||
return isConst;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the isConst.
|
||||
* @param isConst The isConst to set
|
||||
*/
|
||||
public void setConst(boolean isConst) {
|
||||
this.isConst = isConst;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,8 +16,25 @@ import org.eclipse.cdt.core.model.INamespace;
|
|||
|
||||
public class Namespace extends SourceManipulation implements INamespace{
|
||||
|
||||
String typeName = "";
|
||||
public Namespace(ICElement parent, String name) {
|
||||
super(parent, name, CElement.C_NAMESPACE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the typeName.
|
||||
* @return String
|
||||
*/
|
||||
public String getTypeName() {
|
||||
return typeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the typeName.
|
||||
* @param typeName The typeName to set
|
||||
*/
|
||||
public void setTypeName(String typeName) {
|
||||
this.typeName = typeName;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ import java.io.StringBufferInputStream;
|
|||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.ISourceRange;
|
||||
import org.eclipse.cdt.internal.core.parser.Parser;
|
||||
import org.eclipse.cdt.internal.parser.CStructurizer;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
|
@ -44,9 +43,9 @@ class TranslationUnitInfo extends OpenableInfo {
|
|||
removeChildren();
|
||||
if (CCorePlugin.getDefault().useNewParser()) {
|
||||
// new parser
|
||||
NewModelBuilder modelBuilder = new NewModelBuilder((TranslationUnit)getElement());
|
||||
Parser parser = new Parser(in, modelBuilder, true);
|
||||
parser.parse();
|
||||
CModelBuilder modelBuilder = new CModelBuilder((TranslationUnit)getElement());
|
||||
modelBuilder.parse();
|
||||
|
||||
} else {
|
||||
// cdt 1.0 parser
|
||||
ModelBuilder modelBuilder= new ModelBuilder((TranslationUnit)getElement());
|
||||
|
|
|
@ -16,8 +16,24 @@ import org.eclipse.cdt.core.model.ITypeDef;
|
|||
|
||||
public class TypeDef extends SourceManipulation implements ITypeDef{
|
||||
|
||||
String typeName= "";
|
||||
public TypeDef(ICElement parent, String name) {
|
||||
super(parent, name, CElement.C_TYPEDEF);
|
||||
}
|
||||
/**
|
||||
* Returns the typeName.
|
||||
* @return String
|
||||
*/
|
||||
public String getTypeName() {
|
||||
return typeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the typeName.
|
||||
* @param typeName The typeName to set
|
||||
*/
|
||||
public void setTypeName(String typeName) {
|
||||
this.typeName = typeName;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,57 +8,14 @@ package org.eclipse.cdt.internal.core.model;
|
|||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.IVariable;
|
||||
|
||||
public class Variable extends SourceManipulation implements IVariable {
|
||||
public class Variable extends VariableDeclaration implements IVariable {
|
||||
|
||||
public Variable(ICElement parent, String name) {
|
||||
super(parent, name, CElement.C_VARIABLE);
|
||||
}
|
||||
|
||||
public String getTypeName() {
|
||||
return getVariableInfo().getTypeName();
|
||||
}
|
||||
|
||||
public void setTypeName(String type){
|
||||
getVariableInfo().setTypeName(type);
|
||||
}
|
||||
|
||||
public boolean isConst() {
|
||||
return getVariableInfo().isConst();
|
||||
}
|
||||
|
||||
public void setConst(boolean isConst) {
|
||||
getVariableInfo().setConst(isConst);
|
||||
}
|
||||
|
||||
public boolean isVolatile() {
|
||||
return getVariableInfo().isVolatile();
|
||||
}
|
||||
|
||||
public void setVolatile(boolean isVolatile) {
|
||||
getVariableInfo().setVolatile(isVolatile);
|
||||
}
|
||||
|
||||
public boolean isStatic() {
|
||||
return getVariableInfo().isStatic();
|
||||
}
|
||||
|
||||
public void setStatic(boolean isStatic) {
|
||||
getVariableInfo().setStatic(isStatic);
|
||||
}
|
||||
|
||||
public String getInitializer() {
|
||||
return "";
|
||||
}
|
||||
|
||||
public int getAccessControl() {
|
||||
return getVariableInfo().getAccessControl();
|
||||
}
|
||||
|
||||
protected VariableInfo getVariableInfo() {
|
||||
return (VariableInfo)getElementInfo();
|
||||
}
|
||||
|
||||
protected CElementInfo createElementInfo () {
|
||||
return new VariableInfo(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,10 @@ public class VariableDeclaration extends SourceManipulation implements IVariable
|
|||
super(parent, name, CElement.C_VARIABLE_DECLARATION);
|
||||
}
|
||||
|
||||
public VariableDeclaration(ICElement parent, String name, int type) {
|
||||
super(parent, name, type);
|
||||
}
|
||||
|
||||
public int getAccessControl() {
|
||||
return getVariableInfo().getAccessControl();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,464 @@
|
|||
package org.eclipse.cdt.internal.core.model;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2001 Rational Software Corp. and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v0.5
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v05.html
|
||||
*
|
||||
* Contributors:
|
||||
* Rational Software - initial implementation
|
||||
******************************************************************************/
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.INamespace;
|
||||
import org.eclipse.cdt.core.model.IParent;
|
||||
import org.eclipse.cdt.core.model.IStructure;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.internal.core.dom.ClassSpecifier;
|
||||
import org.eclipse.cdt.internal.core.dom.DOMBuilder;
|
||||
import org.eclipse.cdt.internal.core.dom.Declaration;
|
||||
import org.eclipse.cdt.internal.core.dom.Declarator;
|
||||
import org.eclipse.cdt.internal.core.dom.ElaboratedTypeSpecifier;
|
||||
import org.eclipse.cdt.internal.core.dom.EnumerationSpecifier;
|
||||
import org.eclipse.cdt.internal.core.dom.EnumeratorDefinition;
|
||||
import org.eclipse.cdt.internal.core.dom.IOffsetable;
|
||||
import org.eclipse.cdt.internal.core.dom.Inclusion;
|
||||
import org.eclipse.cdt.internal.core.dom.Macro;
|
||||
import org.eclipse.cdt.internal.core.dom.NamespaceDefinition;
|
||||
import org.eclipse.cdt.internal.core.dom.ParameterDeclaration;
|
||||
import org.eclipse.cdt.internal.core.dom.ParameterDeclarationClause;
|
||||
import org.eclipse.cdt.internal.core.dom.PointerOperator;
|
||||
import org.eclipse.cdt.internal.core.dom.SimpleDeclaration;
|
||||
import org.eclipse.cdt.internal.core.dom.TranslationUnit;
|
||||
import org.eclipse.cdt.internal.core.dom.TypeSpecifier;
|
||||
import org.eclipse.cdt.internal.core.parser.Parser;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserException;
|
||||
import org.eclipse.cdt.internal.core.parser.util.ClassKey;
|
||||
import org.eclipse.cdt.internal.core.parser.util.DeclSpecifier;
|
||||
|
||||
public class CModelBuilder {
|
||||
|
||||
org.eclipse.cdt.internal.core.model.TranslationUnit translationUnit;
|
||||
public CModelBuilder(org.eclipse.cdt.internal.core.model.TranslationUnit tu) {
|
||||
this.translationUnit = tu ;
|
||||
}
|
||||
|
||||
public TranslationUnit parse() throws Exception {
|
||||
DOMBuilder domBuilder = new DOMBuilder();
|
||||
String code = translationUnit.getBuffer().getContents();
|
||||
Parser parser = new Parser(code, domBuilder, true);
|
||||
if( ! parser.parse() ) throw new ParserException( "Parse failure" );
|
||||
generateModelElements(domBuilder.getTranslationUnit());
|
||||
return domBuilder.getTranslationUnit();
|
||||
}
|
||||
|
||||
protected void generateModelElements(TranslationUnit tu){
|
||||
List offsetables = tu.getOffsetables();
|
||||
Iterator i = offsetables.iterator();
|
||||
while (i.hasNext()){
|
||||
IOffsetable offsetable = (IOffsetable)i.next();
|
||||
if(offsetable instanceof Inclusion){
|
||||
createInclusion(translationUnit, (Inclusion) offsetable);
|
||||
}
|
||||
else if(offsetable instanceof Macro){
|
||||
createMacro(translationUnit, (Macro) offsetable);
|
||||
}else if(offsetable instanceof Declaration){
|
||||
generateModelElements (translationUnit, (Declaration) offsetable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void generateModelElements (Parent parent, Declaration declaration){
|
||||
// Namespace
|
||||
if(declaration instanceof NamespaceDefinition){
|
||||
NamespaceDefinition nsDef = (NamespaceDefinition) declaration;
|
||||
IParent namespace = createNamespace(parent, nsDef);
|
||||
List nsDeclarations = nsDef.getDeclarations();
|
||||
Iterator nsDecls = nsDeclarations.iterator();
|
||||
while (nsDecls.hasNext()){
|
||||
Declaration subNsDeclaration = (Declaration) nsDecls.next();
|
||||
generateModelElements((Parent)namespace, subNsDeclaration);
|
||||
}
|
||||
}
|
||||
|
||||
if(declaration instanceof SimpleDeclaration){
|
||||
SimpleDeclaration simpleDeclaration = (SimpleDeclaration) declaration;
|
||||
|
||||
/*-------------------------------------------
|
||||
* Checking the type if it is a composite one
|
||||
*-------------------------------------------*/
|
||||
TypeSpecifier typeSpec = simpleDeclaration.getTypeSpecifier();
|
||||
// Enumeration
|
||||
if (typeSpec instanceof EnumerationSpecifier){
|
||||
EnumerationSpecifier enumSpecifier = (EnumerationSpecifier) typeSpec;
|
||||
IParent enumElement = createEnumeration (parent, enumSpecifier);
|
||||
}
|
||||
// Structure
|
||||
else if (typeSpec instanceof ClassSpecifier){
|
||||
ClassSpecifier classSpecifier = (ClassSpecifier) typeSpec;
|
||||
IParent classElement = createClass (parent, simpleDeclaration, classSpecifier);
|
||||
// create the sub declarations
|
||||
List declarations = classSpecifier.getDeclarations();
|
||||
Iterator j = declarations.iterator();
|
||||
while (j.hasNext()){
|
||||
Declaration subDeclaration = (Declaration)j.next();
|
||||
generateModelElements((Parent)classElement, subDeclaration);
|
||||
}
|
||||
// TODO: create the declarators too here
|
||||
}
|
||||
|
||||
/*-----------------------------------------
|
||||
* Create declarators of simple declaration
|
||||
* ----------------------------------------*/
|
||||
|
||||
List declarators = simpleDeclaration.getDeclarators();
|
||||
Iterator d = declarators.iterator();
|
||||
while (d.hasNext()){
|
||||
Declarator declarator = (Declarator)d.next();
|
||||
// typedef
|
||||
if(simpleDeclaration.getDeclSpecifier().isTypedef()){
|
||||
createTypeDef(parent, declarator, simpleDeclaration);
|
||||
} else {
|
||||
ParameterDeclarationClause pdc = declarator.getParms();
|
||||
if (pdc == null){
|
||||
createVariableSpecification(parent, simpleDeclaration, declarator);
|
||||
}
|
||||
else{
|
||||
createFunctionSpecification(parent, simpleDeclaration, declarator, pdc);
|
||||
}
|
||||
}
|
||||
} // end while
|
||||
} // end if SimpleDeclaration
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void createInclusion(Parent parent, Inclusion inclusion){
|
||||
// create element
|
||||
Include element = new Include((CElement)parent, inclusion.getName());
|
||||
// add to parent
|
||||
parent.addChild((CElement) element);
|
||||
// set position
|
||||
element.setIdPos(inclusion.getNameOffset(), inclusion.getNameLength());
|
||||
element.setPos(inclusion.getStartingOffset(), inclusion.getTotalLength());
|
||||
}
|
||||
|
||||
private void createMacro(Parent parent, Macro macro){
|
||||
// create element
|
||||
org.eclipse.cdt.internal.core.model.Macro element = new org.eclipse.cdt.internal.core.model.Macro(parent, macro.getName());
|
||||
// add to parent
|
||||
parent.addChild((CElement) element);
|
||||
// set position
|
||||
element.setIdPos(macro.getNameOffset(), macro.getNameLength());
|
||||
element.setPos(macro.getStartingOffset(), macro.getTotalLength());
|
||||
|
||||
}
|
||||
|
||||
private IParent createNamespace(Parent parent, NamespaceDefinition nsDef){
|
||||
// create element
|
||||
String nsName = (nsDef.getName() == null ) ? "" : nsDef.getName().toString();
|
||||
Namespace element = new Namespace ((ICElement)parent, nsName );
|
||||
// add to parent
|
||||
parent.addChild((ICElement)element);
|
||||
// set element position
|
||||
if(nsDef.getName() != null){
|
||||
element.setIdPos(nsDef.getName().getStartOffset(), nsDef.getName().length());
|
||||
}else{
|
||||
element.setIdPos(nsDef.getStartToken().getOffset(), nsDef.getStartToken().getLength());
|
||||
}
|
||||
element.setPos(nsDef.getStartingOffset(), nsDef.getTotalLength());
|
||||
element.setTypeName(nsDef.getStartToken().getImage());
|
||||
|
||||
return (IParent)element;
|
||||
}
|
||||
|
||||
private IParent createEnumeration(Parent parent, EnumerationSpecifier enumSpecifier){
|
||||
// create element
|
||||
String enumName = (enumSpecifier.getName() == null ) ? "" : enumSpecifier.getName().toString();
|
||||
Enumeration enum = new Enumeration ((ICElement)parent, enumName );
|
||||
// add to parent
|
||||
parent.addChild((ICElement)enum);
|
||||
List enumItems = enumSpecifier.getEnumeratorDefinitions();
|
||||
Iterator i = enumItems.iterator();
|
||||
while (i.hasNext()){
|
||||
// create sub element
|
||||
EnumeratorDefinition enumDef = (EnumeratorDefinition) i.next();
|
||||
Enumerator element = new Enumerator (enum, enumDef.getName().toString());
|
||||
// add to parent
|
||||
enum.addChild(element);
|
||||
// set enumerator position
|
||||
element.setIdPos(enumDef.getName().getStartOffset(), enumDef.getName().length());
|
||||
element.setPos(enumDef.getStartingOffset(), enumDef.getTotalLength());
|
||||
}
|
||||
|
||||
// set enumeration position
|
||||
if(enumSpecifier.getName() != null ){
|
||||
enum.setIdPos(enumSpecifier.getName().getStartOffset(), enumSpecifier.getName().length());
|
||||
}else {
|
||||
enum.setIdPos(enumSpecifier.getStartToken().getOffset(), enumSpecifier.getStartToken().getLength());
|
||||
}
|
||||
enum.setPos(enumSpecifier.getStartingOffset(), enumSpecifier.getTotalLength());
|
||||
enum.setTypeName(enumSpecifier.getStartToken().getImage());
|
||||
|
||||
return (IParent)enum;
|
||||
}
|
||||
|
||||
private IParent createClass(Parent parent, SimpleDeclaration simpleDeclaration, ClassSpecifier classSpecifier){
|
||||
// create element
|
||||
String className = (classSpecifier.getName() == null ) ? "" : classSpecifier.getName().toString();
|
||||
int kind;
|
||||
switch( classSpecifier.getClassKey() )
|
||||
{
|
||||
case ClassKey.t_class:
|
||||
kind = ICElement.C_CLASS;
|
||||
break;
|
||||
case ClassKey.t_struct:
|
||||
kind = ICElement.C_STRUCT;
|
||||
break;
|
||||
default:
|
||||
kind = ICElement.C_UNION;
|
||||
break;
|
||||
}
|
||||
|
||||
Structure classElement = new Structure( (CElement)parent, kind, className );
|
||||
|
||||
// add to parent
|
||||
parent.addChild((ICElement) classElement);
|
||||
String type;
|
||||
// set element position
|
||||
if( classSpecifier.getName() != null )
|
||||
{
|
||||
type = simpleDeclaration.getDeclSpecifier().getTypeName();
|
||||
classElement.setIdPos( classSpecifier.getName().getStartOffset(), classSpecifier.getName().length() );
|
||||
}
|
||||
else
|
||||
{
|
||||
type = classSpecifier.getClassKeyToken().getImage();
|
||||
classElement.setIdPos(classSpecifier.getClassKeyToken().getOffset(), classSpecifier.getClassKeyToken().getLength());
|
||||
|
||||
}
|
||||
classElement.setTypeName( type );
|
||||
classElement.setPos(classSpecifier.getStartingOffset(), classSpecifier.getTotalLength());
|
||||
|
||||
return classElement;
|
||||
}
|
||||
|
||||
private void createTypeDef(Parent parent, Declarator declarator, SimpleDeclaration simpleDeclaration){
|
||||
// create the element
|
||||
String declaratorName = declarator.getName().toString();
|
||||
TypeDef typedef = new TypeDef( parent, declaratorName );
|
||||
String type = getType(simpleDeclaration, declarator);
|
||||
typedef.setTypeName(type);
|
||||
|
||||
// add to parent
|
||||
parent.addChild((CElement)typedef);
|
||||
|
||||
// set positions
|
||||
typedef.setIdPos(declarator.getName().getStartOffset(), declarator.getName().length());
|
||||
typedef.setPos(simpleDeclaration.getStartingOffset(), simpleDeclaration.getTotalLength());
|
||||
}
|
||||
|
||||
private void createVariableSpecification(Parent parent, SimpleDeclaration simpleDeclaration, Declarator declarator){
|
||||
|
||||
String declaratorName = declarator.getName().toString();
|
||||
DeclSpecifier declSpecifier = simpleDeclaration.getDeclSpecifier();
|
||||
|
||||
VariableDeclaration element = null;
|
||||
if(parent instanceof IStructure){
|
||||
// field
|
||||
Field newElement = new Field( parent, declaratorName );
|
||||
newElement.setMutable(declSpecifier.isMutable());
|
||||
newElement.setVisibility(simpleDeclaration.getAccessSpecifier().getAccess());
|
||||
element = newElement;
|
||||
}
|
||||
else {
|
||||
if(declSpecifier.isExtern()){
|
||||
// variableDeclaration
|
||||
VariableDeclaration newElement = new VariableDeclaration( parent, declaratorName );
|
||||
element = newElement;
|
||||
}
|
||||
else {
|
||||
// variable
|
||||
Variable newElement = new Variable( parent, declaratorName );
|
||||
element = newElement;
|
||||
}
|
||||
}
|
||||
element.setTypeName ( getType(simpleDeclaration, declarator) );
|
||||
element.setConst(declSpecifier.isConst());
|
||||
element.setVolatile(declSpecifier.isVolatile());
|
||||
element.setStatic(declSpecifier.isStatic());
|
||||
// add to parent
|
||||
parent.addChild( element );
|
||||
|
||||
// set position
|
||||
// hook up the offsets
|
||||
element.setIdPos( declarator.getName().getStartOffset(), declarator.getName().length() );
|
||||
element.setPos(simpleDeclaration.getStartingOffset(), simpleDeclaration.getTotalLength());
|
||||
|
||||
}
|
||||
|
||||
private void createFunctionSpecification(Parent parent, SimpleDeclaration simpleDeclaration, Declarator declarator, ParameterDeclarationClause pdc){
|
||||
String declaratorName = declarator.getName().toString();
|
||||
DeclSpecifier declSpecifier = simpleDeclaration.getDeclSpecifier();
|
||||
// getParameterTypes
|
||||
List parameterList = pdc.getDeclarations();
|
||||
String[] parameterTypes = new String[parameterList.size()];
|
||||
FunctionDeclaration element = null;
|
||||
for( int j = 0; j< parameterList.size(); ++j )
|
||||
{
|
||||
ParameterDeclaration param = (ParameterDeclaration )parameterList.get(j);
|
||||
Declarator paramDeclarator = (Declarator)param.getDeclarators().get(0);
|
||||
parameterTypes[j] = new String(getType(param, paramDeclarator));
|
||||
}
|
||||
|
||||
if( parent instanceof IStructure )
|
||||
{
|
||||
if (simpleDeclaration.isFunctionDefinition())
|
||||
{
|
||||
// method
|
||||
Method newElement = new Method( parent, declaratorName );
|
||||
newElement.setVisibility(simpleDeclaration.getAccessSpecifier().getAccess());
|
||||
element = newElement;
|
||||
}
|
||||
else
|
||||
{
|
||||
// method declaration
|
||||
MethodDeclaration newElement = new MethodDeclaration( parent, declaratorName );
|
||||
newElement.setVisibility(simpleDeclaration.getAccessSpecifier().getAccess());
|
||||
element = newElement;
|
||||
}
|
||||
}
|
||||
else if(( parent instanceof ITranslationUnit )
|
||||
|| ( parent instanceof INamespace ))
|
||||
{
|
||||
if (simpleDeclaration.isFunctionDefinition())
|
||||
{
|
||||
// if it belongs to a class, then create a method
|
||||
// else create a function
|
||||
// this will not be known until we have cross reference information
|
||||
|
||||
// function
|
||||
Function newElement = new Function( parent, declaratorName );
|
||||
element = newElement;
|
||||
}
|
||||
else
|
||||
{
|
||||
// functionDeclaration
|
||||
FunctionDeclaration newElement = new FunctionDeclaration( parent, declaratorName );
|
||||
element = newElement;
|
||||
}
|
||||
}
|
||||
element.setParameterTypes(parameterTypes);
|
||||
element.setReturnType( getType(simpleDeclaration, declarator) );
|
||||
element.setVolatile(declSpecifier.isVolatile());
|
||||
element.setStatic(declSpecifier.isStatic());
|
||||
element.setConst(declarator.isConst());
|
||||
|
||||
// add to parent
|
||||
parent.addChild( element );
|
||||
|
||||
// hook up the offsets
|
||||
element.setIdPos( declarator.getName().getStartOffset(), declarator.getName().length() );
|
||||
element.setPos(simpleDeclaration.getStartingOffset(), simpleDeclaration.getTotalLength());
|
||||
|
||||
}
|
||||
|
||||
private String getType(Declaration declaration, Declarator declarator){
|
||||
String type = "";
|
||||
// get type from declaration
|
||||
type = getDeclarationType(declaration);
|
||||
// add pointerr or reference from declarator if any
|
||||
type += getDeclaratorPointerOperation(declarator);
|
||||
return type;
|
||||
}
|
||||
|
||||
private String getDeclarationType(Declaration declaration){
|
||||
String type = "";
|
||||
if(declaration instanceof ParameterDeclaration){
|
||||
ParameterDeclaration paramDeclaration = (ParameterDeclaration) declaration;
|
||||
if(paramDeclaration.getDeclSpecifier().isConst())
|
||||
type += "const ";
|
||||
if(paramDeclaration.getDeclSpecifier().isVolatile())
|
||||
type += "volatile ";
|
||||
TypeSpecifier typeSpecifier = paramDeclaration.getTypeSpecifier();
|
||||
if(typeSpecifier == null){
|
||||
type += paramDeclaration.getDeclSpecifier().getTypeName();
|
||||
}
|
||||
else if(typeSpecifier instanceof ElaboratedTypeSpecifier){
|
||||
ElaboratedTypeSpecifier elab = (ElaboratedTypeSpecifier) typeSpecifier;
|
||||
type += getElaboratedTypeSignature(elab);
|
||||
}
|
||||
}
|
||||
|
||||
if(declaration instanceof SimpleDeclaration){
|
||||
SimpleDeclaration simpleDeclaration = (SimpleDeclaration) declaration;
|
||||
if(simpleDeclaration.getDeclSpecifier().isConst())
|
||||
type += "const ";
|
||||
if(simpleDeclaration.getDeclSpecifier().isVolatile())
|
||||
type += "volatile ";
|
||||
TypeSpecifier typeSpecifier = simpleDeclaration.getTypeSpecifier();
|
||||
if(typeSpecifier == null){
|
||||
type += simpleDeclaration.getDeclSpecifier().getTypeName();
|
||||
}
|
||||
else if(typeSpecifier instanceof ElaboratedTypeSpecifier){
|
||||
ElaboratedTypeSpecifier elab = (ElaboratedTypeSpecifier) typeSpecifier;
|
||||
type += getElaboratedTypeSignature(elab);
|
||||
}
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
private String getElaboratedTypeSignature(ElaboratedTypeSpecifier elab){
|
||||
String type = "";
|
||||
int t = elab.getClassKey();
|
||||
switch (t){
|
||||
case ClassKey.t_class:
|
||||
type = "class";
|
||||
break;
|
||||
case ClassKey.t_struct:
|
||||
type = "struct";
|
||||
break;
|
||||
case ClassKey.t_union:
|
||||
type = "union";
|
||||
break;
|
||||
case ClassKey.t_enum:
|
||||
type = "enum";
|
||||
break;
|
||||
};
|
||||
type += " ";
|
||||
type += elab.getName().toString();
|
||||
return type;
|
||||
}
|
||||
|
||||
private String getDeclaratorPointerOperation(Declarator declarator){
|
||||
String pointerString = "";
|
||||
List pointerOperators = declarator.getPointerOperators();
|
||||
if(pointerOperators != null) {
|
||||
Iterator i = pointerOperators.iterator();
|
||||
while(i.hasNext()){
|
||||
PointerOperator po = (PointerOperator) i.next();
|
||||
switch (po.getType()){
|
||||
case PointerOperator.t_pointer:
|
||||
pointerString += "*";
|
||||
break;
|
||||
case PointerOperator.t_reference:
|
||||
pointerString += "&";
|
||||
break;
|
||||
}
|
||||
|
||||
if(po.isConst())
|
||||
pointerString += " const";
|
||||
if(po.isVolatile())
|
||||
pointerString += " volatile";
|
||||
}
|
||||
}
|
||||
return pointerString;
|
||||
}
|
||||
}
|
|
@ -8,6 +8,8 @@ package org.eclipse.cdt.ui;
|
|||
import org.eclipse.cdt.core.model.IBinary;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.IFunctionDeclaration;
|
||||
import org.eclipse.cdt.core.model.INamespace;
|
||||
import org.eclipse.cdt.core.model.ITypeDef;
|
||||
import org.eclipse.cdt.core.model.IVariableDeclaration;
|
||||
import org.eclipse.cdt.internal.ui.CElementImageProvider;
|
||||
import org.eclipse.cdt.internal.ui.ErrorTickAdornmentProvider;
|
||||
|
@ -65,17 +67,21 @@ public class CElementLabelProvider extends LabelProvider {
|
|||
case ICElement.C_VARIABLE_DECLARATION:
|
||||
IVariableDeclaration vDecl = (IVariableDeclaration) celem;
|
||||
name = vDecl.getElementName();
|
||||
name += " : ";
|
||||
name += vDecl.getTypeName();
|
||||
if((vDecl.getTypeName() != null) &&(vDecl.getTypeName().length() > 0)){
|
||||
name += " : ";
|
||||
name += vDecl.getTypeName();
|
||||
}
|
||||
break;
|
||||
case ICElement.C_FUNCTION:
|
||||
case ICElement.C_FUNCTION_DECLARATION:
|
||||
case ICElement.C_METHOD:
|
||||
case ICElement.C_METHOD_DECLARATION:
|
||||
IFunctionDeclaration fDecl = (IFunctionDeclaration) celem;
|
||||
name = fDecl.getSignature();
|
||||
name += " : ";
|
||||
name += fDecl.getReturnType();
|
||||
name = fDecl.getSignature();
|
||||
if((fDecl.getReturnType() != null) &&(fDecl.getReturnType().length() > 0)){
|
||||
name += " : ";
|
||||
name += fDecl.getReturnType();
|
||||
}
|
||||
break;
|
||||
case ICElement.C_STRUCT:
|
||||
case ICElement.C_UNION:
|
||||
|
@ -87,6 +93,22 @@ public class CElementLabelProvider extends LabelProvider {
|
|||
name = varDecl.getTypeName();
|
||||
}
|
||||
break;
|
||||
case ICElement.C_TYPEDEF:
|
||||
ITypeDef tDecl = (ITypeDef) celem;
|
||||
name = tDecl.getElementName();
|
||||
if((tDecl.getTypeName() != null) &&(tDecl.getTypeName().length() > 0)){
|
||||
name += " : ";
|
||||
name += tDecl.getTypeName();
|
||||
}
|
||||
break;
|
||||
case ICElement.C_NAMESPACE:
|
||||
if((celem.getElementName() != null) && (celem.getElementName().length() > 0)){
|
||||
name = celem.getElementName();
|
||||
} else if (celem instanceof INamespace) {
|
||||
INamespace nDecl = (INamespace) celem;
|
||||
name = nDecl.getTypeName();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
name= celem.getElementName();
|
||||
break;
|
||||
|
|
Loading…
Add table
Reference in a new issue