From b3d789e0356806c2aaa7f5976458ba11df153d19 Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Tue, 6 Nov 2007 17:19:24 +0000 Subject: [PATCH] Deprecated methods in IASTTranslationUnit. --- .../cdt/core/dom/ast/IASTTranslationUnit.java | 14 +------------- .../cdt/internal/core/dom/parser/ASTNode.java | 13 ++++++++++--- .../core/dom/parser/c/CASTTranslationUnit.java | 8 -------- .../core/dom/parser/cpp/CPPASTTranslationUnit.java | 8 -------- .../core/parser/scanner/ASTPreprocessorNode.java | 3 --- .../internal/core/parser/scanner/LocationMap.java | 9 +++++---- 6 files changed, 16 insertions(+), 39 deletions(-) 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 064e0373b80..a8080b346b1 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 @@ -120,20 +120,9 @@ public interface IASTTranslationUnit extends IASTNode, IAdaptable { * @param offset sequence number as stored in the ast nodes. * @param length * @return and array of locations. + * @deprecated the offsets needed for this method are not accessible via public API. */ public IASTNodeLocation[] getLocationInfo(int offset, int length); - - /** - * Returns the smallest file location, that encloses the given global range. In case the range - * spans over multiple files, the files are mapped to include statements until all of them are - * found in the same file. So the resulting location contains the include directives that actually - * cause the range to be part of the AST. - * @param offset sequence number as stored in the ASTNodes. - * @param length - * @return a file location - * @since 5.0 - */ - public IASTFileLocation getMappedFileLocation(int offset, int length); /** * Select the node in the treet that best fits the offset/length/file path. @@ -202,7 +191,6 @@ public interface IASTTranslationUnit extends IASTNode, IAdaptable { * * @param nodeLocations IASTNodeLocations to flatten * @return null if not possible, otherwise, a file location representing where the macros are. - * @deprecated use {@link #getMappedFileLocation(int, int)} */ public IASTFileLocation flattenLocationsToFile( IASTNodeLocation [] nodeLocations ); 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 4fee91d7b3c..1a620fbcb05 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 @@ -82,9 +82,16 @@ public abstract class ASTNode implements IASTNode { public IASTNodeLocation[] getNodeLocations() { if (locations != null) return locations; - if (length == 0) - return EMPTY_LOCATION_ARRAY; - locations = getTranslationUnit().getLocationInfo(offset, length); + if (length == 0) { + locations= EMPTY_LOCATION_ARRAY; + } + final IASTTranslationUnit tu= getTranslationUnit(); + if (tu != null) { + org.eclipse.cdt.internal.core.parser.scanner2.ILocationResolver l= (org.eclipse.cdt.internal.core.parser.scanner2.ILocationResolver) tu.getAdapter(org.eclipse.cdt.internal.core.parser.scanner2.ILocationResolver.class); + if (l != null) { + locations= l.getLocations(offset, length); + } + } return locations; } 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 4453281e843..3721084e15c 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 @@ -558,14 +558,6 @@ public class CASTTranslationUnit extends CASTNode implements return true; } - public IASTFileLocation getMappedFileLocation(int offset, int length) { - if (resolver instanceof org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver) { - org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver r2= (org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver) resolver; - return r2.getMappedFileLocation(offset, length); - } - return flattenLocationsToFile(getLocationInfo(offset, length)); - } - public IASTFileLocation flattenLocationsToFile(IASTNodeLocation[] nodeLocations) { if( resolver == null ) return null; 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 d0f75de4e28..e78e77f36e1 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 @@ -509,14 +509,6 @@ public class CPPASTTranslationUnit extends CPPASTNode implements return true; } - public IASTFileLocation getMappedFileLocation(int offset, int length) { - if (resolver instanceof org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver) { - org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver r2= (org.eclipse.cdt.internal.core.parser.scanner.ILocationResolver) resolver; - return r2.getMappedFileLocation(offset, length); - } - return flattenLocationsToFile(getLocationInfo(offset, length)); - } - public IASTFileLocation flattenLocationsToFile(IASTNodeLocation[] nodeLocations) { if( resolver == null ) return null; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ASTPreprocessorNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ASTPreprocessorNode.java index 586b7b9c8ef..3dca8c41f0d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ASTPreprocessorNode.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ASTPreprocessorNode.java @@ -68,9 +68,6 @@ abstract class ASTPreprocessorNode extends ASTNode { } public IASTNodeLocation[] getNodeLocations() { - if (getLength() == 0) { - return getTranslationUnit().getLocationInfo(getOffset(), 0); - } return super.getNodeLocations(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/LocationMap.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/LocationMap.java index 17cf3387674..11bcbef1aea 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/LocationMap.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/LocationMap.java @@ -414,6 +414,11 @@ public class LocationMap implements ILocationResolver { return -1; } + // mstodo implement + public IASTFileLocation flattenLocations(IASTNodeLocation[] locations) { + throw new UnsupportedOperationException(); + } + public IASTPreprocessorMacroDefinition[] getMacroDefinitions() { ArrayList result= new ArrayList(); @@ -497,10 +502,6 @@ public class LocationMap implements ILocationResolver { throw new UnsupportedOperationException(); } // mstodo- scanner removal - public IASTFileLocation flattenLocations(IASTNodeLocation[] locations) { - throw new UnsupportedOperationException(); - } - // mstodo- scanner removal public IASTName[] getMacroExpansions() { throw new UnsupportedOperationException(); }