summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorGeorge Fraser <george@fivetran.com>2018-12-15 00:27:34 -0800
committerGeorge Fraser <george@fivetran.com>2018-12-15 00:27:34 -0800
commit1fb4032a2389dae6000ee5da33cf4b9071d07d0b (patch)
treefcd555ec6415e1eebfe24a713f2b3c1c136adc42 /src/test
parent3dbfd1e91f81967f80984ec1311474ffe70c0346 (diff)
downloadjava-language-server-1fb4032a2389dae6000ee5da33cf4b9071d07d0b.zip
Optimization
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/javacs/JavaCompilerServiceTest.java73
1 files changed, 30 insertions, 43 deletions
diff --git a/src/test/java/org/javacs/JavaCompilerServiceTest.java b/src/test/java/org/javacs/JavaCompilerServiceTest.java
index 43547d5..d5cf119 100644
--- a/src/test/java/org/javacs/JavaCompilerServiceTest.java
+++ b/src/test/java/org/javacs/JavaCompilerServiceTest.java
@@ -85,7 +85,11 @@ public class JavaCompilerServiceTest {
public void identifiers() {
var found =
compiler.scopeMembers(
- URI.create("/CompleteIdentifiers.java"), contents("/CompleteIdentifiers.java"), 13, 21);
+ URI.create("/CompleteIdentifiers.java"),
+ contents("/CompleteIdentifiers.java"),
+ 13,
+ 21,
+ "complete");
var names = elementNames(found);
assertThat(names, hasItem("completeLocal"));
assertThat(names, hasItem("completeParam"));
@@ -95,13 +99,14 @@ public class JavaCompilerServiceTest {
assertThat(names, hasItem("completeInnerField"));
assertThat(names, hasItem("completeOuterField"));
assertThat(names, hasItem("completeOuterStatic"));
- assertThat(names, hasItem("CompleteIdentifiers"));
+ // assertThat(names, hasItem("CompleteIdentifiers"));
}
@Test
public void identifiersInMiddle() {
var found =
- compiler.scopeMembers(URI.create("/CompleteInMiddle.java"), contents("/CompleteInMiddle.java"), 13, 21);
+ compiler.scopeMembers(
+ URI.create("/CompleteInMiddle.java"), contents("/CompleteInMiddle.java"), 13, 21, "complete");
var names = elementNames(found);
assertThat(names, hasItem("completeLocal"));
assertThat(names, hasItem("completeParam"));
@@ -111,18 +116,14 @@ public class JavaCompilerServiceTest {
assertThat(names, hasItem("completeInnerField"));
assertThat(names, hasItem("completeOuterField"));
assertThat(names, hasItem("completeOuterStatic"));
- assertThat(names, hasItem("CompleteInMiddle"));
+ // assertThat(names, hasItem("CompleteInMiddle"));
}
@Test
public void completeIdentifiers() {
var found =
compiler.completions(
- URI.create("/CompleteIdentifiers.java"),
- contents("/CompleteIdentifiers.java"),
- 13,
- 21,
- Integer.MAX_VALUE)
+ URI.create("/CompleteIdentifiers.java"), contents("/CompleteIdentifiers.java"), 13, 21)
.items;
var names = completionNames(found);
assertThat(names, hasItem("completeLocal"));
@@ -149,12 +150,7 @@ public class JavaCompilerServiceTest {
@Test
public void completeMembers() {
var found =
- compiler.completions(
- URI.create("/CompleteMembers.java"),
- contents("/CompleteMembers.java"),
- 3,
- 15,
- Integer.MAX_VALUE)
+ compiler.completions(URI.create("/CompleteMembers.java"), contents("/CompleteMembers.java"), 3, 15)
.items;
var names = completionNames(found);
assertThat(names, hasItem("subMethod"));
@@ -166,11 +162,7 @@ public class JavaCompilerServiceTest {
public void completeExpression() {
var found =
compiler.completions(
- URI.create("/CompleteExpression.java"),
- contents("/CompleteExpression.java"),
- 3,
- 37,
- Integer.MAX_VALUE)
+ URI.create("/CompleteExpression.java"), contents("/CompleteExpression.java"), 3, 37)
.items;
var names = completionNames(found);
assertThat(names, hasItem("instanceMethod"));
@@ -181,13 +173,7 @@ public class JavaCompilerServiceTest {
@Test
public void completeClass() {
var found =
- compiler.completions(
- URI.create("/CompleteClass.java"),
- contents("/CompleteClass.java"),
- 3,
- 23,
- Integer.MAX_VALUE)
- .items;
+ compiler.completions(URI.create("/CompleteClass.java"), contents("/CompleteClass.java"), 3, 23).items;
var names = completionNames(found);
assertThat(names, hasItems("staticMethod", "staticField"));
assertThat(names, hasItems("class"));
@@ -198,12 +184,7 @@ public class JavaCompilerServiceTest {
@Test
public void completeImports() {
var found =
- compiler.completions(
- URI.create("/CompleteImports.java"),
- contents("/CompleteImports.java"),
- 1,
- 18,
- Integer.MAX_VALUE)
+ compiler.completions(URI.create("/CompleteImports.java"), contents("/CompleteImports.java"), 1, 18)
.items;
var names = completionNames(found);
assertThat(names, hasItem("List"));
@@ -232,16 +213,16 @@ public class JavaCompilerServiceTest {
@Test
public void references() {
- ReportReferencesProgress rrp = new ReportReferencesProgress() {
- @Override
- public void scanForPotentialReferences(int nScanned, int nFiles) {}
-
- @Override
- public void checkPotentialReferences(int nCompiled, int nPotential) {}
- };
- var refs =
- compiler.references(
- URI.create("/GotoDefinition.java"), contents("/GotoDefinition.java"), 6, 13, rrp);
+ ReportReferencesProgress rrp =
+ new ReportReferencesProgress() {
+ @Override
+ public void scanForPotentialReferences(int nScanned, int nFiles) {}
+
+ @Override
+ public void checkPotentialReferences(int nCompiled, int nPotential) {}
+ };
+ var refs =
+ compiler.references(URI.create("/GotoDefinition.java"), contents("/GotoDefinition.java"), 6, 13, rrp);
boolean found = false;
for (var t : refs) {
var unit = t.getCompilationUnit();
@@ -291,4 +272,10 @@ public class JavaCompilerServiceTest {
compiler.fixImports(resourceUri("/MissingImport.java"), contents("/MissingImport.java")).fixedImports;
assertThat(qualifiedNames, hasItem("java.util.List"));
}
+
+ @Test
+ public void matchesPartialName() {
+ assertTrue(JavaCompilerService.matchesPartialName("foobar", "foo"));
+ assertFalse(JavaCompilerService.matchesPartialName("foo", "foobar"));
+ }
}