Skip to content

Commit

Permalink
Update target platform to I20220203-0300
Browse files Browse the repository at this point in the history
Fixes eclipse-jdtls#1971

Signed-off-by: Snjezana Peco <[email protected]>
  • Loading branch information
snjeza committed Feb 3, 2022
1 parent 890da66 commit c49f457
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 1 deletion.
2 changes: 1 addition & 1 deletion org.eclipse.jdt.ls.target/org.eclipse.jdt.ls.tp.target
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<unit id="org.eclipse.equinox.sdk.feature.group" version="0.0.0"/>
<unit id="org.eclipse.jdt.source.feature.group" version="0.0.0"/>
<unit id="org.eclipse.sdk.feature.group" version="0.0.0"/>
<repository location="https://download.eclipse.org/eclipse/updates/4.23-I-builds/I20220105-1800/"/>
<repository location="https://download.eclipse.org/eclipse/updates/4.23-I-builds/I20220203-0300/"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="org.eclipse.xtend.sdk.feature.group" version="0.0.0"/>
Expand Down
28 changes: 28 additions & 0 deletions org.eclipse.jdt.ls.tests/projects/maven/typemismatch/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.sample</groupId>
<artifactId>typemismatch</artifactId>
<version>0.0.1-SNAPSHOT</version>

<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.0.1-jre</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package test;

public enum IndexType {
INDEX1("Index1"),
INDEX2("Index2");

private String name;

private IndexType(String name) {
this.name = name;
}

public String getName() {
return name;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package test;

import static java.util.stream.Collectors.collectingAndThen;
import static java.util.stream.Collectors.toMap;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;

import com.google.common.collect.ImmutableMap;

public class Test {
private static final Map<String, IndexType> INDEX_TYPE_MAP = Arrays.stream(IndexType.values())
.collect(collectingAndThen(toMap(Enum::toString, Function.identity()), ImmutableMap::copyOf));

private static final Map<String, IndexType> INDEX_TYPE_MAP2 = ImmutableMap.copyOf(
Arrays.stream(IndexType.values())
.collect(toMap(Enum::toString, Function.identity())));

}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,41 @@ public void testTest() throws Exception {
assertTrue("There is a problem", handler.getProblems().size() == 0);
}

@Test
public void typemismatchTest() throws Exception {
IProject project = importMavenProject("typemismatch");
IJavaProject javaProject = JavaCore.create(project);
IType type = javaProject.findType("test.Test");
ICompilationUnit cu = type.getCompilationUnit();
openDocument(cu, cu.getSource(), 1);
final DiagnosticsHandler handler = new DiagnosticsHandler(javaClient, cu);
WorkingCopyOwner wcOwner = getWorkingCopy(handler);
cu.reconcile(ICompilationUnit.NO_AST, true, wcOwner, null);
long size = handler.getProblems().stream().filter(p -> p.isError()).count();
assertTrue("There is an error", size == 0);
String source = cu.getSource();
source = source.replace("Test {", "Test { ");
cu.getBuffer().setContents(source);
cu.reconcile(ICompilationUnit.NO_AST, true, wcOwner, null);
size = handler.getProblems().stream().filter(p -> p.isError()).count();
assertTrue("There is an error", size == 0);
source = source.replace("Test { ", "Test { ");
cu.getBuffer().setContents(source);
cu.reconcile(ICompilationUnit.NO_AST, true, wcOwner, null);
size = handler.getProblems().stream().filter(p -> p.isError()).count();
assertTrue("There is an error", size == 0);
source = source.replace("Test { ", "Test { ");
cu.getBuffer().setContents(source);
cu.reconcile(ICompilationUnit.NO_AST, true, wcOwner, null);
size = handler.getProblems().stream().filter(p -> p.isError()).count();
assertTrue("There is an error", size == 0);
source = source.replace("Test { ", "Test {");
cu.getBuffer().setContents(source);
cu.reconcile(ICompilationUnit.NO_AST, true, wcOwner, null);
size = handler.getProblems().stream().filter(p -> p.isError()).count();
assertTrue("There is an error", size == 0);
}

private void openDocument(ICompilationUnit cu, String content, int version) {
DidOpenTextDocumentParams openParms = new DidOpenTextDocumentParams();
TextDocumentItem textDocument = new TextDocumentItem();
Expand Down

0 comments on commit c49f457

Please sign in to comment.