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 59da8adb0a1..973e0b278d4 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 @@ -1091,6 +1091,8 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog { } public int getLineNumber(int nodeOffset) { + if( nodeOffset >= reader.buffer.length ) + return 1; int lineNumber = 1; for( int i = 0; i < nodeOffset; ++i ) { @@ -2322,6 +2324,8 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog { filename = result[0].getFileName(); length = result[0].getNodeLength(); } else { + if( result[i] != null && !result[i].getFileName().equals( filename ) ) + return null; if (result[i] != null && result[i].getNodeOffset() != (offset + length)) return null; diff --git a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/DOMAST.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/DOMAST.java index 0d8883384ad..499bc663c3d 100644 --- a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/DOMAST.java +++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/DOMAST.java @@ -103,6 +103,7 @@ import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.DrillDownAdapter; import org.eclipse.ui.part.ViewPart; +import org.eclipse.ui.texteditor.AbstractTextEditor; import org.eclipse.ui.views.properties.PropertySheet; /** @@ -947,7 +948,7 @@ public class DOMAST extends ViewPart { } private class ASTHighlighterAction extends Action { - IEditorPart aPart = null; + IEditorPart aPart = null; public ASTHighlighterAction(IEditorPart part) { this.aPart = part; @@ -975,7 +976,7 @@ public class DOMAST extends ViewPart { public void run() { ISelection selection = viewer.getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); - if (aPart instanceof CEditor && obj instanceof DOMASTNodeLeaf) { + if (obj instanceof DOMASTNodeLeaf) { String filename = ((DOMASTNodeLeaf) obj).getFilename(); if (filename.equals(DOMASTNodeLeaf.BLANK_STRING)) @@ -1001,10 +1002,17 @@ public class DOMAST extends ViewPart { return; } } - ((CEditor) aPart).selectAndReveal(((DOMASTNodeLeaf) obj).getOffset(), - ((DOMASTNodeLeaf) obj).getLength()); - + + if( aPart instanceof AbstractTextEditor ) + { + ((AbstractTextEditor) aPart).selectAndReveal(((DOMASTNodeLeaf) obj).getOffset(), + ((DOMASTNodeLeaf) obj).getLength()); + } + else + System.out.println( "aPart instanceof " + aPart.getClass().getName() ); + aPart.getSite().getPage().activate(aPart.getSite().getPage().findView(VIEW_ID)); + } } } diff --git a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/DOMASTNodeLeaf.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/DOMASTNodeLeaf.java index 61fefe14b2e..4dfa44c1c87 100644 --- a/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/DOMASTNodeLeaf.java +++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/DOMASTNodeLeaf.java @@ -151,7 +151,7 @@ public class DOMASTNodeLeaf implements IAdaptable { buffer.append(node); return buffer.toString(); } else if ( node instanceof IASTTranslationUnit ) { - String fileName = getFilename(); + String fileName = ((IASTTranslationUnit)node).getFilePath(); int lastSlash = fileName.lastIndexOf(FILE_SEPARATOR); if (lastSlash > 0) { @@ -277,7 +277,7 @@ public class DOMASTNodeLeaf implements IAdaptable { { if ( node == null ) return BLANK_STRING; IASTNodeLocation [] location = node.getNodeLocations(); - if( location.length > 0 && location[0] instanceof IASTFileLocation ) + if( location.length == 1 && location[0] instanceof IASTFileLocation ) return ((IASTFileLocation)location[0]).getFileName(); IASTFileLocation f = node.getTranslationUnit().flattenLocationsToFile(location); if( f == null )