Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Clement2013-05-15 04:19:20 +0000
committerssankaran2013-05-15 04:19:20 +0000
commit1155b311a647fc5f126edd0c5e6b818f225baee0 (patch)
tree325043e31301956c0cd50a373b30f4856b62c52f
parentca0a8d2a8dcbdca4c1d22b2aafd247d22556e537 (diff)
downloadeclipse.jdt.core-1155b311a647fc5f126edd0c5e6b818f225baee0.tar.gz
eclipse.jdt.core-1155b311a647fc5f126edd0c5e6b818f225baee0.tar.xz
eclipse.jdt.core-1155b311a647fc5f126edd0c5e6b818f225baee0.zip
Cleanups and bug fixes preparatory for Bug 383624 - [1.8][compiler]
Revive code generation support for type annotations
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java13
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java10
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java27
-rw-r--r--org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTRecoveryPropagator.java52
4 files changed, 44 insertions, 58 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java
index d1906e17e4..0f40e664b8 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java
@@ -14,6 +14,8 @@
* Stephan Herrmann - Contributions for
* bug 342671 - ClassCastException: org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding cannot be cast to org.eclipse.jdt.internal.compiler.lookup.ArrayBinding
* bug 392099 - [1.8][compiler][null] Apply null annotation on types for null analysis
+ * Andy Clement - Contributions for
+ * Bug 383624 - [1.8][compiler] Revive code generation support for type annotations (from Olivier's work)
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
@@ -40,6 +42,17 @@ public class ParameterizedQualifiedTypeReference extends ArrayQualifiedTypeRefer
super(tokens, dim, positions);
this.typeArguments = typeArguments;
+ annotationSearch: for (int i = 0, max = typeArguments.length; i < max; i++) {
+ TypeReference[] typeArgumentsOnTypeComponent = typeArguments[i];
+ if (typeArgumentsOnTypeComponent != null) {
+ for (int j = 0, max2 = typeArgumentsOnTypeComponent.length; j < max2; j++) {
+ if ((typeArgumentsOnTypeComponent[j].bits & ASTNode.HasTypeAnnotations) != 0) {
+ this.bits |= ASTNode.HasTypeAnnotations;
+ break annotationSearch;
+ }
+ }
+ }
+ }
}
public ParameterizedQualifiedTypeReference(char[][] tokens, TypeReference[][] typeArguments, int dim, Annotation[][] annotationsOnDimensions, long[] positions) {
this(tokens, typeArguments, dim, positions);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java
index 82a06ef825..b3b26f2e1f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,6 +14,8 @@
* Stephan Herrmann - Contributions for
* bug 342671 - ClassCastException: org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding cannot be cast to org.eclipse.jdt.internal.compiler.lookup.ArrayBinding
* bug 392099 - [1.8][compiler][null] Apply null annotation on types for null analysis
+ * Andy Clement - Contributions for
+ * Bug 383624 - [1.8][compiler] Revive code generation support for type annotations (from Olivier's work)
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.ast;
@@ -35,6 +37,12 @@ public class ParameterizedSingleTypeReference extends ArrayTypeReference {
super(name, dim, pos);
this.originalSourceEnd = this.sourceEnd;
this.typeArguments = typeArguments;
+ for (int i = 0, max = typeArguments.length; i < max; i++) {
+ if ((typeArguments[i].bits & ASTNode.HasTypeAnnotations) != 0) {
+ this.bits |= ASTNode.HasTypeAnnotations;
+ break;
+ }
+ }
}
public ParameterizedSingleTypeReference(char[] name, TypeReference[] typeArguments, int dim, Annotation[][] annotationsOnDimensions, long pos) {
this(name, typeArguments, dim, pos);
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 baf23ffdb4..0fd892cb9f 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
@@ -24,7 +24,8 @@
* bug 399695 - [1.8][compiler] [1.8][compiler] migrate parser to other syntax for default methods
* bug 384567 - [1.5][compiler] Compiler accepts illegal modifiers on package declaration
* bug 393192 - Incomplete type hierarchy with > 10 annotations
- *
+ * Andy Clement - Contributions for
+ * Bug 383624 - [1.8][compiler] Revive code generation support for type annotations (from Olivier's work)
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.parser;
@@ -1818,11 +1819,13 @@ protected void consumeArrayCreationExpressionWithInitializer() {
length);
Annotation[][] annotationsOnDimensions = getAnnotationsOnDimensions(length);
arrayAllocation.annotationsOnDimensions = annotationsOnDimensions;
+
+ arrayAllocation.type = getTypeReference(0);
+ arrayAllocation.type.bits |= ASTNode.IgnoreRawTypeCheck; // no need to worry about raw type usage
if (annotationsOnDimensions != null) {
arrayAllocation.bits |= ASTNode.HasTypeAnnotations;
+ arrayAllocation.type.bits |= ASTNode.HasTypeAnnotations;
}
- arrayAllocation.type = getTypeReference(0);
- arrayAllocation.type.bits |= ASTNode.IgnoreRawTypeCheck; // no need to worry about raw type usage
arrayAllocation.sourceStart = this.intStack[this.intPtr--];
if (arrayAllocation.initializer == null) {
@@ -1848,11 +1851,12 @@ protected void consumeArrayCreationExpressionWithoutInitializer() {
length);
Annotation[][] annotationsOnDimensions = getAnnotationsOnDimensions(length);
arrayAllocation.annotationsOnDimensions = annotationsOnDimensions;
+ arrayAllocation.type = getTypeReference(0);
+ arrayAllocation.type.bits |= ASTNode.IgnoreRawTypeCheck; // no need to worry about raw type usage
if (annotationsOnDimensions != null) {
arrayAllocation.bits |= ASTNode.HasTypeAnnotations;
+ arrayAllocation.type.bits |= ASTNode.HasTypeAnnotations;
}
- arrayAllocation.type = getTypeReference(0);
- arrayAllocation.type.bits |= ASTNode.IgnoreRawTypeCheck; // no need to worry about raw type usage
arrayAllocation.sourceStart = this.intStack[this.intPtr--];
if (arrayAllocation.initializer == null) {
arrayAllocation.sourceEnd = this.endStatementPosition;
@@ -5180,6 +5184,7 @@ protected void consumeMethodHeaderRightParen() {
if (type.annotations == null) {
type.bits |= ASTNode.HasTypeAnnotations;
type.annotations = new Annotation[type.getAnnotatableLevels()][];
+ md.bits |= ASTNode.HasTypeAnnotations;
}
type.annotations[0] = annotations;
int annotationSourceStart = annotations[0].sourceStart;
@@ -5187,6 +5192,7 @@ protected void consumeMethodHeaderRightParen() {
type.sourceStart = annotationSourceStart;
arg.annotations = null;
}
+ md.bits |= (arg.type.bits & ASTNode.HasTypeAnnotations);
} else {
System.arraycopy(
this.astStack,
@@ -5194,6 +5200,12 @@ protected void consumeMethodHeaderRightParen() {
md.arguments = new Argument[length],
0,
length);
+ for (int i = 0, max = md.arguments.length; i < max; i++) {
+ if ((md.arguments[i].bits & ASTNode.HasTypeAnnotations) != 0) {
+ md.bits |= ASTNode.HasTypeAnnotations;
+ break;
+ }
+ }
}
}
md.bodyStart = this.rParenPos+1;
@@ -10000,7 +10012,7 @@ protected Expression getTypeReference(Expression exp) {
exp.bits |= Binding.TYPE;
return exp;
}
-protected void annotateTypeReference(TypeReference ref) {
+protected void annotateTypeReference(Wildcard ref) {
int length;
if ((length = this.typeAnnotationLengthStack[this.typeAnnotationLengthPtr--]) != 0) {
if (ref.annotations == null)
@@ -10016,6 +10028,9 @@ protected void annotateTypeReference(TypeReference ref) {
}
ref.bits |= ASTNode.HasTypeAnnotations;
}
+ if (ref.bound != null) {
+ ref.bits |= (ref.bound.bits & ASTNode.HasTypeAnnotations);
+ }
}
protected TypeReference getTypeReference(int dim) {
/* build a Reference on a variable that may be qualified or not
diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTRecoveryPropagator.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTRecoveryPropagator.java
index cfffccf60f..28371d695c 100644
--- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTRecoveryPropagator.java
+++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/ASTRecoveryPropagator.java
@@ -1,14 +1,10 @@
/*******************************************************************************
- * Copyright (c) 2006, 2012 IBM Corporation and others.
+ * Copyright (c) 2006, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * This is an implementation of an early-draft specification developed under the Java
- * Community Process (JCP) and is made available for testing and evaluation purposes
- * only. The code is not compatible with any specification of the JCP.
- *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
@@ -130,52 +126,6 @@ class ASTRecoveryPropagator extends DefaultASTVisitor {
}
public void endVisit(Block node) {
- int level = node.getAST().apiLevel;
-
- List statements = node.statements();
- next : for (int i = 0, max = statements.size(); i < max; i++) {
- ASTNode statement = (ASTNode) statements.get(i);
- if (statement.getNodeType() == ASTNode.VARIABLE_DECLARATION_STATEMENT) {
- VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) statement;
-
- if (level == AST.JLS2_INTERNAL) {
- if (variableDeclarationStatement.getModifiers() != Modifier.NONE) {
- continue next;
- }
- } else if (level >= AST.JLS3_INTERNAL) {
- if (variableDeclarationStatement.modifiers().size() != 0) {
- continue next;
- }
- }
-
- Type type = variableDeclarationStatement.getType();
- if (type.getNodeType() != ASTNode.SIMPLE_TYPE) {
- continue next;
- }
-
- List fragments = variableDeclarationStatement.fragments();
- if (fragments.size() == 1) {
- VariableDeclarationFragment fragment = (VariableDeclarationFragment) fragments.get(0);
-
- SimpleName simpleName = fragment.getName();
- if (CharOperation.equals(RecoveryScanner.FAKE_IDENTIFIER, simpleName.getIdentifier().toCharArray())) {
- SimpleType simpleType = (SimpleType) type;
- Name name = simpleType.getName();
- name.setParent(null, null);
- name.setFlags(name.getFlags() | ASTNode.RECOVERED);
-
- final ExpressionStatement stmt = new ExpressionStatement(name.getAST());
- stmt.setExpression(name);
- stmt.setSourceRange(variableDeclarationStatement.getStartPosition(), variableDeclarationStatement.getLength());
- stmt.setFlags(stmt.getFlags() | ASTNode.RECOVERED);
-
- statements.add(i, stmt);
- statements.remove(variableDeclarationStatement);
- }
- }
- }
- }
-
this.blockDepth--;
if(this.blockDepth <= 0) {
flagNodeWithInsertedTokens();

Back to the top