Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
jdneo committed Jan 22, 2024
1 parent 8f0f822 commit 1bf6e2a
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package org.eclipse.jdt.ls.core.internal.commands;

import java.util.Map;
import java.util.Objects;

public class ProjectClasspathEntry {

private int kind;
private String path;
private String output;
private Map<String, String> attributes;

public ProjectClasspathEntry(int kind, String path, String output, Map<String, String> attributes) {
this.kind = kind;
this.path = path;
this.output = output;
this.attributes = attributes;
}

public int getKind() {
return kind;
}

public void setKind(int kind) {
this.kind = kind;
}

public String getPath() {
return path;
}

public void setPath(String path) {
this.path = path;
}

public String getOutput() {
return output;
}

public void setOutput(String output) {
this.output = output;
}

public Map<String, String> getAttributes() {
return attributes;
}

public void setAttributes(Map<String, String> attributes) {
this.attributes = attributes;
}

@Override
public int hashCode() {
return Objects.hash(kind, path, output, attributes);
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ProjectClasspathEntry other = (ProjectClasspathEntry) obj;
return kind == other.kind && Objects.equals(path, other.path) && Objects.equals(output, other.output) && Objects.equals(attributes, other.attributes);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public class ProjectCommand {
public static final String VM_LOCATION = IConstants.PLUGIN_ID + ".vm.location";
public static final String SOURCE_PATHS = IConstants.PLUGIN_ID + ".sourcePaths";
public static final String OUTPUT_PATH = IConstants.PLUGIN_ID + ".outputPath";
public static final String CLASSPATH_ENTRIES = IConstants.PLUGIN_ID + ".classpathEntries";
public static final String REFERENCED_LIBRARIES = IConstants.PLUGIN_ID + ".referencedLibraries";
private static final String TEST_SCOPE_VALUE = "test";

Expand All @@ -95,6 +96,7 @@ public class ProjectCommand {
* <li>"org.eclipse.jdt.ls.core.outputPath": Get the default output path of the given Java project. Note that the default output path
* may not be equal to the output path of each source root.</li>
* <li>"org.eclipse.jdt.ls.core.referencedLibraries": Get all the referenced library files of the given Java project.</li>
* <li>"org.eclipse.jdt.ls.core.classpathEntries": Get all the classpath entries of the given Java project.</li>
* </ul>
* @return A <code>Map<string, string></code> with all the setting keys and
* their values.
Expand Down Expand Up @@ -138,6 +140,24 @@ public static Map<String, Object> getProjectSettings(String uri, List<String> se
.toArray(String[]::new);
settings.putIfAbsent(key, referencedLibraries);
break;
case CLASSPATH_ENTRIES:
IClasspathEntry[] entries = javaProject.getRawClasspath();
List<ProjectClasspathEntry> classpathEntries = new LinkedList<>();
for (IClasspathEntry entry : entries) {
String output = "";
IPath outputLocation = entry.getOutputLocation();
if (outputLocation != null) {
output = outputLocation.toOSString();
}
Map<String, String> attributes = new HashMap<>();
for (IClasspathAttribute attribute : entry.getExtraAttributes()) {
attributes.put(attribute.getName(), attribute.getValue());
}
classpathEntries.add(new ProjectClasspathEntry(entry.getEntryKind(), entry.getPath().toOSString(),
output, attributes));
}
settings.putIfAbsent(key, classpathEntries);
break;
default:
settings.putIfAbsent(key, javaProject.getOption(key, true));
break;
Expand Down

0 comments on commit 1bf6e2a

Please sign in to comment.