diff options
16 files changed, 162 insertions, 109 deletions
diff --git a/org.eclipse.jdt.compiler.tool/src/org/eclipse/jdt/internal/compiler/tool/EclipseCompilerImpl.java b/org.eclipse.jdt.compiler.tool/src/org/eclipse/jdt/internal/compiler/tool/EclipseCompilerImpl.java index 9a20196ac7..0e5b0e98ed 100644 --- a/org.eclipse.jdt.compiler.tool/src/org/eclipse/jdt/internal/compiler/tool/EclipseCompilerImpl.java +++ b/org.eclipse.jdt.compiler.tool/src/org/eclipse/jdt/internal/compiler/tool/EclipseCompilerImpl.java @@ -1,10 +1,14 @@ /******************************************************************************* - * Copyright (c) 2007, 2011 IBM Corporation and others. + * Copyright (c) 2007, 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 * 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 * IBM Corporation - fix for 342936 @@ -148,6 +152,10 @@ public class EclipseCompilerImpl extends Main { public boolean stopOnFirstError() { return false; } + @Override + public boolean ignoreAllErrors() { + return false; + } }; } diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java index a1a39f6f2c..dbf186b5f9 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java @@ -1148,6 +1148,9 @@ protected static class JavacTestOptions { public boolean proceedOnErrors() { return true; } + public boolean ignoreAllErrors() { + return false; + } }; } /* diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java index 3730aed434..4536ac6552 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AnnotationTest.java @@ -8792,6 +8792,7 @@ public void test265() { IErrorHandlingPolicy errorHandlingPolicy = new IErrorHandlingPolicy() { public boolean proceedOnErrors() { return true; } public boolean stopOnFirstError() { return false; } + public boolean ignoreAllErrors() { return false; } }; Map options = getCompilerOptions(); options.put(CompilerOptions.OPTION_Process_Annotations, CompilerOptions.ENABLED); diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeLambdaExpressionsTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeLambdaExpressionsTest.java index 8b5b6036b0..1981029dbf 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeLambdaExpressionsTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NegativeLambdaExpressionsTest.java @@ -5375,72 +5375,57 @@ this.runNegativeTest( " ^^^^^^^^^^^^^\n" + "The constructor X.Y(X::goo) is undefined\n" + "----------\n" + - "2. ERROR in X.java (at line 9)\n" + - " this(X::goo);\n" + - " ^^^^^^\n" + - "The type of goo() from the type X is int, this is incompatible with the descriptor\'s return type: String\n" + - "----------\n" + - "3. ERROR in X.java (at line 14)\n" + + "2. ERROR in X.java (at line 14)\n" + " this((x) -> { return 10;});\n" + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + "The constructor X((<no type> x) -> {\n" + " return 10;\n" + "}) is undefined\n" + "----------\n" + - "4. ERROR in X.java (at line 18)\n" + + "3. ERROR in X.java (at line 18)\n" + " foo(X::goo);\n" + " ^^^\n" + "The method foo(I) in the type X is not applicable for the arguments (X::goo)\n" + "----------\n" + - "5. ERROR in X.java (at line 18)\n" + - " foo(X::goo);\n" + - " ^^^^^^\n" + - "The type of goo() from the type X is int, this is incompatible with the descriptor\'s return type: String\n" + - "----------\n" + - "6. ERROR in X.java (at line 19)\n" + + "4. ERROR in X.java (at line 19)\n" + " new X((x)->{ return 10;});\n" + " ^^^^^^^^^^^^^^^^^^^^^^^^^\n" + "The constructor X((<no type> x) -> {\n" + " return 10;\n" + "}) is undefined\n" + "----------\n" + - "7. ERROR in X.java (at line 20)\n" + + "5. ERROR in X.java (at line 20)\n" + " new X((x)->{ return 10;}).new Y((x) -> { return 0;});\n" + " ^^^^^^^^^^^^^^^^^^^^^^^^^\n" + "The constructor X((<no type> x) -> {\n" + " return 10;\n" + "}) is undefined\n" + "----------\n" + - "8. ERROR in X.java (at line 20)\n" + + "6. ERROR in X.java (at line 20)\n" + " new X((x)->{ return 10;}).new Y((x) -> { return 0;});\n" + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + "The constructor X.Y((<no type> x) -> {\n" + " return 0;\n" + "}) is undefined\n" + "----------\n" + - "9. ERROR in X.java (at line 21)\n" + + "7. ERROR in X.java (at line 21)\n" + " new X((x)->{ return 10;}) {};\n" + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + "The constructor X((<no type> x) -> {\n" + " return 10;\n" + "}) is undefined\n" + "----------\n" + - "10. ERROR in X.java (at line 26)\n" + + "8. ERROR in X.java (at line 26)\n" + " super(X::goo);\n" + " ^^^^^^^^^^^^^^\n" + "The constructor X(X::goo) is undefined\n" + "----------\n" + - "11. ERROR in X.java (at line 26)\n" + - " super(X::goo);\n" + - " ^^^^^^\n" + - "The type of goo() from the type X is int, this is incompatible with the descriptor\'s return type: String\n" + - "----------\n" + - "12. ERROR in X.java (at line 29)\n" + + "9. ERROR in X.java (at line 29)\n" + " super (x -> 10);\n" + " ^^^^^^^^^^^^^^^^\n" + "The constructor X((<no type> x) -> 10) is undefined\n" + "----------\n" + - "13. ERROR in X.java (at line 31)\n" + + "10. ERROR in X.java (at line 31)\n" + " Zork z;\n" + " ^^^^\n" + "Zork cannot be resolved to a type\n" + @@ -5657,12 +5642,7 @@ public void test401847a() { " ^^^\n" + "The method foo(I...) in the type X is not applicable for the arguments ((true ? X::goo : X::goo))\n" + "----------\n" + - "2. ERROR in X.java (at line 8)\n" + - " foo(true ? X::goo : X::goo);\n" + - " ^^^^^^\n" + - "The type of goo() from the type X is int, this is incompatible with the descriptor\'s return type: String\n" + - "----------\n" + - "3. ERROR in X.java (at line 9)\n" + + "2. ERROR in X.java (at line 9)\n" + " foo(true ? x-> 1 : x->0);\n" + " ^^^\n" + "The method foo(I...) in the type X is not applicable for the arguments ((true ? (<no type> x) -> 1 : (<no type> x) -> 0))\n" + diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/Util.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/Util.java index 52d132fc90..d1f7a8f65f 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/Util.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/util/Util.java @@ -1,10 +1,14 @@ /******************************************************************************* - * 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 * 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 * Nina Rinskaya @@ -192,6 +196,9 @@ public static void compile(String[] pathsAndContents, Map options, String[] clas public boolean stopOnFirstError() { return false; } + public boolean ignoreAllErrors() { + return false; + } }; CompilerOptions compilerOptions = new CompilerOptions(options); compilerOptions.performMethodsFullRecovery = false; diff --git a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java index 18e662088f..35ae5b1059 100644 --- a/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java +++ b/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.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 @@ -3034,6 +3034,9 @@ public IErrorHandlingPolicy getHandlingPolicy() { public boolean stopOnFirstError() { return false; } + public boolean ignoreAllErrors() { + return false; + } }; } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/DefaultErrorHandlingPolicies.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/DefaultErrorHandlingPolicies.java index f374c4c0ec..f5acdaeb20 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/DefaultErrorHandlingPolicies.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/DefaultErrorHandlingPolicies.java @@ -1,9 +1,13 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 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 * 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 @@ -27,6 +31,9 @@ public static IErrorHandlingPolicy exitAfterAllProblems() { public boolean proceedOnErrors(){ return false; } + public boolean ignoreAllErrors() { + return false; + } }; } /* @@ -42,6 +49,9 @@ public static IErrorHandlingPolicy exitOnFirstError() { public boolean proceedOnErrors(){ return false; } + public boolean ignoreAllErrors() { + return false; + } }; } /* @@ -56,6 +66,9 @@ public static IErrorHandlingPolicy proceedOnFirstError() { public boolean proceedOnErrors(){ return true; } + public boolean ignoreAllErrors() { + return false; + } }; } /* @@ -70,6 +83,26 @@ public static IErrorHandlingPolicy proceedWithAllProblems() { public boolean proceedOnErrors(){ return true; } + public boolean ignoreAllErrors() { + return false; + } + }; +} +/* + * Accumulate all problems, then proceed with them, but never report them. + * + */ +public static IErrorHandlingPolicy ignoreAllProblems() { + return new IErrorHandlingPolicy() { + public boolean stopOnFirstError() { + return false; + } + public boolean proceedOnErrors(){ + return true; + } + public boolean ignoreAllErrors() { + return true; + } }; } } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/IErrorHandlingPolicy.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/IErrorHandlingPolicy.java index f8afdf2ca0..de68aba850 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/IErrorHandlingPolicy.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/IErrorHandlingPolicy.java @@ -1,21 +1,26 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 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 * 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 *******************************************************************************/ package org.eclipse.jdt.internal.compiler; /* - * Handler policy is responsible to answer the 2 following + * Handler policy is responsible to answer the 3 following * questions: * 1. should the handler stop on first problem which appears * to be a real error (that is, not a warning), * 2. should it proceed once it has gathered all problems + * 3. Should problems be reported at all ? * * The intent is that one can supply its own policy to implement * some interactive error handling strategy where some UI would @@ -25,4 +30,5 @@ package org.eclipse.jdt.internal.compiler; public interface IErrorHandlingPolicy { boolean proceedOnErrors(); boolean stopOnFirstError(); + boolean ignoreAllErrors(); } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FunctionalExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FunctionalExpression.java index 35e98ae3b6..8a5e300985 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FunctionalExpression.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FunctionalExpression.java @@ -18,6 +18,8 @@ package org.eclipse.jdt.internal.compiler.ast; import org.eclipse.jdt.core.compiler.CategorizedProblem; import org.eclipse.jdt.internal.compiler.CompilationResult; +import org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies; +import org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy; import org.eclipse.jdt.internal.compiler.codegen.CodeStream; import org.eclipse.jdt.internal.compiler.flow.FlowInfo; import org.eclipse.jdt.internal.compiler.impl.Constant; @@ -48,13 +50,10 @@ public abstract class FunctionalExpression extends Expression implements Problem protected CompilationResult compilationResult; protected BlockScope enclosingScope; protected boolean ellipsisArgument; - protected static CompilationResult devNullCompilationResult; + protected static IErrorHandlingPolicy silentErrorHandlingPolicy = DefaultErrorHandlingPolicies.ignoreAllProblems(); public FunctionalExpression(CompilationResult compilationResult) { this.compilationResult = compilationResult; - if (devNullCompilationResult == null) { - devNullCompilationResult = new CompilationResult(this.compilationResult.getCompilationUnit(), 0, 0, Integer.MAX_VALUE /* maximum problems per unit */); - } } public void setExpectedType(TypeBinding expectedType) { @@ -209,12 +208,7 @@ public abstract class FunctionalExpression extends Expression implements Problem return this.ignoreFurtherInvestigation; } - private boolean shouldShutup() { - return this.compilationResult == devNullCompilationResult; - } - public void tagAsHavingErrors() { - if (shouldShutup()) return; this.ignoreFurtherInvestigation = true; Scope parent = this.enclosingScope.parent; while (parent != null) { diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LambdaExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LambdaExpression.java index fb1df1d502..e0aa4b3dc1 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LambdaExpression.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LambdaExpression.java @@ -21,6 +21,7 @@ package org.eclipse.jdt.internal.compiler.ast; import org.eclipse.jdt.internal.compiler.ASTVisitor; import org.eclipse.jdt.internal.compiler.CompilationResult; +import org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.codegen.CodeStream; import org.eclipse.jdt.internal.compiler.flow.ExceptionHandlingFlowContext; @@ -80,8 +81,11 @@ public class LambdaExpression extends FunctionalExpression { * @see org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(ClassScope) */ public TypeBinding resolveType(BlockScope blockScope) { + this.constant = Constant.NotAConstant; this.enclosingScope = blockScope; + this.scope = new MethodScope(blockScope, this, blockScope.methodScope().isStatic); + if (this.expectedType == null && this.expressionContext == INVOCATION_CONTEXT) { if (this.body instanceof Block) { // Gather shape information for potential applicability analysis. @@ -129,8 +133,6 @@ public class LambdaExpression extends FunctionalExpression { if (!haveDescriptor && argumentsTypeElided) return null; // FUBAR, bail out... - this.scope = new MethodScope(blockScope, this, blockScope.methodScope().isStatic); - this.binding = new MethodBinding(ClassFileConstants.AccPublic | ExtraCompilerModifiers.AccUnresolved, haveDescriptor ? this.descriptor.selector : TypeConstants.ANONYMOUS_METHOD, haveDescriptor ? this.descriptor.returnType : null, @@ -421,58 +423,52 @@ public class LambdaExpression extends FunctionalExpression { return false; } - LambdaExpression copy = copy(); - copy.setExpressionContext(this.expressionContext); - copy.setExpectedType(left); - copy.resolveType(this.enclosingScope); - - if (!argumentsTypeElided()) { - for (int i = 0, length = sam.parameters.length; i < length; i++) { - TypeBinding argumentType = copy.arguments[i].binding.type; - if (sam.parameters[i] != argumentType) - return false; - } - } - + IErrorHandlingPolicy oldPolicy = this.scope.problemReporter().switchErrorHandlingPolicy(silentErrorHandlingPolicy); try { - final TypeBinding returnType = sam.returnType; - if (this.body instanceof Block) { - ASTVisitor visitor = new ASTVisitor() { - public boolean visit(ReturnStatement returnStatement, BlockScope blockScope) { - Expression expression = returnStatement.expression; - if (expression != null && !expression.isAssignmentCompatible(returnType, blockScope)) - throw new NoncongruentLambdaException(); + LambdaExpression copy = copy(); + copy.setExpressionContext(this.expressionContext); + copy.setExpectedType(left); + copy.resolveType(this.enclosingScope); + + if (!argumentsTypeElided()) { + for (int i = 0, length = sam.parameters.length; i < length; i++) { + TypeBinding argumentType = copy.arguments[i].binding.type; + if (sam.parameters[i] != argumentType) return false; - } - }; - copy.body.traverse(visitor, copy.scope); - } else { - Expression expression = (Expression) copy.body; - if (!expression.isAssignmentCompatible(returnType, copy.scope)) - throw new NoncongruentLambdaException(); + } } - } catch (NoncongruentLambdaException e) { - return false; + + try { + final TypeBinding returnType = sam.returnType; + if (this.body instanceof Block) { + ASTVisitor visitor = new ASTVisitor() { + public boolean visit(ReturnStatement returnStatement, BlockScope blockScope) { + Expression expression = returnStatement.expression; + if (expression != null && !expression.isAssignmentCompatible(returnType, blockScope)) + throw new NoncongruentLambdaException(); + return false; + } + }; + copy.body.traverse(visitor, copy.scope); + } else { + Expression expression = (Expression) copy.body; + if (!expression.isAssignmentCompatible(returnType, copy.scope)) + throw new NoncongruentLambdaException(); + } + } catch (NoncongruentLambdaException e) { + return false; + } + } finally { + this.scope.problemReporter().switchErrorHandlingPolicy(oldPolicy); } return true; } LambdaExpression copy() { - final Parser parser = new Parser(this.enclosingScope.problemReporter(), false); + final Parser parser = new Parser(this.scope.problemReporter(), false); final char[] source = this.compilationResult.getCompilationUnit().getContents(); - LambdaExpression copy; - - CompilationUnitDeclaration unit = this.enclosingScope.referenceCompilationUnit(); - CompilationResult original = unit.compilationResult; - unit.compilationResult = devNullCompilationResult; - - try { - copy = (LambdaExpression) parser.parseExpression(source, this.sourceStart, this.sourceEnd - this.sourceStart + 1, unit); - } finally { - unit.compilationResult = original; - } - copy.compilationResult = devNullCompilationResult; - return copy; + return (LambdaExpression) parser.parseExpression(source, this.sourceStart, this.sourceEnd - this.sourceStart + 1, + this.scope.referenceCompilationUnit(), false /* record line separators */); } } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java index d16be966e4..f88b274b0c 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java @@ -23,6 +23,7 @@ package org.eclipse.jdt.internal.compiler.ast; import org.eclipse.jdt.core.compiler.CharOperation; import org.eclipse.jdt.internal.compiler.ASTVisitor; import org.eclipse.jdt.internal.compiler.CompilationResult; +import org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy; import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.codegen.ConstantPool; import org.eclipse.jdt.internal.compiler.flow.FlowContext; @@ -366,17 +367,17 @@ public class ReferenceExpression extends FunctionalExpression implements Invocat final MethodBinding sam = left.getSingleAbstractMethod(scope); if (sam == null || !sam.isValidBinding()) return false; - this.method.binding = this.binding = null; + boolean isCompatible; setExpectedType(left); - CompilationResult original = this.compilationResult; + IErrorHandlingPolicy oldPolicy = this.enclosingScope.problemReporter().switchErrorHandlingPolicy(silentErrorHandlingPolicy); try { - this.compilationResult = devNullCompilationResult; + this.method.binding = this.binding = null; resolveType(this.enclosingScope); } finally { - this.compilationResult = original; + this.enclosingScope.problemReporter().switchErrorHandlingPolicy(oldPolicy); + isCompatible = this.binding != null && this.binding.isValidBinding(); + this.method.binding = this.binding = null; } - boolean isCompatible = this.binding != null && this.binding.isValidBinding(); - this.method.binding = this.binding = null; return isCompatible; } }
\ No newline at end of file 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 9b5c41c429..0002634817 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 @@ -10228,11 +10228,11 @@ public void goForCompilationUnit(){ this.scanner.foundTaskCount = 0; this.scanner.recordLineSeparator = true; } -public void goForExpression() { +public void goForExpression(boolean recordLineSeparator) { //tells the scanner to go for an expression parsing this.firstToken = TokenNameREMAINDER; - this.scanner.recordLineSeparator = true; // recovery goals must record line separators + this.scanner.recordLineSeparator = recordLineSeparator; // recovery goals must record line separators } public void goForFieldDeclaration(){ //tells the scanner to go for field declaration parsing @@ -11040,7 +11040,7 @@ public void parse( //convert bugs into parse error initialize(); - goForExpression(); + goForExpression(true /* record line separators */); this.nestedMethod[this.nestedType]++; this.referenceContext = type; @@ -11376,10 +11376,10 @@ public ASTNode[] parseClassBodyDeclarations(char[] source, int offset, int lengt } return result; } -public Expression parseExpression(char[] source, int offset, int length, CompilationUnitDeclaration unit) { +public Expression parseExpression(char[] source, int offset, int length, CompilationUnitDeclaration unit, boolean recordLineSeparators) { initialize(); - goForExpression(); + goForExpression(recordLineSeparators); this.nestedMethod[this.nestedType]++; this.referenceContext = unit; diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java index 1ea540f005..2d51b8f59d 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemHandler.java @@ -1,9 +1,13 @@ /******************************************************************************* - * 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 * 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 @@ -35,7 +39,7 @@ public class ProblemHandler { public final static String[] NoArgument = CharOperation.NO_STRINGS; - final public IErrorHandlingPolicy policy; + public IErrorHandlingPolicy policy; public final IProblemFactory problemFactory; public final CompilerOptions options; /* @@ -114,7 +118,7 @@ public void handle( ReferenceContext referenceContext, CompilationResult unitResult) { - if (severity == ProblemSeverities.Ignore) + if (severity == ProblemSeverities.Ignore || this.policy.ignoreAllErrors()) return; if ((severity & ProblemSeverities.Optional) != 0 && problemId != IProblem.Task && !this.options.ignoreSourceFolderWarningOption) { @@ -212,4 +216,10 @@ public void handle( public void record(CategorizedProblem problem, CompilationResult unitResult, ReferenceContext referenceContext, boolean optionalError) { unitResult.record(problem, referenceContext, optionalError); } +/** @return old policy. */ +public IErrorHandlingPolicy switchErrorHandlingPolicy(IErrorHandlingPolicy newPolicy) { + IErrorHandlingPolicy presentPolicy = this.policy; + this.policy = newPolicy; + return presentPolicy; +} } diff --git a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java index df8f21488b..daa3323db4 100644 --- a/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java +++ b/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java @@ -1,10 +1,14 @@ /******************************************************************************* - * 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 * 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 * Stephan Herrmann - Contribution for bug 363858 - [dom] early throwing of AbortCompilation causes NPE in CompilationUnitResolver @@ -317,6 +321,9 @@ class CompilationUnitResolver extends Compiler { public boolean proceedOnErrors() { return false; // stop if there are some errors } + public boolean ignoreAllErrors() { + return false; + } }; } 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 479945c70a..fc6df8d243 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 @@ -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 @@ -818,7 +818,7 @@ protected boolean resumeOnSyntaxError() { this.identifierLengthPtr = -1; // go for the expression - goForExpression(); + goForExpression(true /* record line separators */); this.hasRecoveredOnExpression = true; this.hasReportedError = false; this.hasError = false; diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CodeSnippetParsingUtil.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CodeSnippetParsingUtil.java index 6115e3dbdf..5b119ca203 100644 --- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CodeSnippetParsingUtil.java +++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/CodeSnippetParsingUtil.java @@ -1,9 +1,13 @@ /******************************************************************************* - * Copyright (c) 2002, 2009 IBM Corporation and others. + * Copyright (c) 2002, 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 * 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 @@ -171,7 +175,7 @@ public class CodeSnippetParsingUtil { CompilationResult compilationResult = new CompilationResult(sourceUnit, 0, 0, compilerOptions.maxProblemsPerUnit); CompilationUnitDeclaration unit = new CompilationUnitDeclaration(problemReporter, compilationResult, source.length); - Expression result = parser.parseExpression(source, offset, length, unit); + Expression result = parser.parseExpression(source, offset, length, unit, true /* record line separators */); if (recordParsingInformation) { this.recordedParsingInformation = getRecordedParsingInformation(compilationResult, unit.comments); |