Unverified Commit 8388dd19 authored by Neil C Smith's avatar Neil C Smith Committed by GitHub
Browse files

Merge pull request #3267 from apache/delivery

Merge delivery to release126 for NB12.6-rc1
parents d5a9964a 33d95c55
...@@ -4664,7 +4664,7 @@ public final class JavaCompletionTask<T> extends BaseTask { ...@@ -4664,7 +4664,7 @@ public final class JavaCompletionTask<T> extends BaseTask {
&& env.getController().getTreeUtilities().getPathElementOfKind(Tree.Kind.INTERFACE, env.getPath()) != null) { && env.getController().getTreeUtilities().getPathElementOfKind(Tree.Kind.INTERFACE, env.getPath()) != null) {
results.add(itemFactory.createKeywordItem(DEFAULT_KEYWORD, SPACE, anchorOffset, false)); results.add(itemFactory.createKeywordItem(DEFAULT_KEYWORD, SPACE, anchorOffset, false));
} }
if (isRecordSupported(env)) { if (isRecordSupported(env) && Utilities.startsWith(RECORD_KEYWORD, prefix)) {
results.add(itemFactory.createKeywordItem(RECORD_KEYWORD, SPACE, anchorOffset, false)); results.add(itemFactory.createKeywordItem(RECORD_KEYWORD, SPACE, anchorOffset, false));
} }
addPrimitiveTypeKeywords(env); addPrimitiveTypeKeywords(env);
...@@ -4682,7 +4682,7 @@ public final class JavaCompletionTask<T> extends BaseTask { ...@@ -4682,7 +4682,7 @@ public final class JavaCompletionTask<T> extends BaseTask {
results.add(itemFactory.createKeywordItem(kw, SPACE, anchorOffset, false)); results.add(itemFactory.createKeywordItem(kw, SPACE, anchorOffset, false));
} }
} }
if (isRecordSupported(env)) { if (isRecordSupported(env) && Utilities.startsWith(RECORD_KEYWORD, prefix)) {
results.add(itemFactory.createKeywordItem(RECORD_KEYWORD, SPACE, anchorOffset, false)); results.add(itemFactory.createKeywordItem(RECORD_KEYWORD, SPACE, anchorOffset, false));
} }
if (Utilities.startsWith(RETURN_KEYWORD, prefix)) { if (Utilities.startsWith(RETURN_KEYWORD, prefix)) {
......
...@@ -33,7 +33,7 @@ import org.openide.util.lookup.ServiceProvider; ...@@ -33,7 +33,7 @@ import org.openide.util.lookup.ServiceProvider;
*/ */
public class JavaCompletionTask114FeaturesTest extends CompletionTestBase { public class JavaCompletionTask114FeaturesTest extends CompletionTestBase {
private static String SOURCE_LEVEL = "14"; //NOI18N private static final String SOURCE_LEVEL = "14"; //NOI18N
public JavaCompletionTask114FeaturesTest(String testName) { public JavaCompletionTask114FeaturesTest(String testName) {
super(testName); super(testName);
...@@ -78,9 +78,21 @@ public class JavaCompletionTask114FeaturesTest extends CompletionTestBase { ...@@ -78,9 +78,21 @@ public class JavaCompletionTask114FeaturesTest extends CompletionTestBase {
performTest("Records", 999, null, "override.pass", SOURCE_LEVEL); performTest("Records", 999, null, "override.pass", SOURCE_LEVEL);
} }
public void testRecordKeywordInsideClass() throws Exception { public void testRecordKeywordInsideMethod() throws Exception {
performTest("Records", 1014, "rec", "record.pass", SOURCE_LEVEL); performTest("Records", 1014, "rec", "record.pass", SOURCE_LEVEL);
} }
public void testRecordKeywordInsideClass() throws Exception {
performTest("Records", 844, "rec", "record.pass", SOURCE_LEVEL);
}
public void testRecordKeywordInsideMethodIfPrefixDoesntMatch() throws Exception {
performTest("Records", 1014, "someprefix", "empty.pass", SOURCE_LEVEL);
}
public void testRecordKeywordInsideClassIfPrefixDoesntMatch() throws Exception {
performTest("Records", 844, "someprefix", "empty.pass", SOURCE_LEVEL);
}
public void testVariableNameSuggestion() throws Exception { public void testVariableNameSuggestion() throws Exception {
TestCompilerOptionsQueryImplementation.EXTRA_OPTIONS.add("--enable-preview"); TestCompilerOptionsQueryImplementation.EXTRA_OPTIONS.add("--enable-preview");
......
...@@ -28,6 +28,7 @@ import org.netbeans.api.java.source.CompilationInfo; ...@@ -28,6 +28,7 @@ import org.netbeans.api.java.source.CompilationInfo;
import org.netbeans.api.lexer.TokenSequence; import org.netbeans.api.lexer.TokenSequence;
import org.netbeans.spi.editor.hints.ErrorDescription; import org.netbeans.spi.editor.hints.ErrorDescription;
import org.netbeans.spi.editor.hints.Fix; import org.netbeans.spi.editor.hints.Fix;
import org.netbeans.spi.editor.hints.Severity;
import org.netbeans.spi.java.hints.ErrorDescriptionFactory; import org.netbeans.spi.java.hints.ErrorDescriptionFactory;
import org.netbeans.spi.java.hints.Hint; import org.netbeans.spi.java.hints.Hint;
import org.netbeans.spi.java.hints.HintContext; import org.netbeans.spi.java.hints.HintContext;
...@@ -35,15 +36,15 @@ import org.netbeans.spi.java.hints.JavaFix; ...@@ -35,15 +36,15 @@ import org.netbeans.spi.java.hints.JavaFix;
import org.netbeans.spi.java.hints.TriggerTreeKind; import org.netbeans.spi.java.hints.TriggerTreeKind;
import org.openide.util.NbBundle.Messages; import org.openide.util.NbBundle.Messages;
@Hint(displayName = "#DN_ConvertTextBlockToString", description = "#DESC_ConvertTextBlockToString", category = "general", minSourceVersion = "13") @Hint(displayName = "#DN_ConvertTextBlockToString", description = "#DESC_ConvertTextBlockToString", category = "rules15", severity = Severity.HINT)
@Messages({ @Messages({
"DN_ConvertTextBlockToString=Convert Text block to String", "DN_ConvertTextBlockToString=Convert Text block to String",
"DESC_ConvertTextBlockToString=Text Block may not be supported in older versions of java older then 13" "DESC_ConvertTextBlockToString=Converts java 15 Text Blocks back to regular Strings."
}) })
public class ConvertTextBlockToString { public class ConvertTextBlockToString {
@TriggerTreeKind(Tree.Kind.STRING_LITERAL) @TriggerTreeKind(Tree.Kind.STRING_LITERAL)
@Messages("ERR_ConvertTextBlockToString=Text block may not be supported")//NOI18N @Messages("ERR_ConvertTextBlockToString=Text block can be converted to String")//NOI18N
public static ErrorDescription computeWarning(HintContext ctx) { public static ErrorDescription computeWarning(HintContext ctx) {
TokenSequence<?> ts = ctx.getInfo().getTokenHierarchy().tokenSequence(); TokenSequence<?> ts = ctx.getInfo().getTokenHierarchy().tokenSequence();
if (ts == null) { if (ts == null) {
...@@ -89,8 +90,8 @@ public class ConvertTextBlockToString { ...@@ -89,8 +90,8 @@ public class ConvertTextBlockToString {
protected void performRewrite(TransformationContext ctx) { protected void performRewrite(TransformationContext ctx) {
ExpressionTree ext = ctx.getWorkingCopy().getTreeMaker().Literal(orignalStringArr[orignalStringArr.length - 1]); ExpressionTree ext = ctx.getWorkingCopy().getTreeMaker().Literal(orignalStringArr[orignalStringArr.length - 1]);
if (orignalStringArr.length > 1) { if (orignalStringArr.length > 1) {
ext = ctx.getWorkingCopy().getTreeMaker().Binary(Tree.Kind.PLUS, buildTree(orignalStringArr, orignalStringArr.length - 2, ctx), (ExpressionTree) ext); ext = ctx.getWorkingCopy().getTreeMaker().Binary(Tree.Kind.PLUS, buildTree(orignalStringArr, orignalStringArr.length - 2, ctx), ext);
if (orignalStringArr[orignalStringArr.length - 1].equals("")) { if (orignalStringArr[orignalStringArr.length - 1].isEmpty()) {
ext = (((BinaryTree) ext).getLeftOperand()); ext = (((BinaryTree) ext).getLeftOperand());
} }
} }
......
...@@ -55,7 +55,7 @@ public class ConvertTextBlockToStringTest { ...@@ -55,7 +55,7 @@ public class ConvertTextBlockToStringTest {
.sourceLevel(SourceVersion.latest().name()) .sourceLevel(SourceVersion.latest().name())
.options("--enable-preview") .options("--enable-preview")
.run(ConvertTextBlockToString.class) .run(ConvertTextBlockToString.class)
.findWarning("3:18-3:21:verifier:" + Bundle.ERR_ConvertTextBlockToString()) .findWarning("3:18-3:21:hint:" + Bundle.ERR_ConvertTextBlockToString())
.applyFix() .applyFix()
.assertCompilable() .assertCompilable()
.assertOutput("package helloworld;\n" .assertOutput("package helloworld;\n"
...@@ -85,7 +85,7 @@ public class ConvertTextBlockToStringTest { ...@@ -85,7 +85,7 @@ public class ConvertTextBlockToStringTest {
.sourceLevel(SourceVersion.latest().name()) .sourceLevel(SourceVersion.latest().name())
.options("--enable-preview") .options("--enable-preview")
.run(ConvertTextBlockToString.class) .run(ConvertTextBlockToString.class)
.findWarning("3:18-3:21:verifier:" + Bundle.ERR_ConvertTextBlockToString()) .findWarning("3:18-3:21:hint:" + Bundle.ERR_ConvertTextBlockToString())
.applyFix() .applyFix()
.assertCompilable() .assertCompilable()
.assertOutput("package helloworld;\n" .assertOutput("package helloworld;\n"
...@@ -121,7 +121,7 @@ public class ConvertTextBlockToStringTest { ...@@ -121,7 +121,7 @@ public class ConvertTextBlockToStringTest {
.sourceLevel(SourceVersion.latest().name()) .sourceLevel(SourceVersion.latest().name())
.options("--enable-preview") .options("--enable-preview")
.run(ConvertTextBlockToString.class) .run(ConvertTextBlockToString.class)
.findWarning("3:18-3:21:verifier:" + Bundle.ERR_ConvertTextBlockToString()) .findWarning("3:18-3:21:hint:" + Bundle.ERR_ConvertTextBlockToString())
.applyFix() .applyFix()
.assertCompilable() .assertCompilable()
.assertOutput("package helloworld;\n" .assertOutput("package helloworld;\n"
...@@ -156,7 +156,7 @@ public class ConvertTextBlockToStringTest { ...@@ -156,7 +156,7 @@ public class ConvertTextBlockToStringTest {
.sourceLevel(SourceVersion.latest().name()) .sourceLevel(SourceVersion.latest().name())
.options("--enable-preview") .options("--enable-preview")
.run(ConvertTextBlockToString.class) .run(ConvertTextBlockToString.class)
.findWarning("3:18-3:21:verifier:" + Bundle.ERR_ConvertTextBlockToString()) .findWarning("3:18-3:21:hint:" + Bundle.ERR_ConvertTextBlockToString())
.applyFix() .applyFix()
.assertCompilable() .assertCompilable()
.assertOutput("package helloworld;\n" .assertOutput("package helloworld;\n"
...@@ -197,7 +197,7 @@ public class ConvertTextBlockToStringTest { ...@@ -197,7 +197,7 @@ public class ConvertTextBlockToStringTest {
.sourceLevel(SourceVersion.latest().name()) .sourceLevel(SourceVersion.latest().name())
.options("--enable-preview") .options("--enable-preview")
.run(ConvertTextBlockToString.class) .run(ConvertTextBlockToString.class)
.findWarning("3:18-3:21:verifier:" + Bundle.ERR_ConvertTextBlockToString()) .findWarning("3:18-3:21:hint:" + Bundle.ERR_ConvertTextBlockToString())
.applyFix() .applyFix()
.assertCompilable() .assertCompilable()
.assertOutput("package helloworld;\n" .assertOutput("package helloworld;\n"
...@@ -228,7 +228,7 @@ public class ConvertTextBlockToStringTest { ...@@ -228,7 +228,7 @@ public class ConvertTextBlockToStringTest {
.sourceLevel(SourceVersion.latest().name()) .sourceLevel(SourceVersion.latest().name())
.options("--enable-preview") .options("--enable-preview")
.run(ConvertTextBlockToString.class) .run(ConvertTextBlockToString.class)
.findWarning("3:18-3:21:verifier:" + Bundle.ERR_ConvertTextBlockToString()) .findWarning("3:18-3:21:hint:" + Bundle.ERR_ConvertTextBlockToString())
.applyFix() .applyFix()
.assertCompilable() .assertCompilable()
.assertOutput("package helloworld;\n" .assertOutput("package helloworld;\n"
...@@ -260,7 +260,7 @@ public class ConvertTextBlockToStringTest { ...@@ -260,7 +260,7 @@ public class ConvertTextBlockToStringTest {
.sourceLevel(SourceVersion.latest().name()) .sourceLevel(SourceVersion.latest().name())
.options("--enable-preview") .options("--enable-preview")
.run(ConvertTextBlockToString.class) .run(ConvertTextBlockToString.class)
.findWarning("3:18-3:21:verifier:" + Bundle.ERR_ConvertTextBlockToString()) .findWarning("3:18-3:21:hint:" + Bundle.ERR_ConvertTextBlockToString())
.applyFix() .applyFix()
.assertCompilable() .assertCompilable()
.assertOutput("package helloworld;\n" .assertOutput("package helloworld;\n"
...@@ -290,7 +290,7 @@ public class ConvertTextBlockToStringTest { ...@@ -290,7 +290,7 @@ public class ConvertTextBlockToStringTest {
.sourceLevel(SourceVersion.latest().name()) .sourceLevel(SourceVersion.latest().name())
.options("--enable-preview") .options("--enable-preview")
.run(ConvertTextBlockToString.class) .run(ConvertTextBlockToString.class)
.findWarning("3:18-3:21:verifier:" + Bundle.ERR_ConvertTextBlockToString()) .findWarning("3:18-3:21:hint:" + Bundle.ERR_ConvertTextBlockToString())
.applyFix() .applyFix()
.assertCompilable() .assertCompilable()
.assertOutput("package helloworld;\n" .assertOutput("package helloworld;\n"
...@@ -321,7 +321,7 @@ public class ConvertTextBlockToStringTest { ...@@ -321,7 +321,7 @@ public class ConvertTextBlockToStringTest {
.sourceLevel(SourceVersion.latest().name()) .sourceLevel(SourceVersion.latest().name())
.options("--enable-preview") .options("--enable-preview")
.run(ConvertTextBlockToString.class) .run(ConvertTextBlockToString.class)
.findWarning("3:18-3:21:verifier:" + Bundle.ERR_ConvertTextBlockToString()) .findWarning("3:18-3:21:hint:" + Bundle.ERR_ConvertTextBlockToString())
.applyFix() .applyFix()
.assertCompilable() .assertCompilable()
.assertOutput("package helloworld;\n" .assertOutput("package helloworld;\n"
...@@ -356,7 +356,7 @@ public class ConvertTextBlockToStringTest { ...@@ -356,7 +356,7 @@ public class ConvertTextBlockToStringTest {
.sourceLevel(SourceVersion.latest().name()) .sourceLevel(SourceVersion.latest().name())
.options("--enable-preview") .options("--enable-preview")
.run(ConvertTextBlockToString.class) .run(ConvertTextBlockToString.class)
.findWarning("3:18-3:21:verifier:" + Bundle.ERR_ConvertTextBlockToString()) .findWarning("3:18-3:21:hint:" + Bundle.ERR_ConvertTextBlockToString())
.applyFix() .applyFix()
.assertCompilable() .assertCompilable()
.assertOutput("package helloworld;\n" .assertOutput("package helloworld;\n"
...@@ -387,7 +387,7 @@ public class ConvertTextBlockToStringTest { ...@@ -387,7 +387,7 @@ public class ConvertTextBlockToStringTest {
.sourceLevel(SourceVersion.latest().name()) .sourceLevel(SourceVersion.latest().name())
.options("--enable-preview") .options("--enable-preview")
.run(ConvertTextBlockToString.class) .run(ConvertTextBlockToString.class)
.findWarning("4:27-4:30:verifier:" + Bundle.ERR_ConvertTextBlockToString()) .findWarning("4:27-4:30:hint:" + Bundle.ERR_ConvertTextBlockToString())
.applyFix() .applyFix()
.assertCompilable() .assertCompilable()
.assertOutput("package test;\n" .assertOutput("package test;\n"
...@@ -419,7 +419,7 @@ public class ConvertTextBlockToStringTest { ...@@ -419,7 +419,7 @@ public class ConvertTextBlockToStringTest {
.sourceLevel(SourceVersion.latest().name()) .sourceLevel(SourceVersion.latest().name())
.options("--enable-preview") .options("--enable-preview")
.run(ConvertTextBlockToString.class) .run(ConvertTextBlockToString.class)
.findWarning("2:27-2:30:verifier:" + Bundle.ERR_ConvertTextBlockToString()) .findWarning("2:27-2:30:hint:" + Bundle.ERR_ConvertTextBlockToString())
.applyFix() .applyFix()
.assertCompilable() .assertCompilable()
.assertOutput("class myClass{\n" .assertOutput("class myClass{\n"
......
...@@ -42,6 +42,7 @@ import * as launcher from './nbcode'; ...@@ -42,6 +42,7 @@ import * as launcher from './nbcode';
import {NbTestAdapter} from './testAdapter'; import {NbTestAdapter} from './testAdapter';
import { asRanges, StatusMessageRequest, ShowStatusMessageParams, QuickPickRequest, InputBoxRequest, TestProgressNotification, DebugConnector, import { asRanges, StatusMessageRequest, ShowStatusMessageParams, QuickPickRequest, InputBoxRequest, TestProgressNotification, DebugConnector,
TextEditorDecorationCreateRequest, TextEditorDecorationSetNotification, TextEditorDecorationDisposeNotification, TextEditorDecorationCreateRequest, TextEditorDecorationSetNotification, TextEditorDecorationDisposeNotification,
SetTextEditorDecorationParams
} from './protocol'; } from './protocol';
import * as launchConfigurations from './launchConfigurations'; import * as launchConfigurations from './launchConfigurations';
...@@ -603,6 +604,7 @@ function doActivateWithJDK(specifiedJDK: string | null, context: ExtensionContex ...@@ -603,6 +604,7 @@ function doActivateWithJDK(specifiedJDK: string | null, context: ExtensionContex
} }
}); });
let decorations = new Map<string, TextEditorDecorationType>(); let decorations = new Map<string, TextEditorDecorationType>();
let decorationParamsByUri = new Map<vscode.Uri, SetTextEditorDecorationParams>();
c.onRequest(TextEditorDecorationCreateRequest.type, param => { c.onRequest(TextEditorDecorationCreateRequest.type, param => {
let decorationType = vscode.window.createTextEditorDecorationType(param); let decorationType = vscode.window.createTextEditorDecorationType(param);
decorations.set(decorationType.key, decorationType); decorations.set(decorationType.key, decorationType);
...@@ -616,13 +618,32 @@ function doActivateWithJDK(specifiedJDK: string | null, context: ExtensionContex ...@@ -616,13 +618,32 @@ function doActivateWithJDK(specifiedJDK: string | null, context: ExtensionContex
); );
if (editorsWithUri.length > 0) { if (editorsWithUri.length > 0) {
editorsWithUri[0].setDecorations(decorationType, asRanges(param.ranges)); editorsWithUri[0].setDecorations(decorationType, asRanges(param.ranges));
decorationParamsByUri.set(editorsWithUri[0].document.uri, param);
} }
} }
}); });
let disposableListener = vscode.window.onDidChangeVisibleTextEditors(editors => {
editors.forEach(editor => {
let decorationParams = decorationParamsByUri.get(editor.document.uri);
if (decorationParams) {
let decorationType = decorations.get(decorationParams.key);
if (decorationType) {
editor.setDecorations(decorationType, asRanges(decorationParams.ranges));
}
}
});
});
context.subscriptions.push(disposableListener);
c.onNotification(TextEditorDecorationDisposeNotification.type, param => { c.onNotification(TextEditorDecorationDisposeNotification.type, param => {
let decorationType = decorations.get(param); let decorationType = decorations.get(param);
if (decorationType) { if (decorationType) {
decorations.delete(param);
decorationType.dispose(); decorationType.dispose();
decorationParamsByUri.forEach((value, key, map) => {
if (value.key == param) {
map.delete(key);
}
});
} }
}); });
handleLog(log, 'Language Client: Ready'); handleLog(log, 'Language Client: Ready');
......
...@@ -43,7 +43,7 @@ javac.classpath=\ ...@@ -43,7 +43,7 @@ javac.classpath=\
# Space-separated list of extra javac options # Space-separated list of extra javac options
javac.compilerargs= javac.compilerargs=
javac.deprecation=false javac.deprecation=false
javac.source=1.5 javac.source=1.6
javac.target=1.8 javac.target=1.8
javac.test.classpath=\ javac.test.classpath=\
${javac.classpath}:\ ${javac.classpath}:\
......
...@@ -42,7 +42,7 @@ javac.classpath=\ ...@@ -42,7 +42,7 @@ javac.classpath=\
# Space-separated list of extra javac options # Space-separated list of extra javac options
javac.compilerargs= javac.compilerargs=
javac.deprecation=false javac.deprecation=false
javac.source=1.5 javac.source=1.6
javac.target=1.8 javac.target=1.8
javac.test.classpath=\ javac.test.classpath=\
${javac.classpath}:\ ${javac.classpath}:\
......
...@@ -100,7 +100,7 @@ nb.target.build=jar ...@@ -100,7 +100,7 @@ nb.target.build=jar
# global script # global script
# * ${nb.custom.tasks.cls} - points the netbeans project's build script to the # * ${nb.custom.tasks.cls} - points the netbeans project's build script to the
# location of the built custom tasks # location of the built custom tasks
nb.platform.home=-Dplatforms.JDK_1.5.home=${java.home}/.. nb.platform.home=-Dplatforms.JDK_1.5.home=${java.home}
nb.platform.home.macos=-Dplatforms.JDK_1.5.home=${java.home} nb.platform.home.macos=-Dplatforms.JDK_1.5.home=${java.home}
nb.ignore.native=-Dignore.native=true nb.ignore.native=-Dignore.native=true
nb.no.dependencies=-Dno.dependencies=true nb.no.dependencies=-Dno.dependencies=true
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment