Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Readable
Record
Records
ReflectiveOperationException
Runnable
Runtime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,8 @@
*/
package org.netbeans.modules.java.completion;

import java.util.ArrayList;
import java.util.List;
import javax.lang.model.SourceVersion;
import javax.swing.event.ChangeListener;
import org.junit.Ignore;
import org.netbeans.junit.NbTestSuite;
import org.netbeans.modules.java.source.parsing.JavacParser;
import org.netbeans.spi.java.queries.CompilerOptionsQueryImplementation;
import org.openide.filesystems.FileObject;
import org.openide.util.lookup.ServiceProvider;

/**
*
* @author arusinha
Expand All @@ -40,100 +32,12 @@ public JavaCompletionTask114FeaturesTest(String testName) {
super(testName);
}

public static NbTestSuite suite() {
NbTestSuite suite = new NbTestSuite();
try {
SourceVersion.valueOf("RELEASE_14"); //NOI18N
suite.addTestSuite(JavaCompletionTask114FeaturesTest.class);
} catch (IllegalArgumentException ex) {
//OK, no RELEASE_13, skip tests
suite.addTest(new JavaCompletionTask114FeaturesTest("noop")); //NOI18N
}
return suite;
}

public void testBindingUse() throws Exception {
performTest("GenericMethodInvocation", 1231, "boolean b = argO instanceof String str && st", "BindingUse.pass", SOURCE_LEVEL);
}


public void testBeforeLeftRecordBraces() throws Exception {
TestCompilerOptionsQueryImplementation.EXTRA_OPTIONS.add("--enable-preview");
performTest("Records", 896, null, "implementsKeyword.pass", getLatestSource());
}

public void testBeforeRecParamsLeftParen() throws Exception {
TestCompilerOptionsQueryImplementation.EXTRA_OPTIONS.add("--enable-preview");
performTest("Records", 892, null, "empty.pass", getLatestSource());
}

public void testAfterTypeParamInRecParam() throws Exception {
performTest("Records", 890, null, "extendsKeyword.pass", SOURCE_LEVEL);
}

// TODO "compact source file" feature wraps the compilation unit into additional "final class Test"?
@Ignore
public void testInsideRecAfterStaticKeyWord() throws Exception {
performTest("Records", 918, "R", "typesRecordStaticMembersAndVars.pass", SOURCE_LEVEL);
}

public void testAnnotationInRecordParam() throws Exception {
performTest("Records", 999, null, "override.pass", SOURCE_LEVEL);
}

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());
}

public void noop() {
}

static {
JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
}

private String getLatestSource(){
return SourceVersion.latest().name().substring(SourceVersion.latest().name().indexOf("_")+1);
}
@ServiceProvider(service = CompilerOptionsQueryImplementation.class, position = 100)
public static class TestCompilerOptionsQueryImplementation implements CompilerOptionsQueryImplementation {

private static final List<String> EXTRA_OPTIONS = new ArrayList<>();

@Override
public CompilerOptionsQueryImplementation.Result getOptions(FileObject file) {
return new CompilerOptionsQueryImplementation.Result() {
@Override
public List<? extends String> getArguments() {
return EXTRA_OPTIONS;
}

@Override
public void addChangeListener(ChangeListener listener) {
}

@Override
public void removeChangeListener(ChangeListener listener) {
}
};
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,46 @@ public void testInstanceofPatternCompletion_3() throws Exception {
performTest("InstanceofPattern", 926, null, "stringContent.pass", SOURCE_LEVEL);
}

public void testBeforeLeftRecordBraces() throws Exception {
performTest("Records", 896, null, "implementsKeyword.pass", SOURCE_LEVEL);
}

public void testBeforeRecParamsLeftParen() throws Exception {
performTest("Records", 892, null, "empty.pass", SOURCE_LEVEL);
}

public void testAfterTypeParamInRecParam() throws Exception {
performTest("Records", 890, null, "extendsKeyword.pass", SOURCE_LEVEL);
}

public void testInsideRecAfterStaticKeyWord() throws Exception {
performTest("Records", 918, "R", "typesRecordStaticMembersAndVars.pass", SOURCE_LEVEL);
}

public void testAnnotationInRecordParam() throws Exception {
performTest("Records", 999, null, "override.pass", SOURCE_LEVEL);
}

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 {
performTest("Records", 1071, null, "recordVariableSuggestion.pass", SOURCE_LEVEL);
}

static {
JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = true;
}
Expand Down