View | Details | Raw Unified | Return to bug 150980 | Differences between
and this patch

Collapse All | Expand All

(-)model/org/eclipse/jdt/core/IImportDeclaration.java (-1 / +15 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 46-49 Link Here
46
 * @return true if the import is on-demand, false otherwise
46
 * @return true if the import is on-demand, false otherwise
47
 */
47
 */
48
boolean isOnDemand();
48
boolean isOnDemand();
49
50
/**
51
 * Returns the source range of this import declaration's name,
52
 * or <code>null</code> if this import declaration does not have
53
 * associated source code (for example, a binary type).
54
 *
55
 * @exception JavaModelException if this element does not exist or if an
56
 *      exception occurs while accessing its corresponding resource.
57
 * @return the source range of this import declaration's name,
58
 * or <code>null</code> if this import declaration does not have
59
 * associated source code (for example, a binary type)
60
 * @since 3.7
61
 */
62
ISourceRange getNameRange() throws JavaModelException;
49
}
63
}
(-)model/org/eclipse/jdt/core/IPackageDeclaration.java (-1 / +15 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 24-27 Link Here
24
 * @return the name of the package the statement
24
 * @return the name of the package the statement
25
 */
25
 */
26
String getElementName();
26
String getElementName();
27
/**
28
 * Returns the source range of this package declaration's name,
29
 * or <code>null</code> if this package declaration does not have
30
 * associated source code (for example, a binary type).
31
 *
32
 * @exception JavaModelException if this element does not exist or if an
33
 *      exception occurs while accessing its corresponding resource.
34
 * @return the source range of this package declaration's name,
35
 * or <code>null</code> if this package declaration does not have
36
 * associated source code (for example, a binary type)
37
 * @since 3.7
38
 */
39
ISourceRange getNameRange() throws JavaModelException;
40
27
}
41
}
(-)model/org/eclipse/jdt/internal/compiler/ISourceElementRequestor.java (-2 / +8 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 120-125 Link Here
120
	 * @param declarationEnd
120
	 * @param declarationEnd
121
	 *                   This is the position of the ';' ending the import statement or
121
	 *                   This is the position of the ';' ending the import statement or
122
	 *                   the end of the comment following the import.
122
	 *                   the end of the comment following the import.
123
	 * @param nameStart
124
	 *                   This is the position of the first character of the import declaration's
125
	 *                   name.
126
	 * @param nameEnd
127
	 *                   This is the position of the last character of the import declaration's
128
	 *                   name.
123
	 * @param tokens
129
	 * @param tokens
124
	 *                   This are the tokens of the import like specified in the source.
130
	 *                   This are the tokens of the import like specified in the source.
125
	 * @param onDemand
131
	 * @param onDemand
Lines 128-134 Link Here
128
	 * @param modifiers
134
	 * @param modifiers
129
	 *                   can be set to static from 1.5 on.
135
	 *                   can be set to static from 1.5 on.
130
	 */
136
	 */
131
	void acceptImport(int declarationStart, int declarationEnd, char[][] tokens, boolean onDemand, int modifiers);
137
	void acceptImport(int declarationStart, int declarationEnd, int nameStart, int nameEnd, char[][] tokens, boolean onDemand, int modifiers);
132
138
133
	/*
139
	/*
134
	 * Table of line separator position. This table is passed once at the end of
140
	 * Table of line separator position. This table is passed once at the end of
(-)model/org/eclipse/jdt/internal/compiler/SourceElementNotifier.java (-1 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2008, 2009 IBM Corporation and others.
2
 * Copyright (c) 2008, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 546-551 Link Here
546
		this.requestor.acceptImport(
546
		this.requestor.acceptImport(
547
			importReference.declarationSourceStart,
547
			importReference.declarationSourceStart,
548
			importReference.declarationSourceEnd,
548
			importReference.declarationSourceEnd,
549
			importReference.sourceStart,
550
			importReference.sourceEnd,
549
			importReference.tokens,
551
			importReference.tokens,
550
			(importReference.bits & ASTNode.OnDemand) != 0,
552
			(importReference.bits & ASTNode.OnDemand) != 0,
551
			importReference.modifiers);
553
			importReference.modifiers);
(-)model/org/eclipse/jdt/internal/compiler/SourceElementRequestorAdapter.java (-2 / +4 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 51-61 Link Here
51
	}
51
	}
52
52
53
	/**
53
	/**
54
	 * @see ISourceElementRequestor#acceptImport(int, int, char[][], boolean, int)
54
	 * @see ISourceElementRequestor#acceptImport(int, int, int, int, char[][], boolean, int)
55
	 */
55
	 */
56
	public void acceptImport(
56
	public void acceptImport(
57
		int declarationStart,
57
		int declarationStart,
58
		int declarationEnd,
58
		int declarationEnd,
59
		int nameStart,
60
		int nameEnd,
59
		char[][] tokens,
61
		char[][] tokens,
60
		boolean onDemand,
62
		boolean onDemand,
61
		int modifiers) {
63
		int modifiers) {
(-)model/org/eclipse/jdt/internal/core/AnnotatableInfo.java (-1 / +6 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 11-16 Link Here
11
package org.eclipse.jdt.internal.core;
11
package org.eclipse.jdt.internal.core;
12
12
13
import org.eclipse.jdt.core.IAnnotation;
13
import org.eclipse.jdt.core.IAnnotation;
14
import org.eclipse.jdt.core.ISourceRange;
15
import org.eclipse.jdt.core.SourceRange;
14
16
15
public class AnnotatableInfo extends MemberElementInfo {
17
public class AnnotatableInfo extends MemberElementInfo {
16
18
Lines 61-64 Link Here
61
	protected void setNameSourceStart(int start) {
63
	protected void setNameSourceStart(int start) {
62
		this.nameStart= start;
64
		this.nameStart= start;
63
	}
65
	}
66
	protected ISourceRange getNameRange() {
67
		return new SourceRange(this.nameStart, this.nameEnd - this.nameStart + 1);
68
	}
64
}
69
}
(-)model/org/eclipse/jdt/internal/core/CompilationUnitStructureRequestor.java (-2 / +6 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 125-131 Link Here
125
/**
125
/**
126
 * @see ISourceElementRequestor
126
 * @see ISourceElementRequestor
127
 */
127
 */
128
public void acceptImport(int declarationStart, int declarationEnd, char[][] tokens, boolean onDemand, int modifiers) {
128
public void acceptImport(int declarationStart, int declarationEnd, int nameSourceStart, int nameSourceEnd, char[][] tokens, boolean onDemand, int modifiers) {
129
	JavaElement parentHandle= (JavaElement) this.handleStack.peek();
129
	JavaElement parentHandle= (JavaElement) this.handleStack.peek();
130
	if (!(parentHandle.getElementType() == IJavaElement.COMPILATION_UNIT)) {
130
	if (!(parentHandle.getElementType() == IJavaElement.COMPILATION_UNIT)) {
131
		Assert.isTrue(false); // Should not happen
131
		Assert.isTrue(false); // Should not happen
Lines 148-153 Link Here
148
	ImportDeclarationElementInfo info = new ImportDeclarationElementInfo();
148
	ImportDeclarationElementInfo info = new ImportDeclarationElementInfo();
149
	info.setSourceRangeStart(declarationStart);
149
	info.setSourceRangeStart(declarationStart);
150
	info.setSourceRangeEnd(declarationEnd);
150
	info.setSourceRangeEnd(declarationEnd);
151
	info.setNameSourceStart(nameSourceStart);
152
	info.setNameSourceEnd(nameSourceEnd);
151
	info.setFlags(modifiers);
153
	info.setFlags(modifiers);
152
154
153
	addToChildren(this.importContainerInfo, handle);
155
	addToChildren(this.importContainerInfo, handle);
Lines 184-189 Link Here
184
		AnnotatableInfo info = new AnnotatableInfo();
186
		AnnotatableInfo info = new AnnotatableInfo();
185
		info.setSourceRangeStart(importReference.declarationSourceStart);
187
		info.setSourceRangeStart(importReference.declarationSourceStart);
186
		info.setSourceRangeEnd(importReference.declarationSourceEnd);
188
		info.setSourceRangeEnd(importReference.declarationSourceEnd);
189
		info.setNameSourceStart(importReference.sourceStart);
190
		info.setNameSourceEnd(importReference.sourceEnd);
187
191
188
		addToChildren(parentInfo, handle);
192
		addToChildren(parentInfo, handle);
189
		this.newElements.put(handle, info);
193
		this.newElements.put(handle, info);
(-)model/org/eclipse/jdt/internal/core/ImportDeclaration.java (-1 / +5 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 77-82 Link Here
77
	Assert.isTrue(false, "Should not be called"); //$NON-NLS-1$
77
	Assert.isTrue(false, "Should not be called"); //$NON-NLS-1$
78
	return 0;
78
	return 0;
79
}
79
}
80
public ISourceRange getNameRange() throws JavaModelException {
81
	ImportDeclarationElementInfo info = (ImportDeclarationElementInfo) getElementInfo();
82
	return info.getNameRange();
83
}
80
/*
84
/*
81
 * @see JavaElement#getPrimaryElement(boolean)
85
 * @see JavaElement#getPrimaryElement(boolean)
82
 */
86
 */
(-)model/org/eclipse/jdt/internal/core/ImportDeclarationElementInfo.java (-2 / +33 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.core;
11
package org.eclipse.jdt.internal.core;
12
12
13
import org.eclipse.jdt.core.ISourceRange;
14
import org.eclipse.jdt.core.SourceRange;
13
import org.eclipse.jdt.internal.compiler.env.ISourceImport;
15
import org.eclipse.jdt.internal.compiler.env.ISourceImport;
14
16
15
/**
17
/**
Lines 18-22 Link Here
18
 */
20
 */
19
public class ImportDeclarationElementInfo extends MemberElementInfo implements ISourceImport{
21
public class ImportDeclarationElementInfo extends MemberElementInfo implements ISourceImport{
20
22
21
	// empty element info
23
	/**
24
	 * The start position of this import declaration's name in the its
25
	 * openable's buffer.
26
	 */
27
	protected int nameStart= -1;
28
29
	/**
30
	 * The last position of this import declaration's name in the its
31
	 * openable's buffer.
32
	 */
33
	protected int nameEnd= -1;
34
35
	/**
36
	 * Sets the last position of this import declaration's name, relative
37
	 * to its openable's source buffer.
38
	 */
39
	protected void setNameSourceEnd(int end) {
40
		this.nameEnd= end;
41
	}
42
	/**
43
	 * Sets the start position of this import declaration's name, relative
44
	 * to its openable's source buffer.
45
	 */
46
	protected void setNameSourceStart(int start) {
47
		this.nameStart= start;
48
	}
49
50
	protected ISourceRange getNameRange() {
51
		return new SourceRange(this.nameStart, this.nameEnd - this.nameStart + 1);
52
	}
22
}
53
}
(-)model/org/eclipse/jdt/internal/core/PackageDeclaration.java (-2 / +8 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 11-17 Link Here
11
package org.eclipse.jdt.internal.core;
11
package org.eclipse.jdt.internal.core;
12
12
13
import org.eclipse.jdt.core.*;
13
import org.eclipse.jdt.core.*;
14
import org.eclipse.jdt.core.IPackageDeclaration;
15
14
16
/**
15
/**
17
 * @see IPackageDeclaration
16
 * @see IPackageDeclaration
Lines 44-49 Link Here
44
protected char getHandleMementoDelimiter() {
43
protected char getHandleMementoDelimiter() {
45
	return JavaElement.JEM_PACKAGEDECLARATION;
44
	return JavaElement.JEM_PACKAGEDECLARATION;
46
}
45
}
46
/**
47
 * @see IPackageDeclaration#getNameRange()
48
 */
49
public ISourceRange getNameRange() throws JavaModelException {
50
	AnnotatableInfo info = (AnnotatableInfo) getElementInfo();
51
	return info.getNameRange();
52
}
47
/*
53
/*
48
 * @see JavaElement#getPrimaryElement(boolean)
54
 * @see JavaElement#getPrimaryElement(boolean)
49
 */
55
 */
(-)model/org/eclipse/jdt/internal/core/SourceMapper.java (-1 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 220-225 Link Here
220
	public void acceptImport(
220
	public void acceptImport(
221
			int declarationStart,
221
			int declarationStart,
222
			int declarationEnd,
222
			int declarationEnd,
223
			int nameStart,
224
			int nameEnd,
223
			char[][] tokens,
225
			char[][] tokens,
224
			boolean onDemand,
226
			boolean onDemand,
225
			int modifiers) {
227
			int modifiers) {
(-)model/org/eclipse/jdt/internal/core/jdom/SimpleDOMBuilder.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 39-45 Link Here
39
	// nothing to do
39
	// nothing to do
40
}
40
}
41
41
42
public void acceptImport(int declarationStart, int declarationEnd, char[][] tokens, boolean onDemand, int modifiers) {
42
public void acceptImport(int declarationStart, int declarationEnd, int nameStart, int nameEnd, char[][] tokens, boolean onDemand, int modifiers) {
43
	int[] sourceRange = {declarationStart, declarationEnd};
43
	int[] sourceRange = {declarationStart, declarationEnd};
44
	String importName = new String(CharOperation.concatWith(tokens, '.'));
44
	String importName = new String(CharOperation.concatWith(tokens, '.'));
45
	/** name is set to contain the '*' */
45
	/** name is set to contain the '*' */
(-)search/org/eclipse/jdt/internal/core/search/indexing/SourceIndexerRequestor.java (-3 / +3 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 74-82 Link Here
74
	this.indexer.addFieldReference(fieldName);
74
	this.indexer.addFieldReference(fieldName);
75
}
75
}
76
/**
76
/**
77
 * @see ISourceElementRequestor#acceptImport(int, int, char[][], boolean, int)
77
 * @see ISourceElementRequestor#acceptImport(int, int, int, int, char[][], boolean, int)
78
 */
78
 */
79
public void acceptImport(int declarationStart, int declarationEnd, char[][] tokens, boolean onDemand, int modifiers) {
79
public void acceptImport(int declarationStart, int declarationEnd, int nameStart, int nameEnd, char[][] tokens, boolean onDemand, int modifiers) {
80
	// imports have already been reported while creating the ImportRef node (see SourceElementParser#comsume*ImportDeclarationName() methods)
80
	// imports have already been reported while creating the ImportRef node (see SourceElementParser#comsume*ImportDeclarationName() methods)
81
}
81
}
82
/**
82
/**
(-)src/org/eclipse/jdt/core/tests/compiler/parser/SourceElementParserTest.java (+2 lines)
Lines 93-98 Link Here
93
public void acceptImport(
93
public void acceptImport(
94
	int declarationStart,
94
	int declarationStart,
95
	int declarationEnd,
95
	int declarationEnd,
96
	int nameStart,
97
	int nameEnd,
96
	char[][] tokens,
98
	char[][] tokens,
97
	boolean onDemand,
99
	boolean onDemand,
98
	int modifiers) {
100
	int modifiers) {
(-)src/org/eclipse/jdt/core/tests/compiler/parser/TestSourceElementRequestor.java (-2 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 41-47 Link Here
41
/**
41
/**
42
 * acceptImport method comment.
42
 * acceptImport method comment.
43
 */
43
 */
44
public void acceptImport(int declarationStart, int declarationEnd, char[][] tokens, boolean onDemand, int modifiers) {}
44
public void acceptImport(int declarationStart, int declarationEnd, int nameStart, int nameEnd, char[][] tokens, boolean onDemand, int modifiers) {}
45
/**
45
/**
46
 * acceptLineSeparatorPositions method comment.
46
 * acceptLineSeparatorPositions method comment.
47
 */
47
 */
(-)src/org/eclipse/jdt/core/tests/model/AbstractJavaModelTests.java (+6 lines)
Lines 1938-1943 Link Here
1938
			case IJavaElement.ANNOTATION:
1938
			case IJavaElement.ANNOTATION:
1939
				nameRange = ((IAnnotation) element).getNameRange();
1939
				nameRange = ((IAnnotation) element).getNameRange();
1940
				break;
1940
				break;
1941
			case IJavaElement.PACKAGE_DECLARATION :
1942
				nameRange = ((IPackageDeclaration) element).getNameRange();
1943
				break;
1944
			case IJavaElement.IMPORT_DECLARATION :
1945
				nameRange = ((IImportDeclaration) element).getNameRange();
1946
				break;
1941
			default:
1947
			default:
1942
				nameRange = ((IMember) element).getNameRange();
1948
				nameRange = ((IMember) element).getNameRange();
1943
				break;
1949
				break;
(-)src/org/eclipse/jdt/core/tests/model/GetSourceTests.java (-1 / +49 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 476-481 Link Here
476
	}
476
	}
477
477
478
	/*
478
	/*
479
	 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=150980
480
	 */
481
	public void testNameRange09() throws CoreException { // was testNameRangeAnonymous
482
		try {
483
			String cuSource =
484
				"package p . q . r. s ;\n" +
485
				"public class Y {\n" +
486
				"  void foo() {\n" +
487
				"    Y y = new Y() {};\n" +
488
				"    class C {\n" +
489
				"    }\n"+
490
				"  }\n" +
491
				"}";
492
			createFolder("/P/p/q/r/s/");
493
			createFile("/P/p/q/r/s/Y.java", cuSource);
494
			final IPackageDeclaration[] packageDeclarations = getCompilationUnit("/P/p/q/r/s/Y.java").getPackageDeclarations();
495
			assertEquals("Wrong size", 1, packageDeclarations.length);
496
497
			String actualSource = getNameSource(cuSource, packageDeclarations[0]);
498
			String expectedSource = "p . q . r. s";
499
			assertSourceEquals("Unexpected source'", expectedSource, actualSource);
500
		} finally {
501
			deleteFile("/P/p/q/r/s/Y.java");
502
		}
503
	}
504
505
	/*
506
	 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=150980
507
	 */
508
	public void testNameRange10() throws CoreException { // was testNameRangeAnonymous
509
		try {
510
			String cuSource =
511
				"import java . lang . * ;\n" +
512
				"public class Y {\n" +
513
				"}";
514
			createFile("/P/Y.java", cuSource);
515
			final IImportDeclaration[] imports = getCompilationUnit("/P/Y.java").getImports();
516
			assertEquals("Wrong size", 1, imports.length);
517
518
			String actualSource = getNameSource(cuSource, imports[0]);
519
			String expectedSource = "java . lang";
520
			assertSourceEquals("Unexpected source'", expectedSource, actualSource);
521
		} finally {
522
			deleteFile("/P/Y.java");
523
		}
524
	}
525
526
	/*
479
	 * Ensures that the source range for an annotation on a local variable is correct.
527
	 * Ensures that the source range for an annotation on a local variable is correct.
480
	 * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=209823)
528
	 * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=209823)
481
	 */
529
	 */

Return to bug 150980