Skip to content

Commit

Permalink
Use Java 17
Browse files Browse the repository at this point in the history
  • Loading branch information
mickaelistria committed Oct 20, 2022
1 parent e64be91 commit f6aa142
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 71 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/windowsPR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ jobs:
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
java-version: 17
- name: Build with Maven
run: mvn -B verify --file lemminx-maven/pom.xml -fae
2 changes: 1 addition & 1 deletion .project
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>lemminx-maven</name>
<name>lemminx-maven-p</name>
<comment></comment>
<projects>
</projects>
Expand Down
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pipeline{
agent any
tools {
maven 'apache-maven-latest'
jdk 'openjdk-jdk11-latest'
jdk 'openjdk-jdk17-latest'
}
environment {
MAVEN_HOME = "$WORKSPACE/.m2/"
Expand Down
2 changes: 2 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# LemMinx-Maven Releases

Starting from 0.6.0, the release notes are visible at https://github.com/eclipse/lemminx-maven/releases

### 0.5.2

* 📅 Release Date: May 18th, 2022
Expand Down
4 changes: 2 additions & 2 deletions lemminx-maven/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
</licenses>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<lemminx.maven.indexDirectory>${project.build.directory}/test-index</lemminx.maven.indexDirectory>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,7 @@ public URIResolverExtensionManager getUriResolveExtentionManager() {
public void didChangeWorkspaceFolders(URI[] added, URI[] removed) {
initialize();
WorkspaceReader workspaceReader = mavenRequest.getWorkspaceReader();
if (workspaceReader instanceof MavenLemminxWorkspaceReader) {
MavenLemminxWorkspaceReader reader = (MavenLemminxWorkspaceReader)workspaceReader;
if (workspaceReader instanceof MavenLemminxWorkspaceReader reader) {
Collection<URI> projectsToAdd = computeAddedWorkspaceProjects(added != null? added : new URI[0]);
Collection<URI> projectsToRemove = computeRemovedWorkspaceProjects(removed != null ? removed : new URI[0]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,9 @@ public InputStream getInputStream() throws IOException {
}
} catch (ProjectBuildingException e) {
if (e.getResults() == null) {
if (e.getCause() instanceof ModelBuildingException) {
if (e.getCause() instanceof ModelBuildingException modelBuildingException) {
// Try to manually build a minimal project from the document to collect lower-level
// errors and to have something usable in cache for most basic operations
ModelBuildingException modelBuildingException = (ModelBuildingException) e.getCause();
problems.addAll(modelBuildingException.getProblems());
File file = new File(uri);
try (ByteArrayInputStream documentStream = new ByteArrayInputStream(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,8 @@ public int hashCode() {

@Override
public boolean equals(Object obj) {
if (!(obj instanceof MojoParameter)) {
return false;
}
MojoParameter otherMojo = (MojoParameter) obj;

return this.isRequired() == otherMojo.isRequired() //
return obj instanceof MojoParameter otherMojo //
&& this.isRequired() == otherMojo.isRequired() //
&& this.isMap() == otherMojo.isMap() //
&& this.isMultiple() == otherMojo.isMultiple() //
&& Objects.equals(this.type, otherMojo.type) //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,21 +422,15 @@ private GAVInsertionStrategy computeGAVInsertionStrategy(ICompletionRequest requ
if (request.getParentElement() == null) {
return null;
}
switch (request.getParentElement().getLocalName()) {
case DEPENDENCIES_ELT:
return new GAVInsertionStrategy.NodeWithChildrenInsertionStrategy(DEPENDENCY_ELT);
case DEPENDENCY_ELT:
return GAVInsertionStrategy.CHILDREN_ELEMENTS;
case PLUGINS_ELT:
return new GAVInsertionStrategy.NodeWithChildrenInsertionStrategy(PLUGIN_ELT);
case PLUGIN_ELT:
return GAVInsertionStrategy.CHILDREN_ELEMENTS;
case ARTIFACT_ID_ELT:
return GAVInsertionStrategy.ELEMENT_VALUE_AND_SIBLING;
case PARENT_ELT:
return GAVInsertionStrategy.CHILDREN_ELEMENTS;
}
return GAVInsertionStrategy.ELEMENT_VALUE_AND_SIBLING;
return switch (request.getParentElement().getLocalName()) {
case DEPENDENCIES_ELT -> new GAVInsertionStrategy.NodeWithChildrenInsertionStrategy(DEPENDENCY_ELT);
case DEPENDENCY_ELT -> GAVInsertionStrategy.CHILDREN_ELEMENTS;
case PLUGINS_ELT -> new GAVInsertionStrategy.NodeWithChildrenInsertionStrategy(PLUGIN_ELT);
case PLUGIN_ELT -> GAVInsertionStrategy.CHILDREN_ELEMENTS;
case ARTIFACT_ID_ELT -> GAVInsertionStrategy.ELEMENT_VALUE_AND_SIBLING;
case PARENT_ELT -> GAVInsertionStrategy.CHILDREN_ELEMENTS;
default -> GAVInsertionStrategy.ELEMENT_VALUE_AND_SIBLING;
};
}

private Optional<MavenProject> computeFilesystemParent(ICompletionRequest request) {
Expand Down Expand Up @@ -581,8 +575,8 @@ private CompletionItem toGAVCompletionItem(ArtifactWithDescription artifactInfo,
String newText = "";
String suffix = "";
String gavElementsIndent = request.getLineIndentInfo().getWhitespacesIndent();
if (strategy instanceof GAVInsertionStrategy.NodeWithChildrenInsertionStrategy) {
String elementName = ((GAVInsertionStrategy.NodeWithChildrenInsertionStrategy) strategy).elementName;
if (strategy instanceof GAVInsertionStrategy.NodeWithChildrenInsertionStrategy nodeWithChildren) {
String elementName = nodeWithChildren.elementName;
gavElementsIndent += DOMUtils.getOneLevelIndent(request);
newText += "<" + elementName + ">" + request.getLineIndentInfo().getLineDelimiter()
+ gavElementsIndent;
Expand Down Expand Up @@ -1071,8 +1065,7 @@ private void internalCollectWorkspaceArtifacts(ICompletionRequest request, Colle
.map(ArtifactWithDescription::new) //
.forEach(artifactInfosCollector::add);
break;
case GROUP_ID_ELT:
case VERSION_ELT:
case GROUP_ID_ELT, VERSION_ELT:
plugin.getProjectCache().getProjects().stream() //
.filter(a -> artifactIdFilter == null || artifactIdFilter.equals(a.getArtifactId())) //
.map(ArtifactWithDescription::new) //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package org.eclipse.lemminx.extensions.maven.participants.diagnostics;

import org.eclipse.lemminx.commons.BadLocationException;
import org.eclipse.lemminx.dom.DOMAttr;
import org.eclipse.lemminx.dom.DOMDocument;
import org.eclipse.lemminx.dom.DOMElement;
import org.eclipse.lemminx.dom.DOMNode;
Expand Down Expand Up @@ -90,4 +91,9 @@ public <T> T getComponent(Class clazz) {
return null;
}

@Override
public DOMAttr getCurrentAttribute() {
return node instanceof DOMAttr attr ? attr : null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,11 @@ private Diagnostic toDiagnostic(@Nonnull ModelProblem problem) {
}

private DiagnosticSeverity toDiagnosticSeverity(Severity severity) {
switch (severity) {
case ERROR:
case FATAL:
return DiagnosticSeverity.Error;
case WARNING:
return DiagnosticSeverity.Warning;
}
return DiagnosticSeverity.Information;
return switch (severity) {
case ERROR, FATAL -> DiagnosticSeverity.Error;
case WARNING -> DiagnosticSeverity.Warning;
default -> DiagnosticSeverity.Information;
};
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,7 @@ public Hover onTag(IHoverRequest request) throws Exception {
}

// TODO: Get rid of this?
switch (parent.getLocalName()) {
case CONFIGURATION_ELT:
return collectPluginConfiguration(request);
default:
break;
}

return null;
return CONFIGURATION_ELT.equals(parent.getLocalName()) ? collectPluginConfiguration(request) : null;
}

@Override
Expand All @@ -125,16 +118,14 @@ public Hover onText(IHoverRequest request) throws Exception {
MavenProject p = plugin.getProjectCache().getLastSuccessfulMavenProject(request.getXMLDocument());
Dependency artifactToSearch = ParticipantUtils.getArtifactToSearch(p, request);

switch (parent.getLocalName()) {
case GROUP_ID_ELT:
case ARTIFACT_ID_ELT:
case VERSION_ELT:
return switch (parent.getLocalName()) {
case GROUP_ID_ELT, ARTIFACT_ID_ELT, VERSION_ELT -> {
Hover hover = isParentDeclaration && p != null && p.getParent() != null ? hoverForProject(request,
p.getParent(), ParticipantUtils.isWellDefinedDependency(artifactToSearch)) : null;
if (hover == null) {
Artifact artifact = ParticipantUtils.findWorkspaceArtifact(plugin, request, artifactToSearch);
if (artifact != null && artifact.getFile() != null) {
return hoverForProject(request,
yield hoverForProject(request,
plugin.getProjectCache().getSnapshotProject(artifact.getFile()).orElse(null),
ParticipantUtils.isWellDefinedDependency(artifactToSearch));
}
Expand All @@ -143,15 +134,12 @@ public Hover onText(IHoverRequest request) throws Exception {
if (hover == null) {
hover = collectArtifactDescription(request);
}
return hover;
case GOAL_ELT:
return collectGoal(request);
default:
break;
yield hover;
}
case GOAL_ELT -> collectGoal(request);
// TODO consider incomplete GAV (eg plugins), by querying the "key" against project

return null;
default -> null;
};
}

private static final String PomTextHover_managed_version = "The managed version is {0}.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ public static Map<String, Type> getClassProperties(Class<?> clazz) {
}

public static Class<?> getRawType(Type type) {
if (type instanceof Class) {
return (Class<?>) type;
if (type instanceof Class<?> t) {
return t;
}
if (type instanceof ParameterizedType) {
return (Class<?>) ((ParameterizedType) type).getRawType();
if (type instanceof ParameterizedType paramedType) {
return (Class<?>) paramedType.getRawType();
}
return null;
}
Expand All @@ -126,9 +126,7 @@ public static Type getItemType(Type paramType) {
return null;
}

if (paramType instanceof ParameterizedType) {
ParameterizedType pt = (ParameterizedType) paramType;

if (paramType instanceof ParameterizedType pt) {
Type[] args = pt.getActualTypeArguments();
if (args.length > 0) {
return args[0];
Expand Down Expand Up @@ -157,8 +155,7 @@ public static String getTypeDisplayName(Type type) {
return getTypeDisplayName(clazz.getComponentType()) + "[]"; //$NON-NLS-1$
}

if (type instanceof ParameterizedType) {
ParameterizedType ptype = (ParameterizedType) type;
if (type instanceof ParameterizedType ptype) {
StringBuilder sb = new StringBuilder();
sb.append(getTypeDisplayName(clazz)).append("&lt;"); //$NON-NLS-1$

Expand Down

0 comments on commit f6aa142

Please sign in to comment.