diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFileLocation.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFileLocation.java index 7f58b5bc5a8..dfbefef3638 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFileLocation.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTFileLocation.java @@ -25,10 +25,4 @@ public interface IASTFileLocation extends IASTNodeLocation { public String getFileName(); public void setFileName( String fileName ); - /** - * @param b - */ - public void setResolved(boolean b); - public boolean getResolved(); - } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java index ae412e2b7b7..03c2818643d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java @@ -58,7 +58,8 @@ public interface IASTTranslationUnit extends IASTNode { public IASTNodeLocation getLocationInfo( int offset ); public IASTNodeLocation [] getLocationInfo( int offset, int length ); - public IASTNode getNodeForLocation( IASTNodeLocation location ); + public IASTNode[] selectNodesForLocation( String path, int offset, int length ); + public IASTNode[] selectNodesForLocation( int offset, int length ); public IASTMacroDefinition [] getMacroDefinitions(); public IASTPreprocessorIncludeStatement [] getIncludeDirectives(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTFileLocation.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTFileLocation.java index 2e469261d7f..d448711eaf2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTFileLocation.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ASTFileLocation.java @@ -18,7 +18,6 @@ import org.eclipse.cdt.core.dom.ast.IASTFileLocation; public class ASTFileLocation implements IASTFileLocation { private String fn; - private boolean resolved; private int o; private int l; @@ -36,20 +35,6 @@ public class ASTFileLocation implements IASTFileLocation { fn = fileName; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IASTFileLocation#setResolved(boolean) - */ - public void setResolved(boolean b) { - resolved = b; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IASTFileLocation#getResolved() - */ - public boolean getResolved() { - return resolved; - } - /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IASTNodeLocation#getNodeOffset() */ 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 45305d435f9..2f587eaddf1 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 @@ -36,6 +36,10 @@ public class CASTTranslationUnit extends CASTNode implements IASTTranslationUnit //Binding private CScope compilationUnit = null; private ILocationResolver resolver; + private static final IASTPreprocessorStatement[] EMPTY_PREPROCESSOR_STATEMENT_ARRAY = new IASTPreprocessorStatement[0]; + private static final IASTNodeLocation[] EMPTY_PREPROCESSOR_LOCATION_ARRAY = new IASTNodeLocation[0]; + private static final IASTMacroDefinition[] EMPTY_PREPROCESSOR_MACRODEF_ARRAY = new IASTMacroDefinition[0]; + private static final IASTPreprocessorIncludeStatement[] EMPTY_PREPROCESSOR_INCLUSION_ARRAY = new IASTPreprocessorIncludeStatement[0]; public void addDeclaration( IASTDeclaration d ) { @@ -111,6 +115,7 @@ public class CASTTranslationUnit extends CASTNode implements IASTTranslationUnit * @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getLocationInfo(int) */ public IASTNodeLocation getLocationInfo(int offset) { + if( resolver == null ) return null; return resolver.getLocation(offset); } @@ -119,6 +124,7 @@ public class CASTTranslationUnit extends CASTNode implements IASTTranslationUnit * @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getLocationInfo(int, int) */ public IASTNodeLocation[] getLocationInfo(int offset, int length) { + if( resolver == null ) return EMPTY_PREPROCESSOR_LOCATION_ARRAY; return resolver.getLocations(offset,length); } @@ -126,7 +132,7 @@ public class CASTTranslationUnit extends CASTNode implements IASTTranslationUnit /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getNodeForLocation(org.eclipse.cdt.core.dom.ast.IASTNodeLocation) */ - public IASTNode getNodeForLocation(IASTNodeLocation location) { + public IASTNode[] selectNodesForLocation(String path, int offset, int length) { // TODO Auto-generated method stub return null; } @@ -136,6 +142,7 @@ public class CASTTranslationUnit extends CASTNode implements IASTTranslationUnit * @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getMacroDefinitions() */ public IASTMacroDefinition[] getMacroDefinitions() { + if( resolver == null ) return EMPTY_PREPROCESSOR_MACRODEF_ARRAY; return resolver.getMacroDefinitions(this); } @@ -144,6 +151,7 @@ public class CASTTranslationUnit extends CASTNode implements IASTTranslationUnit * @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getIncludeDirectives() */ public IASTPreprocessorIncludeStatement[] getIncludeDirectives() { + if( resolver == null ) return EMPTY_PREPROCESSOR_INCLUSION_ARRAY; return resolver.getIncludeDirectives(this); } @@ -152,6 +160,7 @@ public class CASTTranslationUnit extends CASTNode implements IASTTranslationUnit * @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getAllPreprocessorStatements() */ public IASTPreprocessorStatement[] getAllPreprocessorStatements() { + if( resolver == null ) return EMPTY_PREPROCESSOR_STATEMENT_ARRAY; return resolver.getAllPreprocessorStatements(this); } @@ -162,4 +171,20 @@ public class CASTTranslationUnit extends CASTNode implements IASTTranslationUnit public void setLocationResolver(ILocationResolver resolver) { this.resolver = resolver; } + + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#selectNodesForLocation(int, int) + */ + public IASTNode[] selectNodesForLocation(int offset, int length) { + return selectNodesForLocation( "", offset, length ); //$NON-NLS-1$ + } + + /* (non-Javadoc) + * @see java.lang.Object#finalize() + */ + protected void finalize() throws Throwable { + if( resolver != null ) resolver.cleanup(); + super.finalize(); + } } 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 e0d95badece..94e89a4f1c5 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 @@ -125,8 +125,7 @@ public class CPPASTTranslationUnit extends CPPASTNode implements /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getNodeForLocation(org.eclipse.cdt.core.dom.ast.IASTNodeLocation) */ - public IASTNode getNodeForLocation(IASTNodeLocation location) { - // TODO Auto-generated method stub + public IASTNode[] selectNodesForLocation(String path, int offset, int length) { return null; } @@ -161,4 +160,12 @@ public class CPPASTTranslationUnit extends CPPASTNode implements public void setLocationResolver(ILocationResolver resolver) { this.resolver = resolver; } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#selectNodesForLocation(int, int) + */ + public IASTNode[] selectNodesForLocation(int offset, int length) { + return selectNodesForLocation( resolver.getTranslationUnitPath(), offset, length ); //$NON-NLS-1$ + } + } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/ILocationResolver.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/ILocationResolver.java index 256f5582950..3c538cafa16 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/ILocationResolver.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/ILocationResolver.java @@ -15,6 +15,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNodeLocation; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement; +import org.eclipse.cdt.core.parser.IProblem; /** * @author jcamelon @@ -27,5 +28,11 @@ public interface ILocationResolver { public IASTNodeLocation [] getLocations( int offset, int length ); public IASTNodeLocation getLocation( int offset ); + public IProblem [] getScannerProblems(); + + public String getTranslationUnitPath(); + public String [] getInclusionsPaths(); + + public void cleanup(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/IScannerPreprocessorLog.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/IScannerPreprocessorLog.java index c483420574b..4d37e71fd79 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/IScannerPreprocessorLog.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/IScannerPreprocessorLog.java @@ -10,6 +10,8 @@ **********************************************************************/ package org.eclipse.cdt.internal.core.parser.scanner2; +import org.eclipse.cdt.core.parser.IProblem; + /** * @author jcamelon */ @@ -54,4 +56,6 @@ public interface IScannerPreprocessorLog { public void encounterPoundElif(int startOffset, int endOffset); public void encounterPoundEndIf(int startOffset, int endOffset); + + public void encounterProblem( IProblem problem ); } \ No newline at end of file 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 a63e2c40761..d135679191a 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 @@ -15,6 +15,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTNodeLocation; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement; import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement; +import org.eclipse.cdt.core.parser.IProblem; /** * @author jcamelon @@ -209,4 +210,43 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog { } + /* (non-Javadoc) + * @see org.eclipse.cdt.internal.core.parser.scanner2.ILocationResolver#getTranslationUnitPath() + */ + public String getTranslationUnitPath() { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.internal.core.parser.scanner2.ILocationResolver#getInclusionsPaths() + */ + public String[] getInclusionsPaths() { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.internal.core.parser.scanner2.ILocationResolver#cleanup() + */ + public void cleanup() { + // TODO Auto-generated method stub + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.internal.core.parser.scanner2.ILocationResolver#getScannerProblems() + */ + public IProblem[] getScannerProblems() { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerPreprocessorLog#encounterIProblem(org.eclipse.cdt.core.parser.IProblem) + */ + public void encounterProblem(IProblem problem) { + // TODO Auto-generated method stub + + } + } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/Scanner2.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/Scanner2.java index 84da6d89a13..44ac60ec500 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/Scanner2.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/Scanner2.java @@ -3466,9 +3466,10 @@ public class Scanner2 implements IScanner, IScannerData { * @see org.eclipse.cdt.core.parser.IScanner#getLocationResolver() */ public ILocationResolver getLocationResolver() { - // TODO Auto-generated method stub + if( locationMap instanceof ILocationResolver ) + return (ILocationResolver) locationMap; return null; } - - + + final IScannerPreprocessorLog locationMap = new LocationMap(); } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/dom/CDOM.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/dom/CDOM.java index ff877bb7eb3..3408a57b457 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/dom/CDOM.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/dom/CDOM.java @@ -9,7 +9,6 @@ * IBM - Initial API and implementation **********************************************************************/ package org.eclipse.cdt.core.dom; -import org.eclipse.cdt.core.dom.ast.IASTLocationFactory; import org.eclipse.cdt.internal.core.dom.InternalASTServiceProvider; import org.eclipse.cdt.internal.core.dom.SavedCodeReaderFactory; @@ -88,9 +87,6 @@ public class CDOM { return null; } - public IASTLocationFactory getLocationFactory() - { - return new EclipseLocationFactory(); - } + } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/dom/EclipseLocationFactory.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/dom/EclipseLocationFactory.java deleted file mode 100644 index 0d66fa8ad8f..00000000000 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/dom/EclipseLocationFactory.java +++ /dev/null @@ -1,56 +0,0 @@ -/********************************************************************** - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM - Initial API and implementation - **********************************************************************/ -package org.eclipse.cdt.core.dom; - -import org.eclipse.cdt.core.dom.ast.IASTFileLocation; -import org.eclipse.cdt.core.dom.ast.IASTLocationFactory; -import org.eclipse.cdt.core.dom.ast.IASTResourceLocation; -import org.eclipse.cdt.core.model.IWorkingCopy; -import org.eclipse.cdt.internal.core.dom.parser.ASTFileLocation; -import org.eclipse.core.resources.IResource; - -/** - * @author jcamelon - */ -public class EclipseLocationFactory implements IASTLocationFactory { - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IASTLocationFactory#createUnresolvedFileLocation(java.lang.String, int, int) - */ - public IASTFileLocation createUnresolvedFileLocation(String path, - int offset, int length) { - IASTFileLocation result = new ASTFileLocation(); - result.setResolved(false); - result.setNodeOffset( offset ); - result.setNodeLength( length ); - result.setFileName( path ); - return result; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IASTLocationFactory#createUnresolvedResourceLocation(org.eclipse.core.resources.IResource, int, int) - */ - public IASTResourceLocation createUnresolvedResourceLocation( - IResource resource, int offset, int length) { - // TODO Auto-generated method stub - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IASTLocationFactory#createUnresolvedWorkingCopyLocation(org.eclipse.cdt.core.model.IWorkingCopy, int, int) - */ - public IASTResourceLocation createUnresolvedWorkingCopyLocation( - IWorkingCopy workingCopy, int offset, int length) { - // TODO Auto-generated method stub - return null; - } - -} diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/dom/ast/IASTLocationFactory.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/dom/ast/IASTLocationFactory.java deleted file mode 100644 index 25f3c261881..00000000000 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/dom/ast/IASTLocationFactory.java +++ /dev/null @@ -1,24 +0,0 @@ -/********************************************************************** - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * IBM - Initial API and implementation - **********************************************************************/ -package org.eclipse.cdt.core.dom.ast; - -import org.eclipse.cdt.core.model.IWorkingCopy; -import org.eclipse.core.resources.IResource; - -/** - * @author jcamelon - */ -public interface IASTLocationFactory { - - public IASTFileLocation createUnresolvedFileLocation( String path, int offset, int length ); - public IASTResourceLocation createUnresolvedResourceLocation( IResource resource, int offset, int length ); - public IASTResourceLocation createUnresolvedWorkingCopyLocation( IWorkingCopy workingCopy, int offset, int length ); -}