diff options
author | Jay Arthanareeswaran | 2019-01-21 14:47:46 +0000 |
---|---|---|
committer | Jay Arthanareeswaran | 2019-01-21 14:55:48 +0000 |
commit | c8c0dc9d19f02083d766af42cfc0ff81f116d281 (patch) | |
tree | c6d4cc76e3309ffc03fcaa35ca99a8ee1d81604c /org.eclipse.jdt.core | |
parent | d7939d6d0d8358feeae861410d7eaa9520e4a5a7 (diff) | |
download | eclipse.jdt.core-c8c0dc9d19f02083d766af42cfc0ff81f116d281.tar.gz eclipse.jdt.core-c8c0dc9d19f02083d766af42cfc0ff81f116d281.tar.xz eclipse.jdt.core-c8c0dc9d19f02083d766af42cfc0ff81f116d281.zip |
Change-Id: I0420f05708ff7bd8eedc116bf3a8aa990fb492c6
Signed-off-by: Jay Arthanareeswaran <jarthana@in.ibm.com>
Diffstat (limited to 'org.eclipse.jdt.core')
4 files changed, 26 insertions, 54 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java index 093d3a8ad3..10870eee09 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java @@ -2105,12 +2105,4 @@ void setSourceStart(int sourceStart); /** @since 3.17 BETA_JAVA_12 */ int SwitchExpressionMissingDefaultCase = Internal + 1607; /** @since 3.17 BETA_JAVA_12 */ - int SwitchExpressionNotBelow12 = Internal + Syntax + 1608; - /** @since 3.17 BETA_JAVA_12 */ - int SwitchCaseLabelWithArrowNotBelow12 = Internal + Syntax + 1609; - /** @since 3.17 BETA_JAVA_12 */ - int SwitchExpressionPreviewDisabled = Internal + Syntax + 1610; - /** @since 3.17 BETA_JAVA_12 */ - int SwitchCaseLabelWithArrowPreviewDisabled = Internal + Syntax + 1611; - } 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 ef860fe7ef..18ff40132c 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 @@ -56,6 +56,7 @@ import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; import org.eclipse.jdt.internal.compiler.codegen.ConstantPool; import org.eclipse.jdt.internal.compiler.env.ICompilationUnit; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; +import org.eclipse.jdt.internal.compiler.impl.IrritantSet; import org.eclipse.jdt.internal.compiler.impl.ReferenceContext; import org.eclipse.jdt.internal.compiler.lookup.Binding; import org.eclipse.jdt.internal.compiler.lookup.BlockScope; @@ -9492,9 +9493,14 @@ protected void consumeCaseLabelExpr() { consumeCaseLabel(); CaseStatement caseStatement = (CaseStatement) this.astStack[this.astPtr]; if (!this.parsingJava12Plus) { - problemReporter().caseStatementWithArrowNotBelow12(caseStatement); +// problemReporter().caseStatementWithArrowNotBelow12(caseStatement); + problemReporter().previewFeatureNotSupported(caseStatement.sourceStart, caseStatement.sourceEnd, "Case Labels with '->'", CompilerOptions.VERSION_12); //$NON-NLS-1$ } else if (!this.options.enablePreviewFeatures){ - problemReporter().caseStatementWithArrowIsPreview(caseStatement); + problemReporter().previewFeatureNotEnabled(caseStatement.sourceStart, caseStatement.sourceEnd, "Case Labels with '->'"); //$NON-NLS-1$ + } else { + if (this.options.isAnyEnabled(IrritantSet.PREVIEW)) { + problemReporter().previewFeatureUsed(caseStatement.sourceStart, caseStatement.sourceEnd); + } } caseStatement.isExpr = true; } @@ -9503,9 +9509,14 @@ protected void consumeDefaultLabelExpr() { consumeDefaultLabel(); CaseStatement defaultStatement = (CaseStatement) this.astStack[this.astPtr]; if (!this.parsingJava12Plus) { - problemReporter().caseStatementWithArrowNotBelow12(defaultStatement); +// problemReporter().caseStatementWithArrowNotBelow12(defaultStatement); + problemReporter().previewFeatureNotSupported(defaultStatement.sourceStart, defaultStatement.sourceEnd, "Case Labels with '->'", CompilerOptions.VERSION_12); //$NON-NLS-1$ } else if (!this.options.enablePreviewFeatures){ - problemReporter().caseStatementWithArrowIsPreview(defaultStatement); + problemReporter().previewFeatureNotEnabled(defaultStatement.sourceStart, defaultStatement.sourceEnd, "Case Labels with '->'"); //$NON-NLS-1$ + } else { + if (this.options.isAnyEnabled(IrritantSet.PREVIEW)) { + problemReporter().previewFeatureUsed(defaultStatement.sourceStart, defaultStatement.sourceEnd); + } } defaultStatement.isExpr = true; } @@ -9516,9 +9527,15 @@ protected void consumeSwitchExpression() { SwitchExpression s = (SwitchExpression) this.astStack[this.astPtr--]; if (!this.parsingJava12Plus) { - problemReporter().switchExpressionsNotBelow12(s); +// problemReporter().switchExpressionsNotBelow12(s); + problemReporter().previewFeatureNotSupported(s.sourceStart, s.sourceEnd, "Switch Expression", CompilerOptions.VERSION_12); //$NON-NLS-1$ } else if (!this.options.enablePreviewFeatures) { - problemReporter().switchExpressionIsPreview(s); + //problemReporter().switchExpressionIsPreview(s); + problemReporter().previewFeatureNotEnabled(s.sourceStart, s.sourceEnd, "Switch Expression"); //$NON-NLS-1$ + } else { + if (this.options.isAnyEnabled(IrritantSet.PREVIEW)) { + problemReporter().previewFeatureUsed(s.sourceStart, s.sourceEnd); + } } pushOnExpressionStack(s); diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java index 46d9f54b23..89d3b15cd0 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java @@ -9283,8 +9283,8 @@ public void previewFeatureUsed(int sourceStart, int sourceEnd) { sourceStart, sourceEnd); } -public void previewFeatureNotSupported(int sourceStart, int sourceEnd, String sourceLevel) { - String[] args = new String[] {sourceLevel}; +public void previewFeatureNotSupported(int sourceStart, int sourceEnd, String featureName, String sourceLevel) { + String[] args = new String[] {featureName, sourceLevel}; this.handle( IProblem.PreviewFeatureNotSupported, args, @@ -11089,36 +11089,4 @@ public void switchExpressionMixedCase(ASTNode statement) { statement.sourceStart, statement.sourceEnd); } -public void switchExpressionsNotBelow12(SwitchExpression switchExpr) { - this.handle( - IProblem.SwitchExpressionNotBelow12, - NoArgument, - NoArgument, - switchExpr.sourceStart, - switchExpr.sourceEnd); -} -public void caseStatementWithArrowNotBelow12(CaseStatement caseStatement) { - this.handle( - IProblem.SwitchCaseLabelWithArrowNotBelow12, - NoArgument, - NoArgument, - caseStatement.sourceStart, - caseStatement.sourceEnd); -} -public void switchExpressionIsPreview(SwitchExpression switchExpr) { - this.handle( - IProblem.SwitchExpressionPreviewDisabled, - NoArgument, - NoArgument, - switchExpr.sourceStart, - switchExpr.sourceEnd); -} -public void caseStatementWithArrowIsPreview(CaseStatement caseStatement) { - this.handle( - IProblem.SwitchCaseLabelWithArrowPreviewDisabled, - NoArgument, - NoArgument, - caseStatement.sourceStart, - caseStatement.sourceEnd); -} } diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties index f22a49da89..6201a1918a 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties @@ -884,7 +884,7 @@ 1102 = At least one of the problems in category ''{0}'' is not analysed due to a compiler option being ignored 1103 = {0} is a preview feature and disabled by default. Use --enable-preview to enable 1104 = You are using a preview language feature that may or may not be supported in a future release -1105 = This preview feature is only available with source level {0} and above +1105 = The preview feature {0} is only available with source level {1} and above # more programming problems: 1200 = Unlikely argument type {0} for {1} on a {2} @@ -984,11 +984,6 @@ 1607 = A switch expression should have a default case 1608 = Switch expressions are allowed only at source level 12 or above 1609 = Switch Case Labels with '->' are allowed only at source level 12 or above -1608 = Switch expressions are allowed only at source level 12 or above -1609 = Switch Case Labels with '->' are allowed only at source level 12 or above -1610 = Switch expression is a preview feature; use --enable-preview at source level 12 or above to enable -1611 = Switch Case Label with '->' is a preview feature; use --enable-preview at source level 12 or above to enable - ### ELABORATIONS ## Access restrictions |