mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-12 10:45:37 +02:00
Patch for John Camelon:
Core fix for Outline View - Fixed bug35939. Proper CElement position is set on Simple Declarations, Class Specifications, Namespaces, Enumerations and Enumerators, Macros and Inclusions. - Callbacks updated to provide additional offset information.
This commit is contained in:
parent
7081cddca6
commit
0ff98a152c
14 changed files with 191 additions and 111 deletions
|
@ -72,7 +72,7 @@ public class DOMBuilder implements IParserCallback
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#classEnd()
|
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#classEnd()
|
||||||
*/
|
*/
|
||||||
public void classSpecifierEnd(Object classSpecifier) {
|
public void classSpecifierEnd(Object classSpecifier, Token closingBrace) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -141,13 +141,13 @@ public class DOMBuilder implements IParserCallback
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#functionBodyEnd()
|
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#functionBodyEnd()
|
||||||
*/
|
*/
|
||||||
public void functionBodyEnd(Object functionBody) {
|
public void functionBodyEnd(Object functionBody ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#inclusionBegin(java.lang.String)
|
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#inclusionBegin(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void inclusionBegin(String includeFile, int offset) {
|
public void inclusionBegin(String includeFile, int offset, int inclusionBeginOffset) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -159,13 +159,13 @@ public class DOMBuilder implements IParserCallback
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#macro(java.lang.String)
|
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#macro(java.lang.String)
|
||||||
*/
|
*/
|
||||||
public void macro(String macroName, int offset) {
|
public void macro(String macroName, int offset, int macroBeginOffset, int macroEndOffset) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#simpleDeclarationBegin(org.eclipse.cdt.internal.core.newparser.Token)
|
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#simpleDeclarationBegin(org.eclipse.cdt.internal.core.newparser.Token)
|
||||||
*/
|
*/
|
||||||
public Object simpleDeclarationBegin(Object container) {
|
public Object simpleDeclarationBegin(Object container, Token firstToken) {
|
||||||
SimpleDeclaration decl = new SimpleDeclaration();
|
SimpleDeclaration decl = new SimpleDeclaration();
|
||||||
((IScope)container).addDeclaration(decl);
|
((IScope)container).addDeclaration(decl);
|
||||||
return decl;
|
return decl;
|
||||||
|
@ -174,7 +174,7 @@ public class DOMBuilder implements IParserCallback
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#simpleDeclarationEnd(org.eclipse.cdt.internal.core.newparser.Token)
|
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#simpleDeclarationEnd(org.eclipse.cdt.internal.core.newparser.Token)
|
||||||
*/
|
*/
|
||||||
public void simpleDeclarationEnd(Object declaration) {
|
public void simpleDeclarationEnd(Object declaration, Token lastToken) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -488,10 +488,10 @@ public class DOMBuilder implements IParserCallback
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationBegin(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationBegin(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public Object namespaceDefinitionBegin(Object container) {
|
public Object namespaceDefinitionBegin(Object container, Token namespace) {
|
||||||
IScope ownerScope = (IScope)container;
|
IScope ownerScope = (IScope)container;
|
||||||
NamespaceDefinition namespace = new NamespaceDefinition(ownerScope);
|
NamespaceDefinition namespaceDef = new NamespaceDefinition(ownerScope);
|
||||||
return namespace;
|
return namespaceDef;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -512,7 +512,7 @@ public class DOMBuilder implements IParserCallback
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationEnd(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationEnd(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void namespaceDefinitionEnd(Object namespace) {
|
public void namespaceDefinitionEnd(Object namespace, Token closingBrace) {
|
||||||
NamespaceDefinition ns = (NamespaceDefinition)namespace;
|
NamespaceDefinition ns = (NamespaceDefinition)namespace;
|
||||||
ns.getOwnerScope().addDeclaration(ns);
|
ns.getOwnerScope().addDeclaration(ns);
|
||||||
}
|
}
|
||||||
|
@ -626,13 +626,13 @@ public class DOMBuilder implements IParserCallback
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierEnd(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierEnd(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void enumSpecifierEnd(Object enumSpec) {
|
public void enumSpecifierEnd(Object enumSpec, Token closingBrace) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionBegin(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionBegin(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public Object enumDefinitionBegin(Object enumSpec) {
|
public Object enumeratorBegin(Object enumSpec) {
|
||||||
EnumerationSpecifier es = (EnumerationSpecifier)enumSpec;
|
EnumerationSpecifier es = (EnumerationSpecifier)enumSpec;
|
||||||
EnumeratorDefinition definition = new EnumeratorDefinition();
|
EnumeratorDefinition definition = new EnumeratorDefinition();
|
||||||
es.addEnumeratorDefinition(definition);
|
es.addEnumeratorDefinition(definition);
|
||||||
|
@ -642,7 +642,7 @@ public class DOMBuilder implements IParserCallback
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionId(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionId(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void enumDefinitionId(Object enumDefn) {
|
public void enumeratorId(Object enumDefn) {
|
||||||
EnumeratorDefinition definition = (EnumeratorDefinition)enumDefn;
|
EnumeratorDefinition definition = (EnumeratorDefinition)enumDefn;
|
||||||
definition.setName( currName );
|
definition.setName( currName );
|
||||||
}
|
}
|
||||||
|
@ -650,7 +650,7 @@ public class DOMBuilder implements IParserCallback
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionEnd(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionEnd(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void enumDefinitionEnd(Object enumDefn) {
|
public void enumeratorEnd(Object enumDefn, Token lastToken) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
2003-04-04 John Camelon
|
||||||
|
Fixed defect 35939. Proper CElement::pos() is set on Simple Declarations,
|
||||||
|
Class Specifications, Namespaces, Enumerations and Enumerators, Macros and Inclusions.
|
||||||
|
|
||||||
2003-04-03 John Camelon
|
2003-04-03 John Camelon
|
||||||
Fixed defects 36019, 36020, 36045.
|
Fixed defects 36019, 36020, 36045.
|
||||||
Finished template declarations and their callbacks for the DOM (not the Code Model).
|
Finished template declarations and their callbacks for the DOM (not the Code Model).
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.model;
|
package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.internal.core.parser.Token;
|
||||||
import org.eclipse.cdt.internal.core.parser.util.Name;
|
import org.eclipse.cdt.internal.core.parser.util.Name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,6 +23,7 @@ public class EnumeratorWrapper {
|
||||||
|
|
||||||
private final EnumerationWrapper parent;
|
private final EnumerationWrapper parent;
|
||||||
private Name name;
|
private Name name;
|
||||||
|
private Token lastToken = null;
|
||||||
|
|
||||||
EnumeratorWrapper( EnumerationWrapper myParent )
|
EnumeratorWrapper( EnumerationWrapper myParent )
|
||||||
{
|
{
|
||||||
|
@ -50,4 +52,18 @@ public class EnumeratorWrapper {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Token getLastToken() {
|
||||||
|
return lastToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param token
|
||||||
|
*/
|
||||||
|
public void setLastToken(Token token) {
|
||||||
|
lastToken = token;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
package org.eclipse.cdt.internal.core.model;
|
package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.IParent;
|
|
||||||
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.internal.core.parser.Token;
|
||||||
import org.eclipse.cdt.internal.core.parser.util.Name;
|
import org.eclipse.cdt.internal.core.parser.util.Name;
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
|
@ -19,11 +20,13 @@ import org.eclipse.cdt.internal.core.parser.util.Name;
|
||||||
public class NamespaceWrapper implements ICElementWrapper{
|
public class NamespaceWrapper implements ICElementWrapper{
|
||||||
private Name name;
|
private Name name;
|
||||||
private final IParent parent;
|
private final IParent parent;
|
||||||
private ICElement element;
|
private ICElement element;
|
||||||
|
private Token firstToken;
|
||||||
|
|
||||||
public NamespaceWrapper( IParent incoming)
|
public NamespaceWrapper( IParent incoming, Token namespace)
|
||||||
{
|
{
|
||||||
this.parent= incoming;
|
this.parent= incoming;
|
||||||
|
firstToken = namespace;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -64,4 +67,12 @@ public class NamespaceWrapper implements ICElementWrapper{
|
||||||
element = item;
|
element = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Token getFirstToken() {
|
||||||
|
return firstToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,11 @@ public class NewModelBuilder implements IParserCallback {
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.core.newparser.IParserCallback#endClass()
|
* @see org.eclipse.cdt.core.newparser.IParserCallback#endClass()
|
||||||
*/
|
*/
|
||||||
public void classSpecifierEnd(Object classSpecifier) {
|
public void classSpecifierEnd(Object classSpecifier, Token closingBrace) {
|
||||||
|
SimpleDeclarationWrapper wrapper = (SimpleDeclarationWrapper)classSpecifier;
|
||||||
|
Structure s = (Structure)wrapper.getElement();
|
||||||
|
s.setPos( wrapper.getClassKind().getOffset(),
|
||||||
|
wrapper.getClassKind().getDelta( closingBrace ));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -121,10 +125,10 @@ public class NewModelBuilder implements IParserCallback {
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.core.newparser.IParserCallback#macro(String)
|
* @see org.eclipse.cdt.core.newparser.IParserCallback#macro(String)
|
||||||
*/
|
*/
|
||||||
public void macro(String macroName, int offset) {
|
public void macro(String macroName, int offset, int macroBeginOffset, int macroEndOffset) {
|
||||||
Macro elem = new Macro((TranslationUnit)translationUnit.getElement(), macroName);
|
Macro elem = new Macro((TranslationUnit)translationUnit.getElement(), macroName);
|
||||||
elem.setIdPos(offset, macroName.length());
|
elem.setIdPos(offset, macroName.length());
|
||||||
elem.setPos(offset, macroName.length());
|
elem.setPos(macroBeginOffset, macroEndOffset - macroBeginOffset);
|
||||||
|
|
||||||
((TranslationUnit)translationUnit.getElement()).addChild(elem);
|
((TranslationUnit)translationUnit.getElement()).addChild(elem);
|
||||||
}
|
}
|
||||||
|
@ -135,12 +139,13 @@ public class NewModelBuilder implements IParserCallback {
|
||||||
* @see
|
* @see
|
||||||
org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(Token)
|
org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(Token)
|
||||||
*/
|
*/
|
||||||
public Object simpleDeclarationBegin(Object container) {
|
public Object simpleDeclarationBegin(Object container, Token firstToken) {
|
||||||
ICElementWrapper wrapper = (ICElementWrapper)container;
|
ICElementWrapper wrapper = (ICElementWrapper)container;
|
||||||
// Assuming that the parent is the container's element
|
// Assuming that the parent is the container's element
|
||||||
IParent parent = (IParent)wrapper.getElement();
|
IParent parent = (IParent)wrapper.getElement();
|
||||||
SimpleDeclarationWrapper result = new SimpleDeclarationWrapper();
|
SimpleDeclarationWrapper result = new SimpleDeclarationWrapper();
|
||||||
result.setParent( parent );
|
result.setParent( parent );
|
||||||
|
result.setFirst( firstToken );
|
||||||
// A special case to transfere the visibility
|
// A special case to transfere the visibility
|
||||||
if( wrapper instanceof SimpleDeclarationWrapper ){
|
if( wrapper instanceof SimpleDeclarationWrapper ){
|
||||||
result.setCurrentVisibility(((SimpleDeclarationWrapper)wrapper).getCurrentVisibility());
|
result.setCurrentVisibility(((SimpleDeclarationWrapper)wrapper).getCurrentVisibility());
|
||||||
|
@ -151,13 +156,13 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#beginInclusion(String)
|
* @see org.eclipse.cdt.internal.core.newmparser.IParserCallback#beginInclusion(String)
|
||||||
*/
|
*/
|
||||||
public void inclusionBegin(String includeFile, int offset) {
|
public void inclusionBegin(String includeFile, int offset, int inclusionBeginOffset) {
|
||||||
Include elem = new Include(((TranslationUnit)translationUnit.getElement()), includeFile);
|
Include elem = new Include(((TranslationUnit)translationUnit.getElement()), includeFile);
|
||||||
((TranslationUnit)translationUnit.getElement()).addChild(elem);
|
((TranslationUnit)translationUnit.getElement()).addChild(elem);
|
||||||
elem.setIdPos(offset, includeFile.length());
|
elem.setIdPos(offset, includeFile.length());
|
||||||
elem.setPos(offset, includeFile.length());
|
elem.setPos(inclusionBeginOffset, offset + includeFile.length() + 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -186,8 +191,9 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#simpleDeclarationEnd(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#simpleDeclarationEnd(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void simpleDeclarationEnd(Object declaration) {
|
public void simpleDeclarationEnd(Object declaration, Token lastToken) {
|
||||||
SimpleDeclarationWrapper wrapper = (SimpleDeclarationWrapper)declaration;
|
SimpleDeclarationWrapper wrapper = (SimpleDeclarationWrapper)declaration;
|
||||||
|
wrapper.setLast( lastToken );
|
||||||
wrapper.createElements();
|
wrapper.createElements();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,7 +273,7 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#functionBodyEnd()
|
* @see org.eclipse.cdt.internal.core.newparser.IParserCallback#functionBodyEnd()
|
||||||
*/
|
*/
|
||||||
public void functionBodyEnd(Object functionBody) {
|
public void functionBodyEnd(Object functionBody ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -358,13 +364,11 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
|
||||||
{
|
{
|
||||||
elem.setTypeName( wrapper.getClassKind().getImage() );
|
elem.setTypeName( wrapper.getClassKind().getImage() );
|
||||||
elem.setIdPos(wrapper.getName().getStartOffset(), elementName.length());
|
elem.setIdPos(wrapper.getName().getStartOffset(), elementName.length());
|
||||||
elem.setPos(wrapper.getName().getStartOffset(), elementName.length());
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
elem.setTypeName( wrapper.getClassKind().getImage() );
|
elem.setTypeName( wrapper.getClassKind().getImage() );
|
||||||
elem.setIdPos(wrapper.getClassKind().getOffset(), wrapper.getClassKind().getLength());
|
elem.setIdPos(wrapper.getClassKind().getOffset(), wrapper.getClassKind().getLength());
|
||||||
elem.setPos(wrapper.getClassKind().getOffset(), wrapper.getClassKind().getLength());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -551,10 +555,10 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationBegin(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationBegin(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public Object namespaceDefinitionBegin(Object container) {
|
public Object namespaceDefinitionBegin(Object container, Token namespace) {
|
||||||
|
|
||||||
ICElementWrapper c = (ICElementWrapper)container;
|
ICElementWrapper c = (ICElementWrapper)container;
|
||||||
NamespaceWrapper wrapper = new NamespaceWrapper((IParent)c.getElement());
|
NamespaceWrapper wrapper = new NamespaceWrapper((IParent)c.getElement(), namespace);
|
||||||
return wrapper;
|
return wrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -574,8 +578,7 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
|
||||||
realParent.addChild( newNameSpace );
|
realParent.addChild( newNameSpace );
|
||||||
|
|
||||||
// set the positions
|
// set the positions
|
||||||
newNameSpace.setIdPos(wrapper.getName().getStartOffset(), namespaceName.length());
|
newNameSpace.setIdPos(wrapper.getName().getStartOffset(), namespaceName.length());
|
||||||
newNameSpace.setPos(wrapper.getName().getStartOffset(), namespaceName.length());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -588,7 +591,10 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationEnd(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationEnd(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void namespaceDefinitionEnd(Object namespace) {
|
public void namespaceDefinitionEnd(Object namespace, Token closingBrace) {
|
||||||
|
NamespaceWrapper wrapper = (NamespaceWrapper)namespace;
|
||||||
|
Namespace celement = (Namespace)wrapper.getElement();
|
||||||
|
celement.setPos( wrapper.getFirstToken().getOffset(), wrapper.getFirstToken().getDelta(closingBrace));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -696,7 +702,7 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierEnd(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierEnd(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void enumSpecifierEnd(Object enumSpec) {
|
public void enumSpecifierEnd(Object enumSpec, Token closingBrace) {
|
||||||
EnumerationWrapper wrapper = (EnumerationWrapper)enumSpec;
|
EnumerationWrapper wrapper = (EnumerationWrapper)enumSpec;
|
||||||
|
|
||||||
List enumerators = wrapper.getEnumerators();
|
List enumerators = wrapper.getEnumerators();
|
||||||
|
@ -716,7 +722,8 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
|
||||||
String enumeratorName = subwrapper.getName().toString();
|
String enumeratorName = subwrapper.getName().toString();
|
||||||
|
|
||||||
enumerator.setIdPos(subwrapper.getName().getStartOffset(), enumeratorName.length());
|
enumerator.setIdPos(subwrapper.getName().getStartOffset(), enumeratorName.length());
|
||||||
enumerator.setPos(subwrapper.getName().getStartOffset(), enumeratorName.length());
|
enumerator.setPos(subwrapper.getName().getStartOffset(),
|
||||||
|
subwrapper.getName().getNameStart().getDelta( subwrapper.getLastToken()));
|
||||||
|
|
||||||
enumeration.addChild( enumerator );
|
enumeration.addChild( enumerator );
|
||||||
}
|
}
|
||||||
|
@ -725,19 +732,19 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
|
||||||
if( wrapper.getName() != null )
|
if( wrapper.getName() != null )
|
||||||
{
|
{
|
||||||
enumeration.setIdPos(wrapper.getName().getStartOffset(), enumName.length());
|
enumeration.setIdPos(wrapper.getName().getStartOffset(), enumName.length());
|
||||||
enumeration.setPos(wrapper.getName().getStartOffset(), enumName.length());
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
enumeration.setIdPos(wrapper.getClassKind().getOffset(), wrapper.getClassKind().getLength());
|
enumeration.setIdPos(wrapper.getClassKind().getOffset(), wrapper.getClassKind().getLength());
|
||||||
enumeration.setPos(wrapper.getClassKind().getOffset(), wrapper.getClassKind().getLength());
|
|
||||||
}
|
}
|
||||||
|
enumeration.setPos(wrapper.getClassKind().getOffset(), wrapper.getClassKind().getDelta( closingBrace ));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionBegin(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionBegin(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public Object enumDefinitionBegin(Object enumSpec) {
|
public Object enumeratorBegin(Object enumSpec) {
|
||||||
EnumerationWrapper wrapper = (EnumerationWrapper)enumSpec;
|
EnumerationWrapper wrapper = (EnumerationWrapper)enumSpec;
|
||||||
EnumeratorWrapper result = new EnumeratorWrapper(wrapper);
|
EnumeratorWrapper result = new EnumeratorWrapper(wrapper);
|
||||||
return result;
|
return result;
|
||||||
|
@ -746,7 +753,7 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionId(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionId(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void enumDefinitionId(Object enumDefn) {
|
public void enumeratorId(Object enumDefn) {
|
||||||
EnumeratorWrapper wrapper = (EnumeratorWrapper)enumDefn;
|
EnumeratorWrapper wrapper = (EnumeratorWrapper)enumDefn;
|
||||||
wrapper.setName( currName );
|
wrapper.setName( currName );
|
||||||
}
|
}
|
||||||
|
@ -754,8 +761,9 @@ org.eclipse.cdt.internal.core.newparser.IParserCallback#beginSimpleDeclaration(T
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionEnd(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionEnd(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void enumDefinitionEnd(Object enumDefn) {
|
public void enumeratorEnd(Object enumDefn, Token lastToken) {
|
||||||
EnumeratorWrapper wrapper = (EnumeratorWrapper)enumDefn;
|
EnumeratorWrapper wrapper = (EnumeratorWrapper)enumDefn;
|
||||||
|
wrapper.setLastToken( lastToken );
|
||||||
wrapper.getParent().addEnumerator( wrapper );
|
wrapper.getParent().addEnumerator( wrapper );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,9 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.INamespace;
|
import org.eclipse.cdt.core.model.INamespace;
|
||||||
import org.eclipse.cdt.core.model.IParent;
|
import org.eclipse.cdt.core.model.IParent;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
|
||||||
import org.eclipse.cdt.core.model.IStructure;
|
import org.eclipse.cdt.core.model.IStructure;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.internal.core.parser.Token;
|
import org.eclipse.cdt.internal.core.parser.Token;
|
||||||
|
@ -22,6 +22,7 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
|
||||||
private ICElement element = null;
|
private ICElement element = null;
|
||||||
private IParent parent = null;
|
private IParent parent = null;
|
||||||
|
|
||||||
|
Token first = null, last = null;
|
||||||
private Name name = null;
|
private Name name = null;
|
||||||
private boolean functionDefinition = false;
|
private boolean functionDefinition = false;
|
||||||
|
|
||||||
|
@ -147,13 +148,13 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
|
||||||
{
|
{
|
||||||
// hook up the offsets
|
// hook up the offsets
|
||||||
declaration.setIdPos( currentDeclarator.getName().getStartOffset(), currentDeclarator.getName().length() );
|
declaration.setIdPos( currentDeclarator.getName().getStartOffset(), currentDeclarator.getName().length() );
|
||||||
declaration.setPos( currentDeclarator.getName().getStartOffset(), currentDeclarator.getName().length());
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
declaration.setIdPos( classKind.getOffset(), classKind.getImage().toString().length());
|
declaration.setIdPos( classKind.getOffset(), classKind.getImage().toString().length());
|
||||||
declaration.setPos( classKind.getOffset(), classKind.getImage().toString().length());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declaration.setPos( getFirst().getOffset(), getFirst().getDelta( getLast() ));
|
||||||
|
|
||||||
// add to parent
|
// add to parent
|
||||||
parentElement.addChild( declaration );
|
parentElement.addChild( declaration );
|
||||||
|
@ -415,4 +416,32 @@ public class SimpleDeclarationWrapper extends DeclSpecifier implements DeclSpeci
|
||||||
this.classKind = classKind;
|
this.classKind = classKind;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Token getFirst() {
|
||||||
|
return first;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Token getLast() {
|
||||||
|
return last;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param token
|
||||||
|
*/
|
||||||
|
public void setFirst(Token token) {
|
||||||
|
first = token;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param token
|
||||||
|
*/
|
||||||
|
public void setLast(Token token) {
|
||||||
|
last = token;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,9 +12,9 @@
|
||||||
package org.eclipse.cdt.internal.core.parser;
|
package org.eclipse.cdt.internal.core.parser;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.parser.util.TypeInfo;
|
import org.eclipse.cdt.internal.core.parser.util.TypeInfo;
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,7 @@ public class ExpressionEvaluator implements IParserCallback {
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#inclusionBegin(java.lang.String, int)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#inclusionBegin(java.lang.String, int)
|
||||||
*/
|
*/
|
||||||
public void inclusionBegin(String includeFile, int offset) {
|
public void inclusionBegin(String includeFile, int offset, int inclusionBeginOffset) {
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#inclusionEnd()
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#inclusionEnd()
|
||||||
|
@ -132,18 +132,18 @@ public class ExpressionEvaluator implements IParserCallback {
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#macro(java.lang.String, int)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#macro(java.lang.String, int)
|
||||||
*/
|
*/
|
||||||
public void macro(String macroName, int offset) {
|
public void macro(String macroName, int offset, int macroBeginOffset, int macroEndOffset) {
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#simpleDeclarationBegin(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#simpleDeclarationBegin(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public Object simpleDeclarationBegin(Object Container) {
|
public Object simpleDeclarationBegin(Object Container, Token firstToken) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#simpleDeclarationEnd(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#simpleDeclarationEnd(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void simpleDeclarationEnd(Object declaration) {
|
public void simpleDeclarationEnd(Object declaration, Token lastToken) {
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#parameterDeclarationBegin(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#parameterDeclarationBegin(java.lang.Object)
|
||||||
|
@ -212,7 +212,7 @@ public class ExpressionEvaluator implements IParserCallback {
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#functionBodyEnd()
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#functionBodyEnd()
|
||||||
*/
|
*/
|
||||||
public void functionBodyEnd(Object functionBody) {
|
public void functionBodyEnd(Object functionBody ) {
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#classSpecifierBegin(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#classSpecifierBegin(java.lang.Object, org.eclipse.cdt.internal.core.parser.Token)
|
||||||
|
@ -228,7 +228,7 @@ public class ExpressionEvaluator implements IParserCallback {
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#classSpecifierEnd(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#classSpecifierEnd(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void classSpecifierEnd(Object classSpecifier) {
|
public void classSpecifierEnd(Object classSpecifier, Token closingBrace) {
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#baseSpecifierBegin(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#baseSpecifierBegin(java.lang.Object)
|
||||||
|
@ -405,7 +405,7 @@ public class ExpressionEvaluator implements IParserCallback {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationBegin(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationBegin(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public Object namespaceDefinitionBegin(Object container) {
|
public Object namespaceDefinitionBegin(Object container, Token namespace) {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -429,7 +429,7 @@ public class ExpressionEvaluator implements IParserCallback {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationEnd(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationEnd(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void namespaceDefinitionEnd(Object namespace) {
|
public void namespaceDefinitionEnd(Object namespace, Token closingBrace) {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -536,7 +536,7 @@ public class ExpressionEvaluator implements IParserCallback {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierEnd(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierEnd(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void enumSpecifierEnd(Object enumSpec) {
|
public void enumSpecifierEnd(Object enumSpec, Token closingBrace) {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -544,7 +544,7 @@ public class ExpressionEvaluator implements IParserCallback {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionBegin(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionBegin(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public Object enumDefinitionBegin(Object enumSpec) {
|
public Object enumeratorBegin(Object enumSpec) {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -552,7 +552,7 @@ public class ExpressionEvaluator implements IParserCallback {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionId(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionId(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void enumDefinitionId(Object enumDefn) {
|
public void enumeratorId(Object enumDefn) {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -560,7 +560,7 @@ public class ExpressionEvaluator implements IParserCallback {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionEnd(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionEnd(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void enumDefinitionEnd(Object enumDefn) {
|
public void enumeratorEnd(Object enumDefn, Token lastToken) {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -722,5 +722,4 @@ public class ExpressionEvaluator implements IParserCallback {
|
||||||
*/
|
*/
|
||||||
public void templateParameterListEnd(Object parameterList) {
|
public void templateParameterListEnd(Object parameterList) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,14 +15,14 @@ public interface IParserCallback {
|
||||||
public Object translationUnitBegin();
|
public Object translationUnitBegin();
|
||||||
public void translationUnitEnd(Object unit);
|
public void translationUnitEnd(Object unit);
|
||||||
|
|
||||||
public void inclusionBegin(String includeFile, int offset);
|
public void inclusionBegin(String includeFile, int nameBeginOffset, int inclusionBeginOffset);
|
||||||
public void inclusionEnd();
|
public void inclusionEnd();
|
||||||
public void macro(String macroName, int offset);
|
public void macro(String macroName, int macroNameOffset, int macroBeginOffset, int macroEndOffset);
|
||||||
|
|
||||||
public Object simpleDeclarationBegin(Object Container);
|
public Object simpleDeclarationBegin(Object Container, Token firstToken);
|
||||||
public void simpleDeclSpecifier(Object Container, Token specifier);
|
public void simpleDeclSpecifier(Object Container, Token specifier);
|
||||||
public void simpleDeclSpecifierName( Object declaration );
|
public void simpleDeclSpecifierName( Object declaration );
|
||||||
public void simpleDeclarationEnd(Object declaration);
|
public void simpleDeclarationEnd(Object declaration, Token lastToken);
|
||||||
|
|
||||||
public Object parameterDeclarationBegin( Object Container );
|
public Object parameterDeclarationBegin( Object Container );
|
||||||
public void parameterDeclarationEnd( Object declaration );
|
public void parameterDeclarationEnd( Object declaration );
|
||||||
|
@ -60,7 +60,7 @@ public interface IParserCallback {
|
||||||
public void classSpecifierAbort( Object classSpecifier );
|
public void classSpecifierAbort( Object classSpecifier );
|
||||||
public void classSpecifierSafe( Object classSpecifier );
|
public void classSpecifierSafe( Object classSpecifier );
|
||||||
public void classMemberVisibility( Object classSpecifier, Token visibility );
|
public void classMemberVisibility( Object classSpecifier, Token visibility );
|
||||||
public void classSpecifierEnd(Object classSpecifier);
|
public void classSpecifierEnd(Object classSpecifier, Token closingBrace );
|
||||||
|
|
||||||
public Object baseSpecifierBegin( Object containingClassSpec );
|
public Object baseSpecifierBegin( Object containingClassSpec );
|
||||||
public void baseSpecifierName( Object baseSpecifier );
|
public void baseSpecifierName( Object baseSpecifier );
|
||||||
|
@ -78,10 +78,10 @@ public interface IParserCallback {
|
||||||
public void elaboratedTypeSpecifierName( Object elab );
|
public void elaboratedTypeSpecifierName( Object elab );
|
||||||
public void elaboratedTypeSpecifierEnd( Object elab );
|
public void elaboratedTypeSpecifierEnd( Object elab );
|
||||||
|
|
||||||
public Object namespaceDefinitionBegin( Object container );
|
public Object namespaceDefinitionBegin( Object container, Token namespace );
|
||||||
public void namespaceDefinitionId( Object namespace );
|
public void namespaceDefinitionId( Object namespace );
|
||||||
public void namespaceDefinitionAbort( Object namespace );
|
public void namespaceDefinitionAbort( Object namespace );
|
||||||
public void namespaceDefinitionEnd( Object namespace );
|
public void namespaceDefinitionEnd( Object namespace, Token closingBrace );
|
||||||
|
|
||||||
public Object linkageSpecificationBegin( Object container, String literal );
|
public Object linkageSpecificationBegin( Object container, String literal );
|
||||||
public void linkageSpecificationEnd( Object linkageSpec );
|
public void linkageSpecificationEnd( Object linkageSpec );
|
||||||
|
@ -99,11 +99,11 @@ public interface IParserCallback {
|
||||||
public Object enumSpecifierBegin( Object container, Token enumKey );
|
public Object enumSpecifierBegin( Object container, Token enumKey );
|
||||||
public void enumSpecifierId( Object enumSpec );
|
public void enumSpecifierId( Object enumSpec );
|
||||||
public void enumSpecifierAbort( Object enumSpec );
|
public void enumSpecifierAbort( Object enumSpec );
|
||||||
public void enumSpecifierEnd( Object enumSpec );
|
public void enumSpecifierEnd( Object enumSpec, Token closingBrace );
|
||||||
|
|
||||||
public Object enumDefinitionBegin( Object enumSpec );
|
public Object enumeratorBegin( Object enumSpec );
|
||||||
public void enumDefinitionId( Object enumDefn );
|
public void enumeratorId( Object enumDefn );
|
||||||
public void enumDefinitionEnd( Object enumDefn );
|
public void enumeratorEnd( Object enumDefn, Token lastToken );
|
||||||
|
|
||||||
public void asmDefinition( Object container, String assemblyCode );
|
public void asmDefinition( Object container, String assemblyCode );
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ public class NullParserCallback implements IParserCallback {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#inclusionBegin(java.lang.String, int)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#inclusionBegin(java.lang.String, int)
|
||||||
*/
|
*/
|
||||||
public void inclusionBegin(String includeFile, int offset) {
|
public void inclusionBegin(String includeFile, int offset, int inclusionBeginOffset) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -30,13 +30,13 @@ public class NullParserCallback implements IParserCallback {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#macro(java.lang.String, int)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#macro(java.lang.String, int)
|
||||||
*/
|
*/
|
||||||
public void macro(String macroName, int offset) {
|
public void macro(String macroName, int offset, int macroBeginOffset, int macroEndOffset) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#simpleDeclarationBegin(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#simpleDeclarationBegin(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public Object simpleDeclarationBegin(Object Container) {
|
public Object simpleDeclarationBegin(Object Container, Token firstToken) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ public class NullParserCallback implements IParserCallback {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#simpleDeclarationEnd(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#simpleDeclarationEnd(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void simpleDeclarationEnd(Object declaration) {
|
public void simpleDeclarationEnd(Object declaration, Token lastToken) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -224,7 +224,7 @@ public class NullParserCallback implements IParserCallback {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#classSpecifierEnd(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#classSpecifierEnd(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void classSpecifierEnd(Object classSpecifier) {
|
public void classSpecifierEnd(Object classSpecifier, Token closingBrace) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -317,7 +317,7 @@ public class NullParserCallback implements IParserCallback {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationBegin(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationBegin(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public Object namespaceDefinitionBegin(Object container) {
|
public Object namespaceDefinitionBegin(Object container, Token namespace) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -336,7 +336,7 @@ public class NullParserCallback implements IParserCallback {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationEnd(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#namespaceDeclarationEnd(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void namespaceDefinitionEnd(Object namespace) {
|
public void namespaceDefinitionEnd(Object namespace, Token closingBrace) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -432,26 +432,26 @@ public class NullParserCallback implements IParserCallback {
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierEnd(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumSpecifierEnd(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void enumSpecifierEnd(Object enumSpec) {
|
public void enumSpecifierEnd(Object enumSpec, Token closingBrace) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionBegin(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionBegin(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public Object enumDefinitionBegin(Object enumSpec) {
|
public Object enumeratorBegin(Object enumSpec) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionId(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionId(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void enumDefinitionId(Object enumDefn) {
|
public void enumeratorId(Object enumDefn) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionEnd(java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.parser.IParserCallback#enumDefinitionEnd(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
public void enumDefinitionEnd(Object enumDefn) {
|
public void enumeratorEnd(Object enumDefn, Token lastToken) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -459,9 +459,8 @@ c, quick);
|
||||||
|
|
||||||
protected void namespaceDefinition( Object container ) throws Backtrack
|
protected void namespaceDefinition( Object container ) throws Backtrack
|
||||||
{
|
{
|
||||||
consume( Token.t_namespace);
|
|
||||||
Object namespace = null;
|
Object namespace = null;
|
||||||
try{ namespace = callback.namespaceDefinitionBegin( container );} catch( Exception e ) {}
|
try{ namespace = callback.namespaceDefinitionBegin( container, consume( Token.t_namespace) );} catch( Exception e ) {}
|
||||||
|
|
||||||
// optional name
|
// optional name
|
||||||
if( LT(1) == Token.tIDENTIFIER )
|
if( LT(1) == Token.tIDENTIFIER )
|
||||||
|
@ -487,8 +486,8 @@ c, quick);
|
||||||
consumeToNextSemicolon();
|
consumeToNextSemicolon();
|
||||||
}
|
}
|
||||||
// consume the }
|
// consume the }
|
||||||
consume();
|
|
||||||
try{ callback.namespaceDefinitionEnd( namespace );} catch( Exception e ) {}
|
try{ callback.namespaceDefinitionEnd( namespace, consume( Token.tRBRACE ));} catch( Exception e ) {}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -511,7 +510,8 @@ c, quick);
|
||||||
*/
|
*/
|
||||||
protected void simpleDeclaration( Object container ) throws Backtrack {
|
protected void simpleDeclaration( Object container ) throws Backtrack {
|
||||||
Object simpleDecl = null;
|
Object simpleDecl = null;
|
||||||
try{ simpleDecl = callback.simpleDeclarationBegin( container);} catch( Exception e ) {}
|
Token lastToken = null;
|
||||||
|
try{ simpleDecl = callback.simpleDeclarationBegin( container, LA(1));} catch( Exception e ) {}
|
||||||
declSpecifierSeq(simpleDecl, false);
|
declSpecifierSeq(simpleDecl, false);
|
||||||
Object declarator = null;
|
Object declarator = null;
|
||||||
|
|
||||||
|
@ -534,7 +534,7 @@ c, quick);
|
||||||
|
|
||||||
switch (LT(1)) {
|
switch (LT(1)) {
|
||||||
case Token.tSEMI:
|
case Token.tSEMI:
|
||||||
consume();
|
lastToken = consume(Token.tSEMI);
|
||||||
break;
|
break;
|
||||||
case Token.tCOLON:
|
case Token.tCOLON:
|
||||||
ctorInitializer(declarator);
|
ctorInitializer(declarator);
|
||||||
|
@ -545,10 +545,11 @@ c, quick);
|
||||||
if (quickParse) {
|
if (quickParse) {
|
||||||
// speed up the parser by skiping the body
|
// speed up the parser by skiping the body
|
||||||
// simply look for matching brace and return
|
// simply look for matching brace and return
|
||||||
consume(Token.tLBRACE);
|
lastToken = consume(Token.tLBRACE);
|
||||||
int depth = 1;
|
int depth = 1;
|
||||||
while (depth > 0) {
|
while (depth > 0) {
|
||||||
switch (consume().getType()) {
|
lastToken = consume();
|
||||||
|
switch (lastToken.getType()) {
|
||||||
case Token.tRBRACE:
|
case Token.tRBRACE:
|
||||||
--depth;
|
--depth;
|
||||||
break;
|
break;
|
||||||
|
@ -560,13 +561,13 @@ c, quick);
|
||||||
} else {
|
} else {
|
||||||
functionBody();
|
functionBody();
|
||||||
}
|
}
|
||||||
try{ callback.functionBodyEnd(function);} catch( Exception e ) {}
|
try{ callback.functionBodyEnd(function );} catch( Exception e ) {}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
try{ callback.simpleDeclarationEnd(simpleDecl);} catch( Exception e ) {}
|
try{ callback.simpleDeclarationEnd(simpleDecl, lastToken);} catch( Exception e ) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void ctorInitializer(Object declarator) throws Backtrack {
|
protected void ctorInitializer(Object declarator) throws Backtrack {
|
||||||
|
@ -1269,9 +1270,9 @@ c, quick);
|
||||||
if( LT(1) == Token.tIDENTIFIER )
|
if( LT(1) == Token.tIDENTIFIER )
|
||||||
{
|
{
|
||||||
defn = null;
|
defn = null;
|
||||||
try{ defn = callback.enumDefinitionBegin( enumSpecifier );} catch( Exception e ) {}
|
try{ defn = callback.enumeratorBegin( enumSpecifier );} catch( Exception e ) {}
|
||||||
identifier();
|
identifier();
|
||||||
try{ callback.enumDefinitionId( defn ); } catch( Exception e ) {}
|
try{ callback.enumeratorId( defn ); } catch( Exception e ) {}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1288,21 +1289,20 @@ c, quick);
|
||||||
try{ callback.expressionEnd( expression );} catch( Exception e ) {}
|
try{ callback.expressionEnd( expression );} catch( Exception e ) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
try{ callback.enumDefinitionEnd( defn );} catch( Exception e ) {}
|
|
||||||
|
try{ callback.enumeratorEnd( defn, lastToken );} catch( Exception e ) {}
|
||||||
if( LT(1) == Token.tRBRACE )
|
if( LT(1) == Token.tRBRACE )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
if( LT(1) != Token.tCOMMA )
|
if( LT(1) != Token.tCOMMA )
|
||||||
{
|
{
|
||||||
try{ callback.enumSpecifierAbort( enumSpecifier );} catch( Exception e ) {}
|
try{ callback.enumSpecifierAbort( enumSpecifier );} catch( Exception e ) {}
|
||||||
throw backtrack;
|
throw backtrack;
|
||||||
}
|
}
|
||||||
consume(Token.tCOMMA); // if we made it this far
|
consume(Token.tCOMMA);
|
||||||
}
|
}
|
||||||
consume( Token.tRBRACE );
|
try{ callback.enumSpecifierEnd( enumSpecifier, consume( Token.tRBRACE ) );} catch( Exception e ) {}
|
||||||
|
|
||||||
try{ callback.enumSpecifierEnd( enumSpecifier );} catch( Exception e ) {}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1357,9 +1357,8 @@ c, quick);
|
||||||
baseSpecifier( classSpec );
|
baseSpecifier( classSpec );
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we don't get a "{", assume elaborated type
|
|
||||||
if (LT(1) == Token.tLBRACE) {
|
if (LT(1) == Token.tLBRACE) {
|
||||||
consume();
|
consume(Token.tLBRACE);
|
||||||
|
|
||||||
memberDeclarationLoop:
|
memberDeclarationLoop:
|
||||||
while (LT(1) != Token.tRBRACE) {
|
while (LT(1) != Token.tRBRACE) {
|
||||||
|
@ -1382,10 +1381,10 @@ c, quick);
|
||||||
consumeToNextSemicolon();
|
consumeToNextSemicolon();
|
||||||
}
|
}
|
||||||
// consume the }
|
// consume the }
|
||||||
consume();
|
try{ callback.classSpecifierEnd(classSpec, consume( Token.tRBRACE )); } catch( Exception e ) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
try{ callback.classSpecifierEnd(classSpec); } catch( Exception e ) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void baseSpecifier( Object classSpecOwner ) throws Backtrack {
|
protected void baseSpecifier( Object classSpecOwner ) throws Backtrack {
|
||||||
|
@ -2063,7 +2062,7 @@ c, quick);
|
||||||
|
|
||||||
// Token management
|
// Token management
|
||||||
private IScanner scanner;
|
private IScanner scanner;
|
||||||
private Token currToken;
|
private Token currToken, lastToken;
|
||||||
|
|
||||||
private Token fetchToken() throws EndOfFile {
|
private Token fetchToken() throws EndOfFile {
|
||||||
try {
|
try {
|
||||||
|
@ -2103,9 +2102,9 @@ c, quick);
|
||||||
if (currToken == null)
|
if (currToken == null)
|
||||||
currToken = fetchToken();
|
currToken = fetchToken();
|
||||||
|
|
||||||
Token retToken = currToken;
|
lastToken = currToken;
|
||||||
currToken = currToken.getNext();
|
currToken = currToken.getNext();
|
||||||
return retToken;
|
return lastToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Token consume(int type) throws Backtrack {
|
protected Token consume(int type) throws Backtrack {
|
||||||
|
@ -2123,6 +2122,7 @@ c, quick);
|
||||||
|
|
||||||
protected void backup(Token mark) {
|
protected void backup(Token mark) {
|
||||||
currToken = mark;
|
currToken = mark;
|
||||||
|
lastToken = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -718,6 +718,7 @@ public class Scanner implements IScanner {
|
||||||
currentContext);
|
currentContext);
|
||||||
|
|
||||||
} else if (c == '#') {
|
} else if (c == '#') {
|
||||||
|
int beginningOffset = currentContext.getOffset();
|
||||||
// lets prepare for a preprocessor statement
|
// lets prepare for a preprocessor statement
|
||||||
StringBuffer buff = new StringBuffer();
|
StringBuffer buff = new StringBuffer();
|
||||||
buff.append((char) c);
|
buff.append((char) c);
|
||||||
|
@ -761,7 +762,7 @@ public class Scanner implements IScanner {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
poundDefine();
|
poundDefine(beginningOffset);
|
||||||
|
|
||||||
c = getChar();
|
c = getChar();
|
||||||
continue;
|
continue;
|
||||||
|
@ -773,7 +774,7 @@ public class Scanner implements IScanner {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
poundInclude();
|
poundInclude( beginningOffset );
|
||||||
|
|
||||||
c = getChar();
|
c = getChar();
|
||||||
continue;
|
continue;
|
||||||
|
@ -1465,7 +1466,7 @@ public class Scanner implements IScanner {
|
||||||
return encounteredNewline;
|
return encounteredNewline;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void poundInclude() throws ScannerException {
|
protected void poundInclude( int beginningOffset ) throws ScannerException {
|
||||||
skipOverWhitespace();
|
skipOverWhitespace();
|
||||||
int c = getChar();
|
int c = getChar();
|
||||||
int offset;
|
int offset;
|
||||||
|
@ -1498,7 +1499,7 @@ public class Scanner implements IScanner {
|
||||||
{
|
{
|
||||||
offset = currentContext.getOffset() - f.length() - 1; // -1 for the end quote
|
offset = currentContext.getOffset() - f.length() - 1; // -1 for the end quote
|
||||||
|
|
||||||
callback.inclusionBegin( f, offset );
|
callback.inclusionBegin( f, offset, beginningOffset );
|
||||||
callback.inclusionEnd();
|
callback.inclusionEnd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1506,7 +1507,7 @@ public class Scanner implements IScanner {
|
||||||
handleInclusion(f.trim(), useIncludePath );
|
handleInclusion(f.trim(), useIncludePath );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void poundDefine() throws ScannerException, Parser.EndOfFile {
|
protected void poundDefine(int beginning) throws ScannerException, Parser.EndOfFile {
|
||||||
skipOverWhitespace();
|
skipOverWhitespace();
|
||||||
// definition
|
// definition
|
||||||
String key = getNextIdentifier();
|
String key = getNextIdentifier();
|
||||||
|
@ -1614,7 +1615,7 @@ public class Scanner implements IScanner {
|
||||||
|
|
||||||
// call the callback accordingly
|
// call the callback accordingly
|
||||||
if( callback != null )
|
if( callback != null )
|
||||||
callback.macro( key, offset );
|
callback.macro( key, offset, beginning, currentContext.getOffset() );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void expandDefinition(String symbol, Object expansion)
|
protected void expandDefinition(String symbol, Object expansion)
|
||||||
|
|
|
@ -40,6 +40,11 @@ public class Token {
|
||||||
public int getOffset() { return offset; }
|
public int getOffset() { return offset; }
|
||||||
public int getLength() { return image.length(); }
|
public int getLength() { return image.length(); }
|
||||||
|
|
||||||
|
public int getDelta( Token other )
|
||||||
|
{
|
||||||
|
return other.getOffset() + other.getLength() - getOffset();
|
||||||
|
}
|
||||||
|
|
||||||
private Token next;
|
private Token next;
|
||||||
public Token getNext() { return next; }
|
public Token getNext() { return next; }
|
||||||
public void setNext(Token t) { next = t; }
|
public void setNext(Token t) { next = t; }
|
||||||
|
|
|
@ -53,4 +53,11 @@ public class Name {
|
||||||
{
|
{
|
||||||
return getEndOffset() - getStartOffset() + nameEnd.getImage().length();
|
return getEndOffset() - getStartOffset() + nameEnd.getImage().length();
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Token getNameStart() {
|
||||||
|
return nameStart;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue