diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNode.java index d1f2b9cdf59..5003a61f03b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNode.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTNode.java @@ -17,14 +17,15 @@ package org.eclipse.cdt.core.dom.ast; * @author Doug Schaefer */ public interface IASTNode { + public static final IASTNode [] EMPTY_NODE_ARRAY = new IASTNode[0]; + /** * Get the translation unit (master) node that is the ancestor of all nodes * in this AST. * * @return IASTTranslationUnit */ - public IASTTranslationUnit getTranslationUnit(); /** @@ -44,7 +45,6 @@ public interface IASTNode { */ public IASTNodeLocation[] getNodeLocations(); - /** * Get the location of the node as a file. * @@ -52,7 +52,6 @@ public interface IASTNode { */ public IASTFileLocation getFileLocation(); - /** * Lightweight check for understanding what file we are in. * @@ -109,4 +108,14 @@ public interface IASTNode { */ public String getRawSignature(); + /** + * Internal interface. + * + * Get the scope for this node. Different children may get different nodes. + * + * @param childProperty + * @return + */ + public IScope2 getScope(IASTNode child, ASTNodeProperty childProperty); + } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IScope2.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IScope2.java new file mode 100644 index 00000000000..947d8ea3f70 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IScope2.java @@ -0,0 +1,19 @@ +/******************************************************************************* + * Copyright (c) 2005 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * QNX - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core.dom.ast; + +/** + * @author Doug Schaefer + * + */ +public interface IScope2 { + +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNode.java index 537bf845cc5..d9ebd031b5b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNode.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTNode.java @@ -10,21 +10,43 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser; +import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; +import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTFileLocation; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNodeLocation; +import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; +import org.eclipse.cdt.core.dom.ast.IScope2; /** * @author jcamelon */ public abstract class ASTNode implements IASTNode { - private int length; - - private int offset; - private static final IASTNodeLocation[] EMPTY_LOCATION_ARRAY = new IASTNodeLocation[0]; + private IASTNode parent; + private ASTNodeProperty property; + + private int length; + private int offset; + + public IASTNode getParent() { + return parent; + } + + public void setParent(IASTNode node) { + this.parent = node; + } + + public ASTNodeProperty getPropertyInParent() { + return property; + } + + public void setPropertyInParent(ASTNodeProperty property) { + this.property = property; + } + public int getOffset() { return offset; } @@ -56,11 +78,6 @@ public abstract class ASTNode implements IASTNode { private IASTNodeLocation[] locations = null; private IASTFileLocation fileLocation = null; - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.core.dom.ast.IASTNode#getNodeLocations() - */ public IASTNodeLocation[] getNodeLocations() { if (locations != null) return locations; @@ -70,11 +87,6 @@ public abstract class ASTNode implements IASTNode { return locations; } - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.core.dom.ast.IASTNode#getRawSignature() - */ public String getRawSignature() { return getTranslationUnit().getUnpreprocessedSignature( getNodeLocations()); @@ -90,4 +102,17 @@ public abstract class ASTNode implements IASTNode { fileLocation = getTranslationUnit().flattenLocationsToFile( getNodeLocations() ); return fileLocation; } + + public IScope2 getScope(IASTNode child, ASTNodeProperty childProperty) { + return parent != null ? parent.getScope(this, property) : null; + } + + public IASTTranslationUnit getTranslationUnit() { + return parent != null ? parent.getTranslationUnit() : null; + } + + public boolean accept(ASTVisitor visitor) { + return true; + } + } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java index 7c4f88023ac..6e4721d1579 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java @@ -1132,6 +1132,8 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser { public static class FoundDeclaratorException extends Exception { + private static final long serialVersionUID = 0; + public final IASTDeclarator declarator; public final IToken currToken; public IASTDeclSpecifier declSpec; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTNode.java index c51513c4b3f..44f89dcae00 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTNode.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTNode.java @@ -10,60 +10,13 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; -import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; -import org.eclipse.cdt.core.dom.ast.IASTNode; -import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.internal.core.dom.parser.ASTNode; /** * @author jcamelon */ -public abstract class CASTNode extends ASTNode implements IASTNode { +public abstract class CASTNode extends ASTNode { - private IASTNode parent; - private ASTNodeProperty property; - - public IASTNode getParent() { - return parent; - } - - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IASTNode#getPropertyInParent() - */ - public ASTNodeProperty getPropertyInParent() { - return property; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IASTNode#setParent(org.eclipse.cdt.core.dom.ast.IASTNode) - */ - public void setParent(IASTNode parent) { - this.parent = parent; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IASTNode#setPropertyInParent(org.eclipse.cdt.core.dom.ast.IASTNodeProperty) - */ - public void setPropertyInParent(ASTNodeProperty property) { - this.property = property; - } - - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IASTNode#getTranslationUnit() - */ - public IASTTranslationUnit getTranslationUnit() { - if( this instanceof IASTTranslationUnit ) return (IASTTranslationUnit) this; - IASTNode node = getParent(); - while( ! (node instanceof IASTTranslationUnit ) && node != null ) - { - node = node.getParent(); - } - return (IASTTranslationUnit) node; - } - -// public boolean accept( ASTVisitor action ){ -// return true; -// } + // A little empty isn't it... + } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java index 14dd226d3ae..35772bb18e9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java @@ -76,6 +76,10 @@ public class CASTTranslationUnit extends CASTNode implements private static final IASTName[] EMPTY_NAME_ARRAY = new IASTName[0]; + public IASTTranslationUnit getTranslationUnit() { + return this; + } + public void addDeclaration(IASTDeclaration d) { if (d != null) { declsPos++; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNode.java index c9680be1769..0446db8cbc6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNode.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNode.java @@ -10,57 +10,13 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; -import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; -import org.eclipse.cdt.core.dom.ast.IASTNode; -import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.internal.core.dom.parser.ASTNode; /** * @author jcamelon */ -public abstract class CPPASTNode extends ASTNode implements IASTNode { +public abstract class CPPASTNode extends ASTNode { - private IASTNode parent; - private ASTNodeProperty property; - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IASTNode#getTranslationUnit() - */ - public IASTTranslationUnit getTranslationUnit() { - if( this instanceof IASTTranslationUnit ) return (IASTTranslationUnit) this; - IASTNode node = getParent(); - while(node != null && !(node instanceof IASTTranslationUnit)) - node = node.getParent(); - - return (IASTTranslationUnit) node; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IASTNode#getParent() - */ - public IASTNode getParent() { - return parent; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IASTNode#setParent(org.eclipse.cdt.core.dom.ast.IASTNode) - */ - public void setParent(IASTNode node) { - this.parent = node; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IASTNode#getPropertyInParent() - */ - public ASTNodeProperty getPropertyInParent() { - return property; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IASTNode#setPropertyInParent(org.eclipse.cdt.core.dom.ast.ASTNodeProperty) - */ - public void setPropertyInParent(ASTNodeProperty property) { - this.property = property; - } - + // A little empty isn't it... + } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java index d4ce9b4d39e..5a0247ef127 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java @@ -89,6 +89,10 @@ public class CPPASTTranslationUnit extends CPPASTNode implements private static final IASTName[] EMPTY_NAME_ARRAY = new IASTName[0]; + public IASTTranslationUnit getTranslationUnit() { + return this; + } + public void addDeclaration(IASTDeclaration d) { decls = (IASTDeclaration [])ArrayUtil.append( IASTDeclaration.class, decls, d ); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/LocationMap.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/LocationMap.java index c0609d54057..39910d4117f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/LocationMap.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/LocationMap.java @@ -10,8 +10,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.parser.scanner2; -import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; -import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTFileLocation; import org.eclipse.cdt.core.dom.ast.IASTFunctionStyleMacroParameter; import org.eclipse.cdt.core.dom.ast.IASTMacroExpansion; @@ -108,7 +106,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog { /** * @author jcamelon */ - public static class ASTEndif extends ScannerASTNode implements + public static class ASTEndif extends ASTNode implements IASTPreprocessorEndifStatement { } @@ -116,7 +114,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog { /** * @author jcamelon */ - public static class ASTElif extends ScannerASTNode implements + public static class ASTElif extends ASTNode implements IASTPreprocessorElifStatement { private final boolean taken; @@ -142,7 +140,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog { /** * @author jcamelon */ - public static class ASTElse extends ScannerASTNode implements + public static class ASTElse extends ASTNode implements IASTPreprocessorElseStatement { private final boolean taken; @@ -167,7 +165,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog { /** * @author jcamelon */ - public static class ASTIfndef extends ScannerASTNode implements + public static class ASTIfndef extends ASTNode implements IASTPreprocessorIfndefStatement { private final boolean taken; @@ -193,7 +191,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog { /** * @author jcamelon */ - public static class ASTIfdef extends ScannerASTNode implements + public static class ASTIfdef extends ASTNode implements IASTPreprocessorIfdefStatement { private final boolean taken; @@ -219,7 +217,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog { /** * @author jcamelon */ - public static class ASTIf extends ScannerASTNode implements + public static class ASTIf extends ASTNode implements IASTPreprocessorIfStatement { private final boolean taken; @@ -245,7 +243,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog { /** * @author jcamelon */ - public static class ASTError extends ScannerASTNode implements + public static class ASTError extends ASTNode implements IASTPreprocessorErrorStatement { } @@ -253,7 +251,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog { /** * @author jcamelon */ - public static class ASTPragma extends ScannerASTNode implements + public static class ASTPragma extends ASTNode implements IASTPreprocessorPragmaStatement { } @@ -261,7 +259,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog { /** * @author jcamelon */ - public static class ASTUndef extends ScannerASTNode implements + public static class ASTUndef extends ASTNode implements IASTPreprocessorUndefStatement { public ASTUndef( IASTName n ) @@ -439,7 +437,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog { /** * @author jcamelon */ - public static class ASTInclusionStatement extends ScannerASTNode implements + public static class ASTInclusionStatement extends ASTNode implements IASTPreprocessorIncludeStatement { private final char[] path; @@ -474,7 +472,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog { /** * @author jcamelon */ - public static class ASTFunctionMacro extends ScannerASTNode implements + public static class ASTFunctionMacro extends ASTNode implements IASTPreprocessorFunctionStyleMacroDefinition { private IASTName name; @@ -596,9 +594,9 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog { if( expansionName == null ) { expansionName = new ASTMacroName( name ); - ((ScannerASTNode)expansionName).setParent( rootNode ); - ((ScannerASTNode)expansionName).setPropertyInParent( IASTPreprocessorUndefStatement.MACRO_NAME ); - ((ScannerASTNode)expansionName).setOffsetAndLength( context_directive_start, name.length ); + expansionName.setParent( rootNode ); + expansionName.setPropertyInParent( IASTPreprocessorUndefStatement.MACRO_NAME ); + ((ASTNode)expansionName).setOffsetAndLength( context_directive_start, name.length ); } return expansionName; } @@ -618,72 +616,10 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog { } - public static class ScannerASTNode extends ASTNode { - private IASTNode parent; - - private ASTNodeProperty property; - - public IASTNode getParent() { - return parent; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.core.dom.ast.IASTNode#getPropertyInParent() - */ - public ASTNodeProperty getPropertyInParent() { - return property; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.core.dom.ast.IASTNode#setParent(org.eclipse.cdt.core.dom.ast.IASTNode) - */ - public void setParent(IASTNode parent) { - this.parent = parent; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.core.dom.ast.IASTNode#setPropertyInParent(org.eclipse.cdt.core.dom.ast.IASTNodeProperty) - */ - public void setPropertyInParent(ASTNodeProperty property) { - this.property = property; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.core.dom.ast.IASTNode#getTranslationUnit() - */ - public IASTTranslationUnit getTranslationUnit() { - if (this instanceof IASTTranslationUnit) - return (IASTTranslationUnit) this; - IASTNode node = getParent(); - while (!(node instanceof IASTTranslationUnit) && node != null) { - node = node.getParent(); - } - return (IASTTranslationUnit) node; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.core.dom.ast.IASTNode#accept(org.eclipse.cdt.core.dom.ast.IASTVisitor.BaseVisitorAction) - */ - public boolean accept(ASTVisitor visitor) { - return true; - } - - } - /** * @author jcamelon */ - public class ASTMacroName extends ScannerASTNode implements IASTName { + public class ASTMacroName extends ASTNode implements IASTName { private final char[] name; private IMacroBinding binding = null; @@ -776,7 +712,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog { /** * @author jcamelon */ - public static class ASTObjectMacro extends ScannerASTNode implements + public static class ASTObjectMacro extends ASTNode implements IASTPreprocessorObjectStyleMacroDefinition { private IASTName name; @@ -867,7 +803,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog { } - public static class ASTFunctionMacroParameter extends ScannerASTNode + public static class ASTFunctionMacroParameter extends ASTNode implements IASTFunctionStyleMacroParameter { private String value; @@ -1287,9 +1223,9 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog { if( expansionName == null ) { expansionName = new ASTMacroName( definition.getName() ); - ((ScannerASTNode)expansionName).setParent( rootNode ); - ((ScannerASTNode)expansionName).setPropertyInParent( IASTTranslationUnit.EXPANSION_NAME ); - ((ScannerASTNode)expansionName).setOffsetAndLength( context_directive_start, context_directive_end - context_directive_start + 1); + expansionName.setParent( rootNode ); + expansionName.setPropertyInParent( IASTTranslationUnit.EXPANSION_NAME ); + ((ASTNode)expansionName).setOffsetAndLength( context_directive_start, context_directive_end - context_directive_start + 1); } return expansionName; } @@ -1396,14 +1332,14 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog { IASTName name = new ASTMacroName(d.name); name.setPropertyInParent(IASTPreprocessorMacroDefinition.MACRO_NAME); name.setParent(r); - ((ScannerASTNode) name).setOffsetAndLength(d.nameOffset, d.name.length); + ((ASTNode) name).setOffsetAndLength(d.nameOffset, d.name.length); r.setName(name); r.setExpansion(new String(d.expansion)); - ((ScannerASTNode) r).setOffsetAndLength(d.context_directive_start, + ((ASTNode) r).setOffsetAndLength(d.context_directive_start, d.context_directive_end - d.context_directive_start); d.astNode = r; - ((ScannerASTNode) r).setParent(rootNode); - ((ScannerASTNode) r).setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT); + r.setParent(rootNode); + r.setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT); return r; } @@ -1433,15 +1369,15 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog { private IASTPreprocessorIncludeStatement createASTInclusion(_Inclusion inc) { IASTPreprocessorIncludeStatement result = new ASTInclusionStatement( inc.reader.filename); - ((ScannerASTNode) result).setOffsetAndLength( + ((ASTNode) result).setOffsetAndLength( inc.context_directive_start, inc.context_directive_end - inc.context_directive_start); ((ASTInclusionStatement) result).startOffset = inc.context_directive_end; ((ASTInclusionStatement) result).endOffset = inc.context_ends; ((ASTInclusionStatement) result).setParent(rootNode); ((ASTInclusionStatement) result).setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT); - ((ScannerASTNode) result).setParent(rootNode); - ((ScannerASTNode) result).setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT); + result.setParent(rootNode); + result.setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT); return result; } @@ -1500,8 +1436,8 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog { IASTPreprocessorEndifStatement result = new ASTEndif(); ((ASTNode) result).setOffsetAndLength(endif.context_directive_start, endif.context_directive_end - endif.context_directive_start); - ((ScannerASTNode) result).setParent(rootNode); - ((ScannerASTNode) result).setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT); + result.setParent(rootNode); + result.setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT); return result; } @@ -1513,8 +1449,8 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog { IASTPreprocessorElifStatement result = new ASTElif(elif.taken); ((ASTNode) result).setOffsetAndLength(elif.context_directive_start, elif.context_directive_end - elif.context_directive_start); - ((ScannerASTNode) result).setParent(rootNode); - ((ScannerASTNode) result).setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT); + result.setParent(rootNode); + result.setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT); return result; } @@ -1526,8 +1462,8 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog { IASTPreprocessorElseStatement result = new ASTElse(e.taken); ((ASTNode) result).setOffsetAndLength(e.context_directive_start, e.context_directive_end - e.context_directive_start); - ((ScannerASTNode) result).setParent(rootNode); - ((ScannerASTNode) result).setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT); + result.setParent(rootNode); + result.setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT); return result; } @@ -1539,8 +1475,8 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog { IASTPreprocessorIfndefStatement result = new ASTIfndef(ifndef.taken); ((ASTNode) result).setOffsetAndLength(ifndef.context_directive_start, ifndef.context_directive_end - ifndef.context_directive_start); - ((ScannerASTNode) result).setParent(rootNode); - ((ScannerASTNode) result).setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT); + result.setParent(rootNode); + result.setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT); return result; } @@ -1552,8 +1488,8 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog { IASTPreprocessorIfdefStatement result = new ASTIfdef(ifdef.taken); ((ASTNode) result).setOffsetAndLength(ifdef.context_directive_start, ifdef.context_directive_end - ifdef.context_directive_start); - ((ScannerASTNode) result).setParent(rootNode); - ((ScannerASTNode) result).setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT); + result.setParent(rootNode); + result.setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT); return result; } @@ -1565,8 +1501,8 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog { IASTPreprocessorIfStatement result = new ASTIf(i.taken); ((ASTNode) result).setOffsetAndLength(i.context_directive_start, i.context_directive_end - i.context_directive_start); - ((ScannerASTNode) result).setParent(rootNode); - ((ScannerASTNode) result).setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT); + result.setParent(rootNode); + result.setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT); return result; } @@ -1578,8 +1514,8 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog { IASTPreprocessorErrorStatement result = new ASTError(); ((ASTNode) result).setOffsetAndLength(error.context_directive_start, error.context_directive_end - error.context_directive_start); - ((ScannerASTNode) result).setParent(rootNode); - ((ScannerASTNode) result).setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT); + result.setParent(rootNode); + result.setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT); return result; } @@ -1591,8 +1527,8 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog { IASTPreprocessorPragmaStatement result = new ASTPragma(); ((ASTNode) result).setOffsetAndLength(pragma.context_directive_start, pragma.context_directive_end - pragma.context_directive_start); - ((ScannerASTNode) result).setParent(rootNode); - ((ScannerASTNode) result).setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT); + result.setParent(rootNode); + result.setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT); return result; } @@ -1604,8 +1540,8 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog { IASTPreprocessorUndefStatement result = new ASTUndef(undef.getName()); ((ASTNode) result).setOffsetAndLength(undef.context_directive_start, undef.context_directive_end - undef.context_directive_start); - ((ScannerASTNode) result).setParent(rootNode); - ((ScannerASTNode) result).setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT); + result.setParent(rootNode); + result.setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT); return result; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/ScannerASTProblem.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/ScannerASTProblem.java index 267adf15966..7594e34296e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/ScannerASTProblem.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/ScannerASTProblem.java @@ -14,12 +14,8 @@ import java.text.MessageFormat; import java.util.HashMap; import java.util.Map; -import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; -import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.IASTFileLocation; -import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTProblem; -import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.parser.ParserMessages; @@ -27,46 +23,7 @@ import org.eclipse.cdt.internal.core.parser.ParserMessages; * @author jcamelon */ public class ScannerASTProblem extends ASTNode implements IASTProblem { - private IASTNode parent; - - private ASTNodeProperty property; - - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.core.dom.ast.IASTNode#getParent() - */ - public IASTNode getParent() { - return parent; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.core.dom.ast.IASTNode#setParent(org.eclipse.cdt.core.dom.ast.IASTNode) - */ - public void setParent(IASTNode node) { - this.parent = node; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.core.dom.ast.IASTNode#getPropertyInParent() - */ - public ASTNodeProperty getPropertyInParent() { - return property; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.core.dom.ast.IASTNode#setPropertyInParent(org.eclipse.cdt.core.dom.ast.ASTNodeProperty) - */ - public void setPropertyInParent(ASTNodeProperty property) { - this.property = property; - } - + private final char[] arg; private final int id; @@ -84,29 +41,14 @@ public class ScannerASTProblem extends ASTNode implements IASTProblem { this.isError = error; } - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.core.parser.IASTProblem#getID() - */ public int getID() { return id; } - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.core.parser.IASTProblem#isError() - */ public boolean isError() { return isError; } - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.core.parser.IASTProblem#isWarning() - */ public boolean isWarning() { return isWarning; } @@ -284,44 +226,12 @@ public class ScannerASTProblem extends ASTNode implements IASTProblem { return message; } - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.core.parser.IASTProblem#checkCategory(int) - */ public boolean checkCategory(int bitmask) { return ((id & bitmask) != 0); } - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.core.parser.IASTProblem#getArguments() - */ public String getArguments() { return arg != null ? String.valueOf(arg) : ""; //$NON-NLS-1$ } - /* - * (non-Javadoc) - * - * @see org.eclipse.cdt.core.dom.ast.IASTNode#getTranslationUnit() - */ - public IASTTranslationUnit getTranslationUnit() { - if (this instanceof IASTTranslationUnit) - return (IASTTranslationUnit) this; - IASTNode node = getParent(); - while (!(node instanceof IASTTranslationUnit) && node != null) { - node = node.getParent(); - } - return (IASTTranslationUnit) node; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IASTNode#accept(org.eclipse.cdt.core.dom.ast.IASTVisitor.BaseVisitorAction) - */ - public boolean accept( ASTVisitor visitor ) { - return true; - } - }