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

Collapse All | Expand All

(-)codeassist/org/eclipse/jdt/internal/codeassist/complete/CompletionOnPackageReference.java (-2 / +2 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 37-43 Link Here
37
37
38
public class CompletionOnPackageReference extends ImportReference {
38
public class CompletionOnPackageReference extends ImportReference {
39
public CompletionOnPackageReference(char[][] tokens , long[] positions) {
39
public CompletionOnPackageReference(char[][] tokens , long[] positions) {
40
	super(tokens, positions, true, ClassFileConstants.AccDefault);
40
	super(tokens, positions, false, ClassFileConstants.AccDefault);
41
}
41
}
42
public StringBuffer print(int indent, StringBuffer output, boolean withOnDemand) {
42
public StringBuffer print(int indent, StringBuffer output, boolean withOnDemand) {
43
43
(-)codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistParser.java (+4 lines)
Lines 717-722 Link Here
717
	/* build specific assist node on import statement */
717
	/* build specific assist node on import statement */
718
	ImportReference reference = createAssistImportReference(subset, positions, ClassFileConstants.AccStatic);
718
	ImportReference reference = createAssistImportReference(subset, positions, ClassFileConstants.AccStatic);
719
	reference.bits |= ASTNode.OnDemand;
719
	reference.bits |= ASTNode.OnDemand;
720
	// star end position
721
	reference.trailingStarPosition = this.intStack[this.intPtr--];
720
	this.assistNode = reference;
722
	this.assistNode = reference;
721
	this.lastCheckPoint = reference.sourceEnd + 1;
723
	this.lastCheckPoint = reference.sourceEnd + 1;
722
724
Lines 839-844 Link Here
839
	/* build specific assist node on import statement */
841
	/* build specific assist node on import statement */
840
	ImportReference reference = createAssistImportReference(subset, positions, ClassFileConstants.AccDefault);
842
	ImportReference reference = createAssistImportReference(subset, positions, ClassFileConstants.AccDefault);
841
	reference.bits |= ASTNode.OnDemand;
843
	reference.bits |= ASTNode.OnDemand;
844
	// star end position
845
	reference.trailingStarPosition = this.intStack[this.intPtr--];
842
	this.assistNode = reference;
846
	this.assistNode = reference;
843
	this.lastCheckPoint = reference.sourceEnd + 1;
847
	this.lastCheckPoint = reference.sourceEnd + 1;
844
848
(-)codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionOnPackageReference.java (-2 / +2 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 34-40 Link Here
34
34
35
public class SelectionOnPackageReference extends ImportReference {
35
public class SelectionOnPackageReference extends ImportReference {
36
public SelectionOnPackageReference(char[][] tokens , long[] positions) {
36
public SelectionOnPackageReference(char[][] tokens , long[] positions) {
37
	super(tokens, positions, true, ClassFileConstants.AccDefault);
37
	super(tokens, positions, false, ClassFileConstants.AccDefault);
38
}
38
}
39
public StringBuffer print(int tab, StringBuffer output, boolean withOnDemand) {
39
public StringBuffer print(int tab, StringBuffer output, boolean withOnDemand) {
40
	printIndent(tab, output).append("<SelectOnPackage:"); //$NON-NLS-1$
40
	printIndent(tab, output).append("<SelectOnPackage:"); //$NON-NLS-1$
(-)codeassist/org/eclipse/jdt/internal/codeassist/select/SelectionParser.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 939-944 Link Here
939
	/* build specific assist node on import statement */
939
	/* build specific assist node on import statement */
940
	ImportReference reference = createAssistImportReference(subset, positions, ClassFileConstants.AccStatic);
940
	ImportReference reference = createAssistImportReference(subset, positions, ClassFileConstants.AccStatic);
941
	reference.bits |= ASTNode.OnDemand;
941
	reference.bits |= ASTNode.OnDemand;
942
	// star end position
943
	reference.trailingStarPosition = this.intStack[this.intPtr--];
942
	this.assistNode = reference;
944
	this.assistNode = reference;
943
	this.lastCheckPoint = reference.sourceEnd + 1;
945
	this.lastCheckPoint = reference.sourceEnd + 1;
944
946
Lines 1020-1025 Link Here
1020
	/* build specific assist node on import statement */
1022
	/* build specific assist node on import statement */
1021
	ImportReference reference = createAssistImportReference(subset, positions, ClassFileConstants.AccDefault);
1023
	ImportReference reference = createAssistImportReference(subset, positions, ClassFileConstants.AccDefault);
1022
	reference.bits |= ASTNode.OnDemand;
1024
	reference.bits |= ASTNode.OnDemand;
1025
	// star end position
1026
	reference.trailingStarPosition = this.intStack[this.intPtr--];
1023
	this.assistNode = reference;
1027
	this.assistNode = reference;
1024
	this.lastCheckPoint = reference.sourceEnd + 1;
1028
	this.lastCheckPoint = reference.sourceEnd + 1;
1025
1029
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ImportReference.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 23-28 Link Here
23
	public int declarationSourceEnd;
23
	public int declarationSourceEnd;
24
	public int modifiers; // 1.5 addition for static imports
24
	public int modifiers; // 1.5 addition for static imports
25
	public Annotation[] annotations;
25
	public Annotation[] annotations;
26
	// star end position
27
	public int trailingStarPosition;
26
28
27
	public ImportReference(
29
	public ImportReference(
28
			char[][] tokens,
30
			char[][] tokens,
(-)compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java (-4 / +14 lines)
Lines 1834-1840 Link Here
1834
			}
1834
			}
1835
			break;
1835
			break;
1836
		case LESS :
1836
		case LESS :
1837
			this.intPtr--;
1837
		case MULTIPLY :
1838
			this.intPtr--; // star end position or starting position of angle bracket
1838
			this.expressionStack[this.expressionPtr] =
1839
			this.expressionStack[this.expressionPtr] =
1839
				new BinaryExpression(
1840
				new BinaryExpression(
1840
					expr1,
1841
					expr1,
Lines 1957-1963 Link Here
1957
			}
1958
			}
1958
			break;
1959
			break;
1959
		case LESS :
1960
		case LESS :
1960
			this.intPtr--;
1961
		case MULTIPLY :
1962
			this.intPtr--; // star end position or starting position of angle bracket
1961
			this.expressionStack[this.expressionPtr] =
1963
			this.expressionStack[this.expressionPtr] =
1962
				new BinaryExpression(
1964
				new BinaryExpression(
1963
					expr1,
1965
					expr1,
Lines 4891-4897 Link Here
4891
		0,
4893
		0,
4892
		length);
4894
		length);
4893
4895
4894
	impt = new ImportReference(tokens, positions, true, ClassFileConstants.AccDefault);
4896
	impt = new ImportReference(tokens, positions, false, ClassFileConstants.AccDefault);
4895
	this.compilationUnit.currentPackage = impt;
4897
	this.compilationUnit.currentPackage = impt;
4896
4898
4897
	if (this.currentToken == TokenNameSEMICOLON){
4899
	if (this.currentToken == TokenNameSEMICOLON){
Lines 4936-4942 Link Here
4936
	int packageModifiersSourceStart = this.intStack[this.intPtr--]; // we don't need the modifiers start
4938
	int packageModifiersSourceStart = this.intStack[this.intPtr--]; // we don't need the modifiers start
4937
	int packageModifiers = this.intStack[this.intPtr--];
4939
	int packageModifiers = this.intStack[this.intPtr--];
4938
4940
4939
	impt = new ImportReference(tokens, positions, true, packageModifiers);
4941
	impt = new ImportReference(tokens, positions, false, packageModifiers);
4940
	this.compilationUnit.currentPackage = impt;
4942
	this.compilationUnit.currentPackage = impt;
4941
	// consume annotations
4943
	// consume annotations
4942
	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
4944
	if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
Lines 7280-7285 Link Here
7280
	System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, 0, length);
7282
	System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, 0, length);
7281
	pushOnAstStack(impt = new ImportReference(tokens, positions, true, ClassFileConstants.AccStatic));
7283
	pushOnAstStack(impt = new ImportReference(tokens, positions, true, ClassFileConstants.AccStatic));
7282
7284
7285
	// star end position
7286
	impt.trailingStarPosition = this.intStack[this.intPtr--];
7283
	this.modifiers = ClassFileConstants.AccDefault;
7287
	this.modifiers = ClassFileConstants.AccDefault;
7284
	this.modifiersSourceStart = -1; // <-- see comment into modifiersFlag(int)
7288
	this.modifiersSourceStart = -1; // <-- see comment into modifiersFlag(int)
7285
7289
Lines 7663-7668 Link Here
7663
				}
7667
				}
7664
			}
7668
			}
7665
			break;
7669
			break;
7670
		case TokenNameMULTIPLY :
7671
			// star end position
7672
			pushOnIntStack(this.scanner.currentPosition - 1);
7673
			break;
7666
			//  case TokenNameCOMMA :
7674
			//  case TokenNameCOMMA :
7667
			//  case TokenNameCOLON  :
7675
			//  case TokenNameCOLON  :
7668
			//  case TokenNameLBRACKET  :
7676
			//  case TokenNameLBRACKET  :
Lines 7789-7794 Link Here
7789
	System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, 0, length);
7797
	System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, 0, length);
7790
	pushOnAstStack(impt = new ImportReference(tokens, positions, true, ClassFileConstants.AccDefault));
7798
	pushOnAstStack(impt = new ImportReference(tokens, positions, true, ClassFileConstants.AccDefault));
7791
7799
7800
	// star end position
7801
	impt.trailingStarPosition = this.intStack[this.intPtr--];
7792
	if (this.currentToken == TokenNameSEMICOLON){
7802
	if (this.currentToken == TokenNameSEMICOLON){
7793
		impt.declarationSourceEnd = this.scanner.currentPosition - 1;
7803
		impt.declarationSourceEnd = this.scanner.currentPosition - 1;
7794
	} else {
7804
	} else {
(-)model/org/eclipse/jdt/core/IImportDeclaration.java (-1 / +18 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
 * <p>The source range for the name includes the trailing '*' if the import declaration
56
 * .</p>
57
 *
58
 * @exception JavaModelException if this element does not exist or if an
59
 *      exception occurs while accessing its corresponding resource.
60
 * @return the source range of this import declaration's name,
61
 * or <code>null</code> if this import declaration does not have
62
 * associated source code (for example, a binary type)
63
 * @since 3.7
64
 */
65
ISourceRange getNameRange() throws JavaModelException;
49
}
66
}
(-)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 (-2 / +5 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 543-553 Link Here
543
	if (isPackage) {
543
	if (isPackage) {
544
		this.requestor.acceptPackage(importReference);
544
		this.requestor.acceptPackage(importReference);
545
	} else {
545
	} else {
546
		final boolean onDemand = (importReference.bits & ASTNode.OnDemand) != 0;
546
		this.requestor.acceptImport(
547
		this.requestor.acceptImport(
547
			importReference.declarationSourceStart,
548
			importReference.declarationSourceStart,
548
			importReference.declarationSourceEnd,
549
			importReference.declarationSourceEnd,
550
			importReference.sourceStart,
551
			onDemand ? importReference.trailingStarPosition : importReference.sourceEnd,
549
			importReference.tokens,
552
			importReference.tokens,
550
			(importReference.bits & ASTNode.OnDemand) != 0,
553
			onDemand,
551
			importReference.modifiers);
554
			importReference.modifiers);
552
	}
555
	}
553
}
556
}
(-)model/org/eclipse/jdt/internal/compiler/SourceElementParser.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 631-636 Link Here
631
	System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, 0, length);
631
	System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, 0, length);
632
	pushOnAstStack(impt = new ImportReference(tokens, positions, true, ClassFileConstants.AccStatic));
632
	pushOnAstStack(impt = new ImportReference(tokens, positions, true, ClassFileConstants.AccStatic));
633
633
634
	// star end position
635
	impt.trailingStarPosition = this.intStack[this.intPtr--];
634
	this.modifiers = ClassFileConstants.AccDefault;
636
	this.modifiers = ClassFileConstants.AccDefault;
635
	this.modifiersSourceStart = -1; // <-- see comment into modifiersFlag(int)
637
	this.modifiersSourceStart = -1; // <-- see comment into modifiersFlag(int)
636
638
Lines 675-680 Link Here
675
	System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, 0, length);
677
	System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, 0, length);
676
	pushOnAstStack(impt = new ImportReference(tokens, positions, true, ClassFileConstants.AccDefault));
678
	pushOnAstStack(impt = new ImportReference(tokens, positions, true, ClassFileConstants.AccDefault));
677
679
680
	// star end position
681
	impt.trailingStarPosition = this.intStack[this.intPtr--];
678
	if (this.currentToken == TokenNameSEMICOLON){
682
	if (this.currentToken == TokenNameSEMICOLON){
679
		impt.declarationSourceEnd = this.scanner.currentPosition - 1;
683
		impt.declarationSourceEnd = this.scanner.currentPosition - 1;
680
	} else {
684
	} else {
(-)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 / +70 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
	/*
527
	 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=150980
528
	 */
529
	public void testNameRange11() throws CoreException { // was testNameRangeAnonymous
530
		try {
531
			String cuSource =
532
				"import java . lang  .  Object  ;\n" +
533
				"public class Y {\n" +
534
				"}";
535
			createFile("/P/Y.java", cuSource);
536
			final IImportDeclaration[] imports = getCompilationUnit("/P/Y.java").getImports();
537
			assertEquals("Wrong size", 1, imports.length);
538
539
			String actualSource = getNameSource(cuSource, imports[0]);
540
			String expectedSource = "java . lang  .  Object";
541
			assertSourceEquals("Unexpected source'", expectedSource, actualSource);
542
		} finally {
543
			deleteFile("/P/Y.java");
544
		}
545
	}
546
547
	/*
479
	 * Ensures that the source range for an annotation on a local variable is correct.
548
	 * 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)
549
	 * (regression test for https://bugs.eclipse.org/bugs/show_bug.cgi?id=209823)
481
	 */
550
	 */

Return to bug 150980