This commit was manufactured by cvs2svn to create tag
'v_0_129_16_(2_0_stream)'.
Sprout from master 2001-08-24 18:30:22 UTC Philipe Mulet <pmulet> 'Fix for 1GII07V'
Cherrypick from unlabeled-1.6.2 2001-08-29 20:55:11 UTC Philipe Mulet <pmulet> 'Fix for AST positions (1GITCCY, 1GIRQFW, 1GIRHRP, 1GIUTIZ)':
org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Argument.java
org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java
org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompoundAssignment.java
org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DefaultCase.java
org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LabeledStatement.java
org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/PostfixExpression.java
org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/PrefixExpression.java
org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetParser.java
org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaConventions.java
org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Buffer.java
Cherrypick from unlabeled-1.7.2 2001-08-29 20:55:13 UTC Philipe Mulet <pmulet> 'Fix for AST positions (1GITCCY, 1GIRQFW, 1GIRHRP, 1GIUTIZ)':
org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/SourceElementParser.java
org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Case.java
org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java
org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java
org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SearchPattern.java
Cherrypick from unlabeled-1.13.2 2001-08-29 20:55:14 UTC Philipe Mulet <pmulet> 'Fix for AST positions (1GITCCY, 1GIRQFW, 1GIRHRP, 1GIUTIZ)':
org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
Cherrypick from unlabeled-1.2.12 2001-08-29 08:28:33 UTC Philipe Mulet <pmulet> '*** empty log message ***':
org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProjectElementInfo.java
Cherrypick from unlabeled-1.28.2 2001-08-29 15:04:55 UTC Philipe Mulet <pmulet> 'Adding new PRs':
org.eclipse.jdt.core/changes.txt
Cherrypick from unlabeled-1.5.2 2001-08-29 20:55:12 UTC Philipe Mulet <pmulet> 'Fix for AST positions (1GITCCY, 1GIRQFW, 1GIRHRP, 1GIUTIZ)':
org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java
Cherrypick from unlabeled-1.9.2 2001-08-29 08:28:32 UTC Philipe Mulet <pmulet> '*** empty log message ***':
org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java
diff --git a/org.eclipse.jdt.core/changes.txt b/org.eclipse.jdt.core/changes.txt
index 1be915b..030d269 100644
--- a/org.eclipse.jdt.core/changes.txt
+++ b/org.eclipse.jdt.core/changes.txt
@@ -15,6 +15,24 @@
PRs Fixed in this Release (since 1.0NL stream)
==================================================================================
+1GFY02B: ITPJUI:ALL - Delete a method and saving introduces extra lines
+1GFOFMD: ITPJUI:WIN2000 - New class should have space between package and class decls
+1GI3R1I: ITPJCORE:WIN2000 - Compilation error evaluating super expression in debugger
+1GII07V: ITPJCORE:WIN2000 - CompilationUnitDeclaration.traverse doesn't call visitor.endVisit
+1GIR345: ITPJCORE:ALL - Indexer: NegativeArraySizeException
+1GIRC23: ITPJCORE:ALL - CodeFormatter brace on new line problem
+1GIT8SA: ITPJCORE:WIN2000 - AST: wrong sourceEnd if action is Block
+1GIUQVL: ITPJCORE:WINNT - IClassPathEntry: java doc incorrect
+1GIVGMH: ITPJUI:ALL - EC: Javadoc hoverhelp incorrectly uses first of multiple comments
+1GIYKSR: ITPJCORE:WIN2000 - Ast: FieldDeclaration.traverse implemeted differently
+1GI3ND5: ITPJCORE:WINNT - Potential optimization during IB problem generation
+1GFBVZH: ITPUI:WIN2000 - ArrayIndexOutOfBoundsException: Java editor
+1GI509E: ITPJCORE:WINNT - IJavaProject.getNonJavaResources returns java and class files
+1GI2WAW: ITPJCORE:WINNT - Too many results for default package
+1GHQZ9H: ITPJUI:ALL - Walkback doing a search
+1GGYT3S: ITPJCORE:WINNT - javaconventions::validatePackageName and default package
+1GF9856: ITPJCORE:WINNT - JM - JavaConventions::validateCompilationUnitName
+1GF822P: ITPJCORE:WIN2000 - NegativeArraySizeException in Parser
1GI6T4Y: ITPJCORE:WINNT - NPE in JavaModeManager retrieving workspace options
1GE4ILR: ITPJCORE:ALL - Eval - Evaluation in Binary Project fails
1GI3LLC: ITPJCORE:ALL - Incorrect formatting for the new keyword
@@ -48,6 +66,7 @@
PRs Fixed in 1.0NL stream (since 0.9)
==================================================================================
+1GIRQLA: ITPJCORE:ALL - ClassFormatError for local variable attribute
1GGCYEU: ITPJCORE:ALL - Using Ant for build skip files
1GH3218: ITPJUI:WIN - mnuemonic problems
1GGLLUG: ITPJCORE:WINNT - @deprecated does not work if it is followed by a TAB
@@ -75,6 +94,11 @@
PRs Closed in this Release
==================================================================================
+1GJ31GB: ITPJCORE:WINNT - Formatter - doesn't line up braces vertically when begin brace on new line
+1GIV9WS: ITPJCORE:WIN2000 - Unexpected compiler behavior
+1GI6VUI: ITPJCORE:WINNT - Source attachment not working anymore in 2.0 stream
+1GIF18T: ITPJCORE:WIN2000 - ArrayIndexOutOfBounds deleting text
+1GF2C3C: ITPJUI:Linux - New class wizard allows illegal character
1GGRCGZ: ITPJUI:WIN2000 - Can't rename/copy/move/delete default package
1GDRXHP: ITPDUI:WINNT - NPE inspecting local var
1G7RAO5: ITPJCORE:ALL - Java Model Core Tests: JavaProjectTests>>testProjectClose() has been removed
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/SourceElementParser.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/SourceElementParser.java
index 9a130fb..cbc20e1 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/SourceElementParser.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/SourceElementParser.java
@@ -467,30 +467,64 @@
*/
public void notifySourceElementRequestor() {
+ // collect the top level ast nodes
+ int length = 0;
+ AstNode[] nodes = null;
if (sourceType == null){
if (scanner.initialPosition == 0) {
requestor.enterCompilationUnit();
}
- // first we notify the package declaration
ImportReference currentPackage = compilationUnit.currentPackage;
- if (currentPackage != null) {
- notifySourceElementRequestor(currentPackage, true);
- }
- // then the imports
ImportReference[] imports = compilationUnit.imports;
+ TypeDeclaration[] types = compilationUnit.types;
+ length =
+ (currentPackage == null ? 0 : 1)
+ + (imports == null ? 0 : imports.length)
+ + (types == null ? 0 : types.length);
+ nodes = new AstNode[length];
+ int index = 0;
+ if (currentPackage != null) {
+ nodes[index++] = currentPackage;
+ }
if (imports != null) {
for (int i = 0, max = imports.length; i < max; i++) {
- notifySourceElementRequestor(imports[i], false);
+ nodes[index++] = imports[i];
+ }
+ }
+ if (types != null) {
+ for (int i = 0, max = types.length; i < max; i++) {
+ nodes[index++] = types[i];
+ }
+ }
+ } else {
+ TypeDeclaration[] types = compilationUnit.types;
+ if (types != null) {
+ length = types.length;
+ nodes = new AstNode[length];
+ for (int i = 0, max = types.length; i < max; i++) {
+ nodes[i] = types[i];
}
}
}
- // then the types contained by this compilation unit
- TypeDeclaration[] types = compilationUnit.types;
- if (types != null) {
- for (int i = 0, max = types.length; i < max; i++) {
- notifySourceElementRequestor(types[i], sourceType == null);
+
+ // notify the nodes in the syntactical order
+ if (nodes != null && length > 0) {
+ quickSort(nodes, 0, length-1);
+ for (int i=0;i<length;i++) {
+ AstNode node = nodes[i];
+ if (node instanceof ImportReference) {
+ ImportReference importRef = (ImportReference)node;
+ if (node == compilationUnit.currentPackage) {
+ notifySourceElementRequestor(importRef, true);
+ } else {
+ notifySourceElementRequestor(importRef, false);
+ }
+ } else { // instanceof TypeDeclaration
+ notifySourceElementRequestor((TypeDeclaration)node, sourceType == null);
+ }
}
}
+
if (sourceType == null){
if (scanner.eofPosition >= compilationUnit.sourceEnd) {
requestor.exitCompilationUnit(compilationUnit.sourceEnd);
@@ -873,6 +907,35 @@
diet = old;
}
}
+/**
+ * Sort the given ast nodes by their positions.
+ */
+private static void quickSort(AstNode[] sortedCollection, int left, int right) {
+ int original_left = left;
+ int original_right = right;
+ AstNode mid = sortedCollection[ (left + right) / 2];
+ do {
+ while (sortedCollection[left].sourceStart < mid.sourceStart) {
+ left++;
+ }
+ while (mid.sourceStart < sortedCollection[right].sourceStart) {
+ right--;
+ }
+ if (left <= right) {
+ AstNode tmp = sortedCollection[left];
+ sortedCollection[left] = sortedCollection[right];
+ sortedCollection[right] = tmp;
+ left++;
+ right--;
+ }
+ } while (left <= right);
+ if (original_left < right) {
+ quickSort(sortedCollection, original_left, right);
+ }
+ if (left < original_right) {
+ quickSort(sortedCollection, left, original_right);
+ }
+}
/*
* Answer a char array representation of the type name formatted like:
* - type name + dimensions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Argument.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Argument.java
index d78048d..547914e 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Argument.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Argument.java
@@ -10,7 +10,7 @@
public class Argument extends LocalDeclaration {
public Argument(char[] name , long posNom , TypeReference tr , int modifiers){
- super(null,name, (int) (posNom >>> 32), (int) (posNom & 0xFFFFFFFFL));
+ super(null,name, (int) (posNom >>> 32), (int) posNom);
this.modifiers = modifiers;
type = tr;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java
index aea7acd..9882e5b 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java
@@ -20,17 +20,18 @@
public AssertStatement(
Expression exceptionArgument,
Expression assertExpression,
- int startPosition) {
+ int sourceStart,
+ int sourceEnd) {
this.assertExpression = assertExpression;
this.exceptionArgument = exceptionArgument;
- sourceStart = startPosition;
- sourceEnd = exceptionArgument.sourceEnd;
+ this.sourceStart = sourceStart;
+ this.sourceEnd = sourceEnd;
}
- public AssertStatement(Expression assertExpression, int startPosition) {
+ public AssertStatement(Expression assertExpression, int sourceStart, int sourceEnd) {
this.assertExpression = assertExpression;
- sourceStart = startPosition;
- sourceEnd = assertExpression.sourceEnd;
+ this.sourceStart = sourceStart;
+ this.sourceEnd = sourceEnd;
}
public FlowInfo analyseCode(
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java
index e3d89aa..1385a5e 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Assignment.java
@@ -13,15 +13,15 @@
public class Assignment extends Expression {
public Reference lhs ;
public Expression expression ;
-public Assignment(Expression lhs, Expression expression) {
+public Assignment(Expression lhs, Expression expression, int sourceEnd) {
//lhs is always a reference by construction ,
//but is build as an expression ==> the checkcast cannot fail
this.lhs = (Reference) lhs;
this.expression = expression ;
- sourceStart = lhs.sourceStart;
- sourceEnd = expression.sourceEnd;
+ this.sourceStart = lhs.sourceStart;
+ this.sourceEnd = sourceEnd;
}
public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Case.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Case.java
index 09fabb4..9ae7c8f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Case.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/Case.java
@@ -13,10 +13,10 @@
public class Case extends Statement {
public Expression constantExpression;
public CaseLabel targetLabel;
-public Case(Expression constantExpression) {
+public Case(int sourceEnd, int sourceStart, Expression constantExpression) {
this.constantExpression = constantExpression;
- sourceEnd = constantExpression.sourceEnd;
- sourceStart = constantExpression.sourceStart;
+ this.sourceEnd = sourceEnd;
+ this.sourceStart = sourceStart;
}
public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompoundAssignment.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompoundAssignment.java
index fec4e8c..bdc7943 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompoundAssignment.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompoundAssignment.java
@@ -17,11 +17,11 @@
// var op exp is equivalent to var = (varType) var op exp
// assignmentImplicitConversion stores the cast needed for the assignment
-public CompoundAssignment(Expression lhs, Expression expression,int operator) {
+public CompoundAssignment(Expression lhs, Expression expression,int operator, int sourceEnd) {
//lhs is always a reference by construction ,
//but is build as an expression ==> the checkcast cannot fail
- super(lhs, expression);
+ super(lhs, expression, sourceEnd);
this.operator = operator ;
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java
index 70a97df..514e00a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java
@@ -18,12 +18,12 @@
int thenInitStateIndex = -1;
int elseInitStateIndex = -1;
int mergedInitStateIndex = -1;
-public ConditionalExpression(Expression condition, Expression valueIfTrue, Expression valueIfFalse) {
+public ConditionalExpression(Expression condition, Expression valueIfTrue, Expression valueIfFalse, int sourceEnd) {
this.condition = condition;
this.valueIfTrue = valueIfTrue;
this.valueIfFalse = valueIfFalse;
- sourceStart = condition.sourceStart ;
- sourceEnd = valueIfFalse.sourceEnd;
+ this.sourceStart = condition.sourceStart ;
+ this.sourceEnd = sourceEnd;
}
public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
Constant inlinedCondition = condition.constant;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DefaultCase.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DefaultCase.java
index b2c7d59..ffda316 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DefaultCase.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/DefaultCase.java
@@ -16,9 +16,9 @@
/**
* DefautCase constructor comment.
*/
-public DefaultCase(int startPosition) {
- this.sourceStart = startPosition ;
- this.sourceEnd = startPosition+6; //default.length-1 (good approximation)
+public DefaultCase(int sourceEnd, int sourceStart) {
+ this.sourceStart = sourceStart;
+ this.sourceEnd = sourceEnd;
}
public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
return flowInfo;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LabeledStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LabeledStatement.java
index b4e3c5a..3fca23c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LabeledStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LabeledStatement.java
@@ -21,10 +21,10 @@
* LabeledStatement constructor comment.
*/
public LabeledStatement(char[] l , Statement st, int s,int e) {
- statement = st ;
- label = l ;
- sourceStart = s;
- sourceEnd = e;
+ this.statement = st ;
+ this.label = l ;
+ this.sourceStart = s;
+ this.sourceEnd = e;
}
public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/PostfixExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/PostfixExpression.java
index 75dc122..ea4cc67 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/PostfixExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/PostfixExpression.java
@@ -12,9 +12,9 @@
public class PostfixExpression extends CompoundAssignment {
public PostfixExpression(Expression l, Expression e, int op, int pos) {
- super(l, e, op);
- sourceStart = l.sourceStart;
- sourceEnd = pos ;
+ super(l, e, op, pos);
+ this.sourceStart = l.sourceStart;
+ this.sourceEnd = pos ;
}
/**
* Code generation for PostfixExpression
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/PrefixExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/PrefixExpression.java
index df18a47..10f0d2f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/PrefixExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/PrefixExpression.java
@@ -15,10 +15,10 @@
* @param r org.eclipse.jdt.internal.compiler.ast.Expression
* @param op int
*/
-public PrefixExpression(Expression l, Expression e, int op, int pos) {
- super(l, e, op);
- sourceStart = pos;
- sourceEnd = l.sourceEnd;
+public PrefixExpression(Expression l, Expression e, int op, int pos, int sourceEnd) {
+ super(l, e, op, sourceEnd);
+ this.sourceStart = pos;
+ this.sourceEnd = sourceEnd;
}
public String operatorToString() {
switch (operator) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
index 1b916af..cf62f1e 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
@@ -967,7 +967,6 @@
//since jdk1.2 look only in the last java doc comment...
found : {
if ((lastAnnotationIndex = scanner.commentPtr) >= 0) { //look for @deprecated
- scanner.commentPtr = -1; // reset the comment stack, since not necessary after having checked
int commentSourceStart = scanner.commentStarts[lastAnnotationIndex];
// javadoc only (non javadoc comment have negative end positions.)
int commentSourceEnd = scanner.commentStops[lastAnnotationIndex] - 1; //stop is one over
@@ -998,7 +997,8 @@
}
// modify the modifier source start to point at the first comment
if (lastAnnotationIndex >= 0) {
- modifiersSourceStart = scanner.commentStarts[0];
+ modifiersSourceStart = scanner.commentStarts[scanner.commentPtr];
+ scanner.commentPtr = -1; // reset the comment stack, since not necessary after having checked
}
}
protected void classInstanceCreation(boolean alwaysQualified) {
@@ -1152,7 +1152,8 @@
protected void consumeAssertStatement() {
// AssertStatement ::= 'assert' Expression ':' Expression ';'
expressionLengthPtr-=2;
- pushOnAstStack(new AssertStatement(expressionStack[expressionPtr--], expressionStack[expressionPtr--], intStack[intPtr--]));
+ intPtr--; // remove the position pushed for the ':'
+ pushOnAstStack(new AssertStatement(expressionStack[expressionPtr--], expressionStack[expressionPtr--], intStack[intPtr--], endStatementPosition));
}
protected void consumeAssignment() {
@@ -1167,10 +1168,12 @@
new CompoundAssignment(
expressionStack[expressionPtr] ,
expressionStack[expressionPtr+1],
- op) :
+ op,
+ scanner.currentPosition) :
new Assignment(
expressionStack[expressionPtr] ,
- expressionStack[expressionPtr+1]);
+ expressionStack[expressionPtr+1],
+ scanner.currentPosition);
}
protected void consumeAssignmentOperator(int pos) {
// AssignmentOperator ::= '='
@@ -1291,7 +1294,7 @@
protected void consumeCaseLabel() {
// SwitchLabel ::= 'case' ConstantExpression ':'
expressionLengthPtr--;
- pushOnAstStack(new Case(expressionStack[expressionPtr--]));
+ pushOnAstStack(new Case(intStack[intPtr--], intStack[intPtr--], expressionStack[expressionPtr--]));
}
protected void consumeCastExpression() {
// CastExpression ::= PushLPAREN PrimitiveType Dimsopt PushRPAREN UnaryExpression
@@ -1526,11 +1529,13 @@
expressionPtr -= 2;
expressionLengthPtr -= 2;
+ intPtr--; // remove the position pushed for the ':'
expressionStack[expressionPtr] =
new ConditionalExpression(
expressionStack[expressionPtr],
expressionStack[expressionPtr + 1],
- expressionStack[expressionPtr + 2]);
+ expressionStack[expressionPtr + 2],
+ endStatementPosition);
}
protected void consumeConstructorBlockStatements() {
// ConstructorBody ::= NestedMethod '{' ExplicitConstructorInvocation BlockStatements '}'
@@ -1659,7 +1664,7 @@
}
protected void consumeDefaultLabel() {
// SwitchLabel ::= 'default' ':'
- pushOnAstStack(new DefaultCase(endPosition));
+ pushOnAstStack(new DefaultCase(intStack[intPtr--], intStack[intPtr--]));
}
protected void consumeDefaultModifiers() {
checkAnnotation(); // might update modifiers with AccDeprecated
@@ -1913,7 +1918,7 @@
variableDecl.initialization = expressionStack[expressionPtr--];
// we need to update the declarationSourceEnd of the local variable declaration to the
// source end position of the initialization expression
- variableDecl.declarationSourceEnd = variableDecl.initialization.sourceEnd;
+ variableDecl.declarationSourceEnd = scanner.currentPosition - 1;
}
protected void consumeExitVariableWithoutInitialization() {
// ExitVariableWithoutInitialization ::= $empty
@@ -3386,7 +3391,7 @@
protected void consumeSimpleAssertStatement() {
// AssertStatement ::= 'assert' Expression ';'
expressionLengthPtr--;
- pushOnAstStack(new AssertStatement(expressionStack[expressionPtr--], intStack[intPtr--]));
+ pushOnAstStack(new AssertStatement(expressionStack[expressionPtr--], intStack[intPtr--], endStatementPosition));
}
protected void consumeSingleTypeImportDeclaration() {
@@ -3583,7 +3588,7 @@
action,
scope,
intStack[intPtr--],
- endPosition));
+ endStatementPosition));
}
protected void consumeStatementIfNoElse() {
// IfThenStatement ::= 'if' '(' Expression ')' Statement
@@ -3597,7 +3602,7 @@
expressionStack[expressionPtr--],
Block.None,
intStack[intPtr--],
- endPosition);
+ endStatementPosition);
} else {
expressionLengthPtr--;
astStack[astPtr] =
@@ -3605,7 +3610,7 @@
expressionStack[expressionPtr--],
(Statement) astStack[astPtr],
intStack[intPtr--],
- endPosition);
+ endStatementPosition);
}
}
protected void consumeStatementIfWithElse() {
@@ -3624,7 +3629,7 @@
(Statement) astStack[astPtr],
(Statement) astStack[astPtr + 1],
intStack[intPtr--],
- endPosition);
+ endStatementPosition);
} else {
astLengthPtr--; //second decrement
expressionLengthPtr--;
@@ -3633,7 +3638,7 @@
(lengthT == 0) ? Block.None : (Statement) astStack[astPtr--],
(lengthE == 0) ? Block.None : (Statement) astStack[astPtr--],
intStack[intPtr--],
- endPosition));
+ endStatementPosition));
}
}
protected void consumeStatementLabel() {
@@ -3645,19 +3650,20 @@
if (astLengthStack[astLengthPtr] == 0) {
astLengthStack[astLengthPtr] = 1;
astStack[++astPtr] =
- new LabeledStatement(identifierStack[identifierPtr], Block.None, (int)
- (identifierPositionStack[identifierPtr--] >>> 32),
- endPosition);
+ new LabeledStatement(
+ identifierStack[identifierPtr],
+ Block.None,
+ (int) (identifierPositionStack[identifierPtr--] >>> 32),
+ endStatementPosition);
} else {
astStack[astPtr] =
new LabeledStatement(
identifierStack[identifierPtr],
(Statement) astStack[astPtr],
- (int)
- (identifierPositionStack[identifierPtr--] >>> 32),
- endPosition);
+ (int) (identifierPositionStack[identifierPtr--] >>> 32),
+ endStatementPosition);
}
-
+ intPtr--; // remove the position pushed for the ':'
identifierLengthPtr--;
}
protected void consumeStatementReturn() {
@@ -3713,16 +3719,16 @@
new SynchronizedStatement(
exp = expressionStack[expressionPtr--],
Block.None,
- exp.sourceStart,
- exp.sourceEnd);
+ intStack[intPtr--],
+ endStatementPosition);
} else {
expressionLengthPtr--;
astStack[astPtr] =
new SynchronizedStatement(
exp = expressionStack[expressionPtr--],
(Block) astStack[astPtr],
- exp.sourceStart,
- exp.sourceEnd);
+ intStack[intPtr--],
+ endStatementPosition);
}
resetModifiers();
}
@@ -3778,7 +3784,7 @@
expressionStack[expressionPtr--],
null,
intStack[intPtr--],
- endPosition);
+ endStatementPosition);
} else {
expressionLengthPtr--;
astStack[astPtr] =
@@ -3786,7 +3792,7 @@
expressionStack[expressionPtr--],
(Statement) astStack[astPtr],
intStack[intPtr--],
- endPosition);
+ endStatementPosition);
}
}
protected void consumeStaticInitializer() {
@@ -3898,6 +3904,7 @@
break;
case TokenNamesynchronized :
checkAndSetModifiers(AccSynchronized);
+ pushOnIntStack(scanner.startPosition);
break;
//==============================
@@ -4021,12 +4028,13 @@
case TokenNamecontinue :
case TokenNameclass :
case TokenNamereturn :
+ case TokenNamecase :
+ case TokenNameCOLON :
+ case TokenNamedefault :
pushOnIntStack(scanner.startPosition);
break;
-
//let extra semantic action decide when to push
- case TokenNamedefault :
case TokenNameRBRACKET :
case TokenNamePLUS_PLUS :
case TokenNameMINUS_MINUS :
@@ -4051,13 +4059,11 @@
break;
// case TokenNameQUESTION :
// case TokenNameCOMMA :
- // case TokenNameCOLON :
// case TokenNameEQUAL :
// case TokenNameLBRACKET :
// case TokenNameDOT :
// case TokenNameERROR :
// case TokenNameEOF :
- // case TokenNamecase :
// case TokenNamecatch :
// case TokenNameelse :
// case TokenNameextends :
@@ -4205,14 +4211,15 @@
leftHandSide,
IntLiteral.One,
op,
- endPosition + 1);
+ scanner.currentPosition - 1);
} else {
expressionStack[expressionPtr] =
new PrefixExpression(
leftHandSide,
IntLiteral.One,
op,
- intStack[intPtr--]);
+ intStack[intPtr--],
+ scanner.currentPosition - 1);
}
} else {
//the ++ or the -- is NOT taken into account if code gen proceeds
diff --git a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetParser.java b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetParser.java
index c841c05..0a79eab 100644
--- a/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetParser.java
+++ b/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetParser.java
@@ -274,7 +274,8 @@
for (int i = 0; i < varCount; i++){
finallyBlock.statements[i] = new Assignment(
new SingleNameReference(CharOperation.concat(LOCAL_VAR_PREFIX, this.evaluationContext.localVariableNames[i]), position),
- new SingleNameReference(this.evaluationContext.localVariableNames[i], position));
+ new SingleNameReference(this.evaluationContext.localVariableNames[i], position),
+ (int) position);
}
tryStatement.finallyBlock = finallyBlock;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaConventions.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaConventions.java
index 00aaca0..b846d75 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaConventions.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaConventions.java
@@ -116,7 +116,7 @@
String extension;
String identifier;
int index;
- index = name.indexOf('.');
+ index = name.lastIndexOf('.');
if (index == -1) {
return new Status(IStatus.ERROR, JavaCore.PLUGIN_ID, -1, Util.bind("convention.unit.notJavaName"), null); //$NON-NLS-1$
}
@@ -258,6 +258,9 @@
* <p>
* The syntax of a package name corresponds to PackageName as
* defined by PackageDeclaration (JLS2 7.4). For example, <code>"java.lang"</code>.
+ * <p>
+ * Note that the given name must be a non-empty package name (ie. attempting to
+ * validate the default package will return an error status.)
*
* @param name the name of a package
* @return a status object with code <code>IStatus.OK</code> if
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Buffer.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Buffer.java
index 2f6866a..05771da 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Buffer.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/Buffer.java
@@ -367,14 +367,20 @@
break;
case '\r':
lineLength = i-lineStart;
- line = new char[lineLength];
- System.arraycopy(text, lineStart, line, 0, lineLength);
- buffer.append(line);
- buffer.append(lineSeparator);
- if (nextChar == '\n') {
- nextChar = ' ';
+ if (lineLength >= 0) {
+ line = new char[lineLength];
+ System.arraycopy(text, lineStart, line, 0, lineLength);
+ buffer.append(line);
+ buffer.append(lineSeparator);
+ if (nextChar == '\n') {
+ nextChar = ' ';
+ }
+ lineStart = i+2;
+ } else {
+ // when line separator are mixed in the same file
+ // we need to prevent NegativeArraySizeException
+ lineStart = i+1;
}
- lineStart = i+2;
break;
}
}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProjectElementInfo.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProjectElementInfo.java
index 2faff79..10426bc 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProjectElementInfo.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaProjectElementInfo.java
@@ -60,6 +60,24 @@
* Compute the non-java resources contained in this java project.
*/
private Object[] computeNonJavaResources(JavaProject project) {
+ // determine if src == project and/or if bin == project
+ IPath projectPath = project.getProject().getFullPath();
+ boolean srcIsProject = false;
+ boolean binIsProject = false;
+ try {
+ IClasspathEntry[] classpath = project.getResolvedClasspath(true);
+ for (int i = 0; i < classpath.length; i++) {
+ IClasspathEntry entry = classpath[i];
+ if (projectPath.equals(entry.getPath())) {
+ srcIsProject = true;
+ break;
+ }
+ }
+ binIsProject = projectPath.equals(project.getOutputLocation());
+ } catch (JavaModelException e) {
+ // ignore
+ }
+
Object[] nonJavaResources = new IResource[5];
int nonJavaResourcesCounter = 0;
try {
@@ -68,10 +86,20 @@
IResource res = members[i];
switch (res.getType()) {
case IResource.FILE :
- String extension = res.getProjectRelativePath().getFileExtension();
// check if this file might be a jar or a zip inside the build path
IPath resFullPath = res.getFullPath();
if (project.findPackageFragmentRoot(resFullPath) == null) {
+ String extension = res.getFileExtension();
+ if (extension != null) extension = extension.toLowerCase();
+ // ignore .java file if src == project
+ if (srcIsProject && "java".equals(extension)) { //$NON-NLS-1$
+ break;
+ }
+ // ignore .class file if bin == project
+ if (binIsProject && "class".equals(extension)) { //$NON-NLS-1$
+ break;
+ }
+ // else add non java resource
if (nonJavaResources.length == nonJavaResourcesCounter) {
// resize
System.arraycopy(
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java
index 6f52cfd..aa947fd 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/indexing/BinaryIndexer.java
@@ -433,6 +433,10 @@
name = reader.getInnerSourceName();
char[] fullEnclosingName = reader.getEnclosingTypeName();
int nameLength = fullEnclosingName.length - packageNameIndex - 1;
+ if (nameLength <= 0) {
+ // See PR 1GIR345: ITPJCORE:ALL - Indexer: NegativeArraySizeException
+ return;
+ }
enclosingTypeName = new char[nameLength];
System.arraycopy(fullEnclosingName, packageNameIndex + 1, enclosingTypeName, 0, nameLength);
}
@@ -440,29 +444,11 @@
if (name == null) return;
char[][] superinterfaces = replace('/', '.', reader.getInterfaceNames());
- if (DEBUG) {
- if (packageName != null) {
- System.out.println("package name = " + new String(packageName)); //$NON-NLS-1$
- }
- if (name != null) {
- System.out.println("class name = " + new String(name)); //$NON-NLS-1$
- }
- if (superinterfaces != null) {
- for (int i = 0, max = superinterfaces.length; i < max; i++) {
- System.out.println("superinterfaces[" + i + "]= " + new String(superinterfaces[i])); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- }
char[][] enclosingTypeNames = enclosingTypeName == null ? null : new char[][] {enclosingTypeName};
if (reader.isInterface()) {
addInterfaceDeclaration(reader.getModifiers(), packageName, name, enclosingTypeNames, superinterfaces);
} else {
char[] superclass = replace('/', '.', reader.getSuperclassName());
- if (DEBUG) {
- if (superclass != null) {
- System.out.println("superclass name = " + new String(superclass)); //$NON-NLS-1$
- }
- }
addClassDeclaration(reader.getModifiers(), packageName, name, enclosingTypeNames, superclass, superinterfaces);
}
@@ -475,24 +461,6 @@
char[][] parameterTypes = decodeParameterTypes(descriptor);
char[] returnType = decodeReturnType(descriptor);
char[][] exceptionTypes = replace('/', '.', method.getExceptionTypeNames());
- if (DEBUG) {
- if (method.getSelector() != null) {
- System.out.println("method selector = " + new String(method.getSelector())); //$NON-NLS-1$
- }
- if (parameterTypes != null) {
- for (int j = 0, max2 = parameterTypes.length; j < max2; j++) {
- System.out.println("parameterTypes[" + j + "]= " + new String(parameterTypes[j])); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- if (returnType != null) {
- System.out.println("return type = " + new String(returnType)); //$NON-NLS-1$
- }
- if (exceptionTypes != null) {
- for (int j = 0, max2 = exceptionTypes.length; j < max2; j++) {
- System.out.println("exceptionTypes[" + j + "]= " + new String(exceptionTypes[j])); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- }
if (method.isConstructor()) {
addConstructorDeclaration(className, parameterTypes, exceptionTypes);
} else {
@@ -508,14 +476,6 @@
FieldInfo field = fields[i];
char[] fieldName = field.getName();
char[] fieldType = decodeFieldType(replace('/', '.', field.getTypeName()));
- if (DEBUG) {
- if (fieldName != null) {
- System.out.println("field name = " + new String(fieldName)); //$NON-NLS-1$
- }
- if (fieldType != null) {
- System.out.println("field type = " + new String(fieldType)); //$NON-NLS-1$
- }
- }
addFieldDeclaration(fieldType, fieldName);
}
}
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java
index 33270d5..b525c36 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java
@@ -343,9 +343,9 @@
for (int j = 0, rootsLength = roots.length; j < rootsLength; j++) {
IJavaElement[] pkgs = roots[j].getChildren();
for (int k = 0, pksLength = pkgs.length; k < pksLength; k++) {
- IJavaElement pkg = pkgs[k];
- if (pkgPattern
- .matchesName(pkgPattern.pkgName, pkg.getElementName().toCharArray())) {
+ IPackageFragment pkg = (IPackageFragment)pkgs[k];
+ if (pkg.getChildren().length > 0
+ && pkgPattern.matchesName(pkgPattern.pkgName, pkg.getElementName().toCharArray())) {
IResource resource = pkg.getUnderlyingResource();
if (resource == null) { // case of a file in an external jar
resource = javaProject.getProject();
diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SearchPattern.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SearchPattern.java
index c822dd0..eb2a79e 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SearchPattern.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/SearchPattern.java
@@ -13,6 +13,7 @@
import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
import org.eclipse.jdt.internal.compiler.util.*;
import org.eclipse.jdt.internal.core.index.impl.IndexInput;
@@ -835,30 +836,35 @@
*/
protected char[][][] collectSuperTypeNames(char[] declaringQualification, char[] declaringSimpleName, int matchMode, LookupEnvironment env) {
- char[][] declaringTypeName = null;
- if (declaringQualification != null
- && declaringSimpleName != null
- && matchMode == EXACT_MATCH) {
- char[][] qualification = CharOperation.splitOn('.', declaringQualification);
- declaringTypeName = CharOperation.arrayConcat(qualification, declaringSimpleName);
- }
- if (declaringTypeName != null) {
- for (int i = 0, max = declaringTypeName.length; i < max; i++) {
- ReferenceBinding matchingDeclaringType = env.askForType(declaringTypeName);
- if (matchingDeclaringType != null
- && (matchingDeclaringType.isValidBinding()
- || matchingDeclaringType.problemId() != ProblemReasons.NotFound)) {
- return this.collectSuperTypeNames(matchingDeclaringType);
- }
- // if nothing is in the cache, it could have been a member type (A.B.C.D --> A.B.C$D)
- int last = declaringTypeName.length - 1;
- if (last == 0) break;
- declaringTypeName[last-1] = CharOperation.concat(declaringTypeName[last-1], declaringTypeName[last], '$'); // try nested type
- declaringTypeName = CharOperation.subarray(declaringTypeName, 0, last);
+ try {
+ char[][] declaringTypeName = null;
+ if (declaringQualification != null
+ && declaringSimpleName != null
+ && matchMode == EXACT_MATCH) {
+ char[][] qualification = CharOperation.splitOn('.', declaringQualification);
+ declaringTypeName = CharOperation.arrayConcat(qualification, declaringSimpleName);
}
- return NOT_FOUND_DECLARING_TYPE; // the declaring type was not found
- } else {
- // non exact match: use the null value so that matches is more tolerant
+ if (declaringTypeName != null) {
+ for (int i = 0, max = declaringTypeName.length; i < max; i++) {
+ ReferenceBinding matchingDeclaringType = env.askForType(declaringTypeName);
+ if (matchingDeclaringType != null
+ && (matchingDeclaringType.isValidBinding()
+ || matchingDeclaringType.problemId() != ProblemReasons.NotFound)) {
+ return this.collectSuperTypeNames(matchingDeclaringType);
+ }
+ // if nothing is in the cache, it could have been a member type (A.B.C.D --> A.B.C$D)
+ int last = declaringTypeName.length - 1;
+ if (last == 0) break;
+ declaringTypeName[last-1] = CharOperation.concat(declaringTypeName[last-1], declaringTypeName[last], '$'); // try nested type
+ declaringTypeName = CharOperation.subarray(declaringTypeName, 0, last);
+ }
+ return NOT_FOUND_DECLARING_TYPE; // the declaring type was not found
+ } else {
+ // non exact match: use the null value so that matches is more tolerant
+ return null;
+ }
+ } catch (AbortCompilation e) {
+ // classpath problem: default to null value so that matches is more tolerant
return null;
}
}