### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/core/IImportDeclaration.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IImportDeclaration.java,v retrieving revision 1.24 diff -u -r1.24 IImportDeclaration.java --- model/org/eclipse/jdt/core/IImportDeclaration.java 27 Jun 2008 16:04:00 -0000 1.24 +++ model/org/eclipse/jdt/core/IImportDeclaration.java 27 Jul 2010 20:39:46 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation 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 @@ -46,4 +46,18 @@ * @return true if the import is on-demand, false otherwise */ boolean isOnDemand(); + +/** + * Returns the source range of this import declaration's name, + * or null if this import declaration does not have + * associated source code (for example, a binary type). + * + * @exception JavaModelException if this element does not exist or if an + * exception occurs while accessing its corresponding resource. + * @return the source range of this import declaration's name, + * or null if this import declaration does not have + * associated source code (for example, a binary type) + * @since 3.7 + */ +ISourceRange getNameRange() throws JavaModelException; } Index: model/org/eclipse/jdt/core/IPackageDeclaration.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/IPackageDeclaration.java,v retrieving revision 1.17 diff -u -r1.17 IPackageDeclaration.java --- model/org/eclipse/jdt/core/IPackageDeclaration.java 27 Jun 2008 16:04:01 -0000 1.17 +++ model/org/eclipse/jdt/core/IPackageDeclaration.java 27 Jul 2010 20:39:46 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation 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 @@ -24,4 +24,18 @@ * @return the name of the package the statement */ String getElementName(); +/** + * Returns the source range of this package declaration's name, + * or null if this package declaration does not have + * associated source code (for example, a binary type). + * + * @exception JavaModelException if this element does not exist or if an + * exception occurs while accessing its corresponding resource. + * @return the source range of this package declaration's name, + * or null if this package declaration does not have + * associated source code (for example, a binary type) + * @since 3.7 + */ +ISourceRange getNameRange() throws JavaModelException; + } Index: model/org/eclipse/jdt/internal/compiler/ISourceElementRequestor.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/ISourceElementRequestor.java,v retrieving revision 1.25 diff -u -r1.25 ISourceElementRequestor.java --- model/org/eclipse/jdt/internal/compiler/ISourceElementRequestor.java 16 Jan 2009 14:29:29 -0000 1.25 +++ model/org/eclipse/jdt/internal/compiler/ISourceElementRequestor.java 27 Jul 2010 20:39:46 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation 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 @@ -120,6 +120,12 @@ * @param declarationEnd * This is the position of the ';' ending the import statement or * the end of the comment following the import. + * @param nameStart + * This is the position of the first character of the import declaration's + * name. + * @param nameEnd + * This is the position of the last character of the import declaration's + * name. * @param tokens * This are the tokens of the import like specified in the source. * @param onDemand @@ -128,7 +134,7 @@ * @param modifiers * can be set to static from 1.5 on. */ - void acceptImport(int declarationStart, int declarationEnd, char[][] tokens, boolean onDemand, int modifiers); + void acceptImport(int declarationStart, int declarationEnd, int nameStart, int nameEnd, char[][] tokens, boolean onDemand, int modifiers); /* * Table of line separator position. This table is passed once at the end of Index: model/org/eclipse/jdt/internal/compiler/SourceElementNotifier.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementNotifier.java,v retrieving revision 1.6 diff -u -r1.6 SourceElementNotifier.java --- model/org/eclipse/jdt/internal/compiler/SourceElementNotifier.java 16 Jan 2009 14:29:29 -0000 1.6 +++ model/org/eclipse/jdt/internal/compiler/SourceElementNotifier.java 27 Jul 2010 20:39:46 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 IBM Corporation and others. + * Copyright (c) 2008, 2010 IBM Corporation 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 @@ -546,6 +546,8 @@ this.requestor.acceptImport( importReference.declarationSourceStart, importReference.declarationSourceEnd, + importReference.sourceStart, + importReference.sourceEnd, importReference.tokens, (importReference.bits & ASTNode.OnDemand) != 0, importReference.modifiers); Index: model/org/eclipse/jdt/internal/compiler/SourceElementRequestorAdapter.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementRequestorAdapter.java,v retrieving revision 1.20 diff -u -r1.20 SourceElementRequestorAdapter.java --- model/org/eclipse/jdt/internal/compiler/SourceElementRequestorAdapter.java 27 Jun 2008 16:04:07 -0000 1.20 +++ model/org/eclipse/jdt/internal/compiler/SourceElementRequestorAdapter.java 27 Jul 2010 20:39:46 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation 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 @@ -51,11 +51,13 @@ } /** - * @see ISourceElementRequestor#acceptImport(int, int, char[][], boolean, int) + * @see ISourceElementRequestor#acceptImport(int, int, int, int, char[][], boolean, int) */ public void acceptImport( int declarationStart, int declarationEnd, + int nameStart, + int nameEnd, char[][] tokens, boolean onDemand, int modifiers) { Index: model/org/eclipse/jdt/internal/core/AnnotatableInfo.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/AnnotatableInfo.java,v retrieving revision 1.4 diff -u -r1.4 AnnotatableInfo.java --- model/org/eclipse/jdt/internal/core/AnnotatableInfo.java 7 Mar 2009 00:58:56 -0000 1.4 +++ model/org/eclipse/jdt/internal/core/AnnotatableInfo.java 27 Jul 2010 20:39:46 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation 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 @@ -11,6 +11,8 @@ package org.eclipse.jdt.internal.core; import org.eclipse.jdt.core.IAnnotation; +import org.eclipse.jdt.core.ISourceRange; +import org.eclipse.jdt.core.SourceRange; public class AnnotatableInfo extends MemberElementInfo { @@ -61,4 +63,7 @@ protected void setNameSourceStart(int start) { this.nameStart= start; } + protected ISourceRange getNameRange() { + return new SourceRange(this.nameStart, this.nameEnd - this.nameStart + 1); + } } Index: model/org/eclipse/jdt/internal/core/CompilationUnitStructureRequestor.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/CompilationUnitStructureRequestor.java,v retrieving revision 1.86 diff -u -r1.86 CompilationUnitStructureRequestor.java --- model/org/eclipse/jdt/internal/core/CompilationUnitStructureRequestor.java 10 Nov 2009 16:53:03 -0000 1.86 +++ model/org/eclipse/jdt/internal/core/CompilationUnitStructureRequestor.java 27 Jul 2010 20:39:46 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation 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 @@ -125,7 +125,7 @@ /** * @see ISourceElementRequestor */ -public void acceptImport(int declarationStart, int declarationEnd, char[][] tokens, boolean onDemand, int modifiers) { +public void acceptImport(int declarationStart, int declarationEnd, int nameSourceStart, int nameSourceEnd, char[][] tokens, boolean onDemand, int modifiers) { JavaElement parentHandle= (JavaElement) this.handleStack.peek(); if (!(parentHandle.getElementType() == IJavaElement.COMPILATION_UNIT)) { Assert.isTrue(false); // Should not happen @@ -148,6 +148,8 @@ ImportDeclarationElementInfo info = new ImportDeclarationElementInfo(); info.setSourceRangeStart(declarationStart); info.setSourceRangeEnd(declarationEnd); + info.setNameSourceStart(nameSourceStart); + info.setNameSourceEnd(nameSourceEnd); info.setFlags(modifiers); addToChildren(this.importContainerInfo, handle); @@ -184,6 +186,8 @@ AnnotatableInfo info = new AnnotatableInfo(); info.setSourceRangeStart(importReference.declarationSourceStart); info.setSourceRangeEnd(importReference.declarationSourceEnd); + info.setNameSourceStart(importReference.sourceStart); + info.setNameSourceEnd(importReference.sourceEnd); addToChildren(parentInfo, handle); this.newElements.put(handle, info); Index: model/org/eclipse/jdt/internal/core/ImportDeclaration.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ImportDeclaration.java,v retrieving revision 1.40 diff -u -r1.40 ImportDeclaration.java --- model/org/eclipse/jdt/internal/core/ImportDeclaration.java 7 Mar 2009 01:08:07 -0000 1.40 +++ model/org/eclipse/jdt/internal/core/ImportDeclaration.java 27 Jul 2010 20:39:46 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation 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 @@ -77,6 +77,10 @@ Assert.isTrue(false, "Should not be called"); //$NON-NLS-1$ return 0; } +public ISourceRange getNameRange() throws JavaModelException { + ImportDeclarationElementInfo info = (ImportDeclarationElementInfo) getElementInfo(); + return info.getNameRange(); +} /* * @see JavaElement#getPrimaryElement(boolean) */ Index: model/org/eclipse/jdt/internal/core/ImportDeclarationElementInfo.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ImportDeclarationElementInfo.java,v retrieving revision 1.11 diff -u -r1.11 ImportDeclarationElementInfo.java --- model/org/eclipse/jdt/internal/core/ImportDeclarationElementInfo.java 7 Mar 2009 01:08:07 -0000 1.11 +++ model/org/eclipse/jdt/internal/core/ImportDeclarationElementInfo.java 27 Jul 2010 20:39:46 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation 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 @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core; +import org.eclipse.jdt.core.ISourceRange; +import org.eclipse.jdt.core.SourceRange; import org.eclipse.jdt.internal.compiler.env.ISourceImport; /** @@ -18,5 +20,34 @@ */ public class ImportDeclarationElementInfo extends MemberElementInfo implements ISourceImport{ - // empty element info + /** + * The start position of this import declaration's name in the its + * openable's buffer. + */ + protected int nameStart= -1; + + /** + * The last position of this import declaration's name in the its + * openable's buffer. + */ + protected int nameEnd= -1; + + /** + * Sets the last position of this import declaration's name, relative + * to its openable's source buffer. + */ + protected void setNameSourceEnd(int end) { + this.nameEnd= end; + } + /** + * Sets the start position of this import declaration's name, relative + * to its openable's source buffer. + */ + protected void setNameSourceStart(int start) { + this.nameStart= start; + } + + protected ISourceRange getNameRange() { + return new SourceRange(this.nameStart, this.nameEnd - this.nameStart + 1); + } } Index: model/org/eclipse/jdt/internal/core/PackageDeclaration.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/PackageDeclaration.java,v retrieving revision 1.31 diff -u -r1.31 PackageDeclaration.java --- model/org/eclipse/jdt/internal/core/PackageDeclaration.java 27 Jun 2008 16:03:51 -0000 1.31 +++ model/org/eclipse/jdt/internal/core/PackageDeclaration.java 27 Jul 2010 20:39:46 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation 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 @@ -11,7 +11,6 @@ package org.eclipse.jdt.internal.core; import org.eclipse.jdt.core.*; -import org.eclipse.jdt.core.IPackageDeclaration; /** * @see IPackageDeclaration @@ -44,6 +43,13 @@ protected char getHandleMementoDelimiter() { return JavaElement.JEM_PACKAGEDECLARATION; } +/** + * @see IPackageDeclaration#getNameRange() + */ +public ISourceRange getNameRange() throws JavaModelException { + AnnotatableInfo info = (AnnotatableInfo) getElementInfo(); + return info.getNameRange(); +} /* * @see JavaElement#getPrimaryElement(boolean) */ Index: model/org/eclipse/jdt/internal/core/SourceMapper.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SourceMapper.java,v retrieving revision 1.149 diff -u -r1.149 SourceMapper.java --- model/org/eclipse/jdt/internal/core/SourceMapper.java 10 Dec 2009 16:00:06 -0000 1.149 +++ model/org/eclipse/jdt/internal/core/SourceMapper.java 27 Jul 2010 20:39:46 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation 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 @@ -220,6 +220,8 @@ public void acceptImport( int declarationStart, int declarationEnd, + int nameStart, + int nameEnd, char[][] tokens, boolean onDemand, int modifiers) { Index: model/org/eclipse/jdt/internal/core/jdom/SimpleDOMBuilder.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/jdom/SimpleDOMBuilder.java,v retrieving revision 1.50 diff -u -r1.50 SimpleDOMBuilder.java --- model/org/eclipse/jdt/internal/core/jdom/SimpleDOMBuilder.java 27 Jun 2008 16:04:07 -0000 1.50 +++ model/org/eclipse/jdt/internal/core/jdom/SimpleDOMBuilder.java 27 Jul 2010 20:39:46 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation 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 @@ -39,7 +39,7 @@ // nothing to do } -public void acceptImport(int declarationStart, int declarationEnd, char[][] tokens, boolean onDemand, int modifiers) { +public void acceptImport(int declarationStart, int declarationEnd, int nameStart, int nameEnd, char[][] tokens, boolean onDemand, int modifiers) { int[] sourceRange = {declarationStart, declarationEnd}; String importName = new String(CharOperation.concatWith(tokens, '.')); /** name is set to contain the '*' */ Index: search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexerRequestor.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexerRequestor.java,v retrieving revision 1.48 diff -u -r1.48 SourceIndexerRequestor.java --- search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexerRequestor.java 16 Jan 2009 14:29:29 -0000 1.48 +++ search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexerRequestor.java 27 Jul 2010 20:39:46 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation 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 @@ -74,9 +74,9 @@ this.indexer.addFieldReference(fieldName); } /** - * @see ISourceElementRequestor#acceptImport(int, int, char[][], boolean, int) + * @see ISourceElementRequestor#acceptImport(int, int, int, int, char[][], boolean, int) */ -public void acceptImport(int declarationStart, int declarationEnd, char[][] tokens, boolean onDemand, int modifiers) { +public void acceptImport(int declarationStart, int declarationEnd, int nameStart, int nameEnd, char[][] tokens, boolean onDemand, int modifiers) { // imports have already been reported while creating the ImportRef node (see SourceElementParser#comsume*ImportDeclarationName() methods) } /** #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/parser/SourceElementParserTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/SourceElementParserTest.java,v retrieving revision 1.46 diff -u -r1.46 SourceElementParserTest.java --- src/org/eclipse/jdt/core/tests/compiler/parser/SourceElementParserTest.java 11 May 2010 18:53:51 -0000 1.46 +++ src/org/eclipse/jdt/core/tests/compiler/parser/SourceElementParserTest.java 27 Jul 2010 20:39:47 -0000 @@ -93,6 +93,8 @@ public void acceptImport( int declarationStart, int declarationEnd, + int nameStart, + int nameEnd, char[][] tokens, boolean onDemand, int modifiers) { Index: src/org/eclipse/jdt/core/tests/compiler/parser/TestSourceElementRequestor.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/parser/TestSourceElementRequestor.java,v retrieving revision 1.22 diff -u -r1.22 TestSourceElementRequestor.java --- src/org/eclipse/jdt/core/tests/compiler/parser/TestSourceElementRequestor.java 27 May 2008 23:53:59 -0000 1.22 +++ src/org/eclipse/jdt/core/tests/compiler/parser/TestSourceElementRequestor.java 27 Jul 2010 20:39:47 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation 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 @@ -41,7 +41,7 @@ /** * acceptImport method comment. */ -public void acceptImport(int declarationStart, int declarationEnd, char[][] tokens, boolean onDemand, int modifiers) {} +public void acceptImport(int declarationStart, int declarationEnd, int nameStart, int nameEnd, char[][] tokens, boolean onDemand, int modifiers) {} /** * acceptLineSeparatorPositions method comment. */ #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java,v retrieving revision 1.240 diff -u -r1.240 AbstractJavaModelTests.java --- src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java 28 Jun 2010 13:28:41 -0000 1.240 +++ src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java 27 Jul 2010 20:39:47 -0000 @@ -1938,6 +1938,12 @@ case IJavaElement.ANNOTATION: nameRange = ((IAnnotation) element).getNameRange(); break; + case IJavaElement.PACKAGE_DECLARATION : + nameRange = ((IPackageDeclaration) element).getNameRange(); + break; + case IJavaElement.IMPORT_DECLARATION : + nameRange = ((IImportDeclaration) element).getNameRange(); + break; default: nameRange = ((IMember) element).getNameRange(); break; Index: src/org/eclipse/jdt/core/tests/model/GetSourceTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/GetSourceTests.java,v retrieving revision 1.27 diff -u -r1.27 GetSourceTests.java --- src/org/eclipse/jdt/core/tests/model/GetSourceTests.java 28 Apr 2009 17:46:10 -0000 1.27 +++ src/org/eclipse/jdt/core/tests/model/GetSourceTests.java 27 Jul 2010 20:39:47 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation 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 @@ -476,6 +476,54 @@ } /* + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=150980 + */ + public void testNameRange09() throws CoreException { // was testNameRangeAnonymous + try { + String cuSource = + "package p . q . r. s ;\n" + + "public class Y {\n" + + " void foo() {\n" + + " Y y = new Y() {};\n" + + " class C {\n" + + " }\n"+ + " }\n" + + "}"; + createFolder("/P/p/q/r/s/"); + createFile("/P/p/q/r/s/Y.java", cuSource); + final IPackageDeclaration[] packageDeclarations = getCompilationUnit("/P/p/q/r/s/Y.java").getPackageDeclarations(); + assertEquals("Wrong size", 1, packageDeclarations.length); + + String actualSource = getNameSource(cuSource, packageDeclarations[0]); + String expectedSource = "p . q . r. s"; + assertSourceEquals("Unexpected source'", expectedSource, actualSource); + } finally { + deleteFile("/P/p/q/r/s/Y.java"); + } + } + + /* + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=150980 + */ + public void testNameRange10() throws CoreException { // was testNameRangeAnonymous + try { + String cuSource = + "import java . lang . * ;\n" + + "public class Y {\n" + + "}"; + createFile("/P/Y.java", cuSource); + final IImportDeclaration[] imports = getCompilationUnit("/P/Y.java").getImports(); + assertEquals("Wrong size", 1, imports.length); + + String actualSource = getNameSource(cuSource, imports[0]); + String expectedSource = "java . lang"; + assertSourceEquals("Unexpected source'", expectedSource, actualSource); + } finally { + deleteFile("/P/Y.java"); + } + } + + /* * Ensures that the source range for an annotation on a local variable is correct. * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=209823) */