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 {
&& env.getController().getTreeUtilities().getPathElementOfKind(Tree.Kind.INTERFACE, env.getPath()) != null) {
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));
}
addPrimitiveTypeKeywords(env);
......@@ -4682,7 +4682,7 @@ public final class JavaCompletionTask<T> extends BaseTask {
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));
}
if (Utilities.startsWith(RETURN_KEYWORD, prefix)) {
......
......@@ -33,7 +33,7 @@ import org.openide.util.lookup.ServiceProvider;
*/
public class JavaCompletionTask114FeaturesTest extends CompletionTestBase {
private static String SOURCE_LEVEL = "14"; //NOI18N
private static final String SOURCE_LEVEL = "14"; //NOI18N
public JavaCompletionTask114FeaturesTest(String testName) {
super(testName);
......@@ -78,10 +78,22 @@ public class JavaCompletionTask114FeaturesTest extends CompletionTestBase {
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);
}
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 {
TestCompilerOptionsQueryImplementation.EXTRA_OPTIONS.add("--enable-preview");
performTest("Records", 1071, null, "recordVariableSuggestion.pass", getLatestSource());
......
......@@ -28,6 +28,7 @@ import org.netbeans.api.java.source.CompilationInfo;
import org.netbeans.api.lexer.TokenSequence;
import org.netbeans.spi.editor.hints.ErrorDescription;
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.Hint;
import org.netbeans.spi.java.hints.HintContext;
......@@ -35,15 +36,15 @@ import org.netbeans.spi.java.hints.JavaFix;
import org.netbeans.spi.java.hints.TriggerTreeKind;
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({
"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 {
@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) {
TokenSequence<?> ts = ctx.getInfo().getTokenHierarchy().tokenSequence();
if (ts == null) {
......@@ -89,8 +90,8 @@ public class ConvertTextBlockToString {
protected void performRewrite(TransformationContext ctx) {
ExpressionTree ext = ctx.getWorkingCopy().getTreeMaker().Literal(orignalStringArr[orignalStringArr.length - 1]);
if (orignalStringArr.length > 1) {
ext = ctx.getWorkingCopy().getTreeMaker().Binary(Tree.Kind.PLUS, buildTree(orignalStringArr, orignalStringArr.length - 2, ctx), (ExpressionTree) ext);
if (orignalStringArr[orignalStringArr.length - 1].equals("")) {
ext = ctx.getWorkingCopy().getTreeMaker().Binary(Tree.Kind.PLUS, buildTree(orignalStringArr, orignalStringArr.length - 2, ctx), ext);
if (orignalStringArr[orignalStringArr.length - 1].isEmpty()) {
ext = (((BinaryTree) ext).getLeftOperand());
}
}
......
......@@ -55,7 +55,7 @@ public class ConvertTextBlockToStringTest {
.sourceLevel(SourceVersion.latest().name())
.options("--enable-preview")
.run(ConvertTextBlockToString.class)
.findWarning("3:18-3:21:verifier:" + Bundle.ERR_ConvertTextBlockToString())
.findWarning("3:18-3:21:hint:" + Bundle.ERR_ConvertTextBlockToString())
.applyFix()
.assertCompilable()
.assertOutput("package helloworld;\n"
......@@ -85,7 +85,7 @@ public class ConvertTextBlockToStringTest {
.sourceLevel(SourceVersion.latest().name())
.options("--enable-preview")
.run(ConvertTextBlockToString.class)
.findWarning("3:18-3:21:verifier:" + Bundle.ERR_ConvertTextBlockToString())
.findWarning("3:18-3:21:hint:" + Bundle.ERR_ConvertTextBlockToString())
.applyFix()
.assertCompilable()
.assertOutput("package helloworld;\n"
......@@ -121,7 +121,7 @@ public class ConvertTextBlockToStringTest {
.sourceLevel(SourceVersion.latest().name())
.options("--enable-preview")
.run(ConvertTextBlockToString.class)
.findWarning("3:18-3:21:verifier:" + Bundle.ERR_ConvertTextBlockToString())
.findWarning("3:18-3:21:hint:" + Bundle.ERR_ConvertTextBlockToString())
.applyFix()
.assertCompilable()
.assertOutput("package helloworld;\n"
......@@ -156,7 +156,7 @@ public class ConvertTextBlockToStringTest {
.sourceLevel(SourceVersion.latest().name())
.options("--enable-preview")
.run(ConvertTextBlockToString.class)
.findWarning("3:18-3:21:verifier:" + Bundle.ERR_ConvertTextBlockToString())
.findWarning("3:18-3:21:hint:" + Bundle.ERR_ConvertTextBlockToString())
.applyFix()
.assertCompilable()
.assertOutput("package helloworld;\n"
......@@ -197,7 +197,7 @@ public class ConvertTextBlockToStringTest {
.sourceLevel(SourceVersion.latest().name())
.options("--enable-preview")
.run(ConvertTextBlockToString.class)
.findWarning("3:18-3:21:verifier:" + Bundle.ERR_ConvertTextBlockToString())
.findWarning("3:18-3:21:hint:" + Bundle.ERR_ConvertTextBlockToString())
.applyFix()
.assertCompilable()
.assertOutput("package helloworld;\n"
......@@ -228,7 +228,7 @@ public class ConvertTextBlockToStringTest {
.sourceLevel(SourceVersion.latest().name())
.options("--enable-preview")
.run(ConvertTextBlockToString.class)
.findWarning("3:18-3:21:verifier:" + Bundle.ERR_ConvertTextBlockToString())
.findWarning("3:18-3:21:hint:" + Bundle.ERR_ConvertTextBlockToString())
.applyFix()
.assertCompilable()
.assertOutput("package helloworld;\n"
......@@ -260,7 +260,7 @@ public class ConvertTextBlockToStringTest {
.sourceLevel(SourceVersion.latest().name())
.options("--enable-preview")
.run(ConvertTextBlockToString.class)
.findWarning("3:18-3:21:verifier:" + Bundle.ERR_ConvertTextBlockToString())
.findWarning("3:18-3:21:hint:" + Bundle.ERR_ConvertTextBlockToString())
.applyFix()
.assertCompilable()
.assertOutput("package helloworld;\n"
......@@ -290,7 +290,7 @@ public class ConvertTextBlockToStringTest {
.sourceLevel(SourceVersion.latest().name())
.options("--enable-preview")
.run(ConvertTextBlockToString.class)
.findWarning("3:18-3:21:verifier:" + Bundle.ERR_ConvertTextBlockToString())
.findWarning("3:18-3:21:hint:" + Bundle.ERR_ConvertTextBlockToString())
.applyFix()
.assertCompilable()
.assertOutput("package helloworld;\n"
......@@ -321,7 +321,7 @@ public class ConvertTextBlockToStringTest {
.sourceLevel(SourceVersion.latest().name())
.options("--enable-preview")
.run(ConvertTextBlockToString.class)
.findWarning("3:18-3:21:verifier:" + Bundle.ERR_ConvertTextBlockToString())
.findWarning("3:18-3:21:hint:" + Bundle.ERR_ConvertTextBlockToString())
.applyFix()
.assertCompilable()
.assertOutput("package helloworld;\n"
......@@ -356,7 +356,7 @@ public class ConvertTextBlockToStringTest {
.sourceLevel(SourceVersion.latest().name())
.options("--enable-preview")
.run(ConvertTextBlockToString.class)
.findWarning("3:18-3:21:verifier:" + Bundle.ERR_ConvertTextBlockToString())
.findWarning("3:18-3:21:hint:" + Bundle.ERR_ConvertTextBlockToString())
.applyFix()
.assertCompilable()
.assertOutput("package helloworld;\n"
......@@ -387,7 +387,7 @@ public class ConvertTextBlockToStringTest {
.sourceLevel(SourceVersion.latest().name())
.options("--enable-preview")
.run(ConvertTextBlockToString.class)
.findWarning("4:27-4:30:verifier:" + Bundle.ERR_ConvertTextBlockToString())
.findWarning("4:27-4:30:hint:" + Bundle.ERR_ConvertTextBlockToString())
.applyFix()
.assertCompilable()
.assertOutput("package test;\n"
......@@ -419,7 +419,7 @@ public class ConvertTextBlockToStringTest {
.sourceLevel(SourceVersion.latest().name())
.options("--enable-preview")
.run(ConvertTextBlockToString.class)
.findWarning("2:27-2:30:verifier:" + Bundle.ERR_ConvertTextBlockToString())
.findWarning("2:27-2:30:hint:" + Bundle.ERR_ConvertTextBlockToString())
.applyFix()
.assertCompilable()
.assertOutput("class myClass{\n"
......
......@@ -42,6 +42,7 @@ import * as launcher from './nbcode';
import {NbTestAdapter} from './testAdapter';
import { asRanges, StatusMessageRequest, ShowStatusMessageParams, QuickPickRequest, InputBoxRequest, TestProgressNotification, DebugConnector,
TextEditorDecorationCreateRequest, TextEditorDecorationSetNotification, TextEditorDecorationDisposeNotification,
SetTextEditorDecorationParams
} from './protocol';
import * as launchConfigurations from './launchConfigurations';
......@@ -603,6 +604,7 @@ function doActivateWithJDK(specifiedJDK: string | null, context: ExtensionContex
}
});
let decorations = new Map<string, TextEditorDecorationType>();
let decorationParamsByUri = new Map<vscode.Uri, SetTextEditorDecorationParams>();
c.onRequest(TextEditorDecorationCreateRequest.type, param => {
let decorationType = vscode.window.createTextEditorDecorationType(param);
decorations.set(decorationType.key, decorationType);
......@@ -616,13 +618,32 @@ function doActivateWithJDK(specifiedJDK: string | null, context: ExtensionContex
);
if (editorsWithUri.length > 0) {
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 => {
let decorationType = decorations.get(param);
if (decorationType) {
decorations.delete(param);
decorationType.dispose();
decorationParamsByUri.forEach((value, key, map) => {
if (value.key == param) {
map.delete(key);
}
});
}
});
handleLog(log, 'Language Client: Ready');
......
......@@ -43,7 +43,7 @@ javac.classpath=\
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
javac.source=1.5
javac.source=1.6
javac.target=1.8
javac.test.classpath=\
${javac.classpath}:\
......
......@@ -42,7 +42,7 @@ javac.classpath=\
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
javac.source=1.5
javac.source=1.6
javac.target=1.8
javac.test.classpath=\
${javac.classpath}:\
......
......@@ -100,7 +100,7 @@ nb.target.build=jar
# global script
# * ${nb.custom.tasks.cls} - points the netbeans project's build script to the
# 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.ignore.native=-Dignore.native=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