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
7 changes: 7 additions & 0 deletions jdtls.ext/com.microsoft.jdtls.ext.core/.checkstyle
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>

<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
<fileset name="all" enabled="true" check-config-name="Google Checks" local="false">
<file-match-pattern match-pattern="." include-pattern="true"/>
</fileset>
</fileset-config>
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0
org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
org.eclipse.jdt.core.formatter.alignment_for_module_statements=16
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
Expand Down Expand Up @@ -62,11 +63,11 @@ org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=true
org.eclipse.jdt.core.formatter.comment.format_block_comments=false
org.eclipse.jdt.core.formatter.comment.format_block_comments=true
org.eclipse.jdt.core.formatter.comment.format_header=false
org.eclipse.jdt.core.formatter.comment.format_html=true
org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
org.eclipse.jdt.core.formatter.comment.format_line_comments=false
org.eclipse.jdt.core.formatter.comment.format_line_comments=true
org.eclipse.jdt.core.formatter.comment.format_source_code=true
org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
Expand All @@ -92,7 +93,7 @@ org.eclipse.jdt.core.formatter.indent_empty_lines=false
org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
org.eclipse.jdt.core.formatter.indentation.size=4
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
Expand Down Expand Up @@ -284,7 +285,7 @@ org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
org.eclipse.jdt.core.formatter.lineSplit=240
org.eclipse.jdt.core.formatter.lineSplit=160
org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
Expand All @@ -302,7 +303,7 @@ org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
org.eclipse.jdt.core.formatter.tabulation.char=tab
org.eclipse.jdt.core.formatter.tabulation.size=4
org.eclipse.jdt.core.formatter.use_on_off_tags=true
org.eclipse.jdt.core.formatter.use_on_off_tags=false
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false
org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ cleanup_profile=org.eclipse.jdt.ui.default.eclipse_clean_up_profile
cleanup_settings_version=2
eclipse.preferences.version=1
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
formatter_profile=_JDT LS
formatter_profile=_JDTLS.EXT
formatter_settings_version=13
org.eclipse.jdt.ui.javadoc=true
org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return the ${bare_field_name}\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} the ${bare_field_name} to set\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*******************************************************************************\n * Copyright (c) ${year} Red Hat Inc. and others.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http\://www.eclipse.org/legal/epl-v10.html\n *\n * Contributors\:\n * Red Hat Inc. - initial API and implementation\n *******************************************************************************/</template><template autoinsert\="true" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * @author ${user}\n *\n * ${tags}\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\n * ${see_to_overridden}\n */</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * ${tags}\n * ${see_to_target}\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import org.eclipse.jdt.internal.core.JarEntryResource;
import org.eclipse.jdt.internal.core.JrtPackageFragmentRoot;
import org.eclipse.jdt.ls.core.internal.JDTUtils;
import org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin;
import org.eclipse.lsp4j.jsonrpc.json.adapters.CollectionTypeAdapterFactory;
import org.eclipse.lsp4j.jsonrpc.json.adapters.EnumTypeAdapterFactory;

Expand All @@ -54,6 +53,7 @@
import com.microsoft.jdtls.ext.core.model.NodeKind;
import com.microsoft.jdtls.ext.core.model.PackageNode;
import com.microsoft.jdtls.ext.core.model.PackageRootNode;
import com.microsoft.jdtls.ext.core.model.TypeRootNode;

@SuppressWarnings("deprecation")
public class PackageCommand {
Expand All @@ -68,7 +68,7 @@ public class PackageCommand {
commands.put(NodeKind.PROJECT, PackageCommand::getContainers);
commands.put(NodeKind.CONTAINER, PackageCommand::getPackageFragmentRoots);
commands.put(NodeKind.PACKAGEROOT, PackageCommand::getPackages);
commands.put(NodeKind.PACKAGE, PackageCommand::getClassfiles);
commands.put(NodeKind.PACKAGE, PackageCommand::getRootTypes);
commands.put(NodeKind.Folder, PackageCommand::getFolderChildren);
}

Expand All @@ -91,8 +91,7 @@ public static List<PackageNode> getChildren(List<Object> arguments, IProgressMon

BiFunction<PackageParams, IProgressMonitor, List<PackageNode>> loader = commands.get(params.getKind());
if (loader == null) {
throw new CoreException(
new Status(IStatus.ERROR, JdtlsExtActivator.PLUGIN_ID, String.format("Unknown classpath item type: %s", params.getKind())));
throw new CoreException(new Status(IStatus.ERROR, JdtlsExtActivator.PLUGIN_ID, String.format("Unknown classpath item type: %s", params.getKind())));
}
List<PackageNode> result = loader.apply(params, pm);
return result;
Expand Down Expand Up @@ -121,7 +120,7 @@ private static List<PackageNode> getContainers(PackageParams query, IProgressMon
return null;
}).filter(containerNode -> containerNode != null).collect(Collectors.toList());
} catch (CoreException e) {
JavaLanguageServerPlugin.logException("Problem load project library ", e);
JdtlsExtActivator.logException("Problem load project library ", e);
}
}
return Collections.emptyList();
Expand All @@ -144,7 +143,11 @@ private static List<PackageNode> getPackageFragmentRoots(PackageParams query, IP
ArrayList<PackageNode> children = new ArrayList<>();
IPackageFragmentRoot[] packageFragmentRoots = javaProject.findPackageFragmentRoots(containerEntry);
for (IPackageFragmentRoot fragmentRoot : packageFragmentRoots) {
PackageNode node = new PackageRootNode(fragmentRoot.getElementName(), fragmentRoot.getPath().toPortableString(), NodeKind.PACKAGEROOT,
String displayName = fragmentRoot.getElementName();
if (fragmentRoot.getKind() == IPackageFragmentRoot.K_SOURCE) {
displayName = ExtUtils.removeProjectSegment(javaProject.getElementName(), fragmentRoot.getPath()).toPortableString();
}
PackageNode node = new PackageRootNode(displayName, fragmentRoot.getPath().toPortableString(), NodeKind.PACKAGEROOT,
fragmentRoot.getKind());
children.add(node);
if (fragmentRoot instanceof JrtPackageFragmentRoot) {
Expand All @@ -154,7 +157,7 @@ private static List<PackageNode> getPackageFragmentRoots(PackageParams query, IP
return children;
}
} catch (CoreException e) {
JavaLanguageServerPlugin.logException("Problem load project JAR entries ", e);
JdtlsExtActivator.logException("Problem load project JAR entries ", e);
}
}

Expand All @@ -170,38 +173,38 @@ private static List<PackageNode> getPackages(PackageParams query, IProgressMonit
IPackageFragmentRoot packageRoot = javaProject.findPackageFragmentRoot(Path.fromPortableString(query.getRootPath()));
if (packageRoot == null) {
throw new CoreException(
new Status(IStatus.ERROR, JdtlsExtActivator.PLUGIN_ID,
String.format("No package root found for %s", query.getPath())));
new Status(IStatus.ERROR, JdtlsExtActivator.PLUGIN_ID, String.format("No package root found for %s", query.getPath())));
}
Object[] result = getPackageFragmentRootContent(packageRoot, pm);
return convertToClasspathNode(result);
} catch (CoreException e) {
JavaLanguageServerPlugin.logException("Problem load project package ", e);
JdtlsExtActivator.logException("Problem load project package ", e);
}
}
return Collections.emptyList();
}

private static List<PackageNode> getClassfiles(PackageParams query, IProgressMonitor pm) {
private static List<PackageNode> getRootTypes(PackageParams query, IProgressMonitor pm) {
IJavaProject javaProject = getJavaProject(query.getProjectUri());
if (javaProject != null) {
try {
IPackageFragmentRoot packageRoot = javaProject.findPackageFragmentRoot(Path.fromPortableString(query.getRootPath()));
if (packageRoot == null) {
throw new CoreException(
new Status(IStatus.ERROR, JavaLanguageServerPlugin.PLUGIN_ID, String.format("No package root found for %s", query.getPath())));
new Status(IStatus.ERROR, JdtlsExtActivator.PLUGIN_ID, String.format("No package root found for %s", query.getPath())));
}
IPackageFragment packageFragment = packageRoot.getPackageFragment(query.getPath());
if (packageFragment != null) {
IJavaElement[] classFiles = packageFragment.getChildren();
return Arrays.stream(classFiles).filter(classFile -> !classFile.getElementName().contains("$")).map(classFile -> {
PackageNode item = new PackageNode(classFile.getElementName(), classFile.getPath().toPortableString(), NodeKind.CLASSFILE);
IJavaElement[] types = packageFragment.getChildren();
return Arrays.stream(types).filter(typeRoot -> !typeRoot.getElementName().contains("$")).map(typeRoot -> {
PackageNode item = new TypeRootNode(typeRoot.getElementName(), typeRoot.getPath().toPortableString(), NodeKind.TYPEROOT,
typeRoot instanceof IClassFile ? TypeRootNode.K_BINARY : TypeRootNode.K_SOURCE);
return item;
}).collect(Collectors.toList());

}
} catch (CoreException e) {
JavaLanguageServerPlugin.logException("Problem load project classfile list ", e);
JdtlsExtActivator.logException("Problem load project classfile list ", e);
}
}
return Collections.emptyList();
Expand Down Expand Up @@ -232,7 +235,7 @@ private static List<PackageNode> getFolderChildren(PackageParams query, IProgres
}

} catch (CoreException e) {
JavaLanguageServerPlugin.logException("Problem load project classfile list ", e);
JdtlsExtActivator.logException("Problem load project classfile list ", e);
}
}
return Collections.emptyList();
Expand Down Expand Up @@ -264,7 +267,7 @@ private static List<PackageNode> convertToClasspathNode(Object[] rootContent) th
result.add(entry);
} else if (root instanceof IClassFile) {
IClassFile classFile = (IClassFile) root;
PackageNode entry = new PackageNode(classFile.getElementName(), null, NodeKind.CLASSFILE);
PackageNode entry = new PackageNode(classFile.getElementName(), null, NodeKind.TYPEROOT);
entry.setUri(JDTUtils.toUri(classFile));
result.add(entry);
} else if (root instanceof JarEntryResource) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ public ContainerNode(String name, String path, NodeKind kind, int entryKind) {
this.entryKind = entryKind;
}

public ContainerNode() {

}

public int getEntryType() {
return this.entryKind;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public enum NodeKind {

PACKAGE(5),

CLASSFILE(6),
TYPEROOT(6),

Folder(7),

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*******************************************************************************
* Copyright (c) 2018 Microsoft Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Microsoft Corporation - initial API and implementation
*******************************************************************************/

package com.microsoft.jdtls.ext.core.model;

public class TypeRootNode extends PackageNode {

/**
* Kind constant for a source file.
*/
public final static int K_SOURCE = 1;

/**
* Kind constant for a binary type.
*/
public final static int K_BINARY = 2;

private int entryKind;

public TypeRootNode(String name, String path, NodeKind kind, int entryKind) {
super(name, path, kind);
this.entryKind = entryKind;
}

public int getEntryType() {
return this.entryKind;
}
}
1 change: 1 addition & 0 deletions vscode/images/file_type_java.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion vscode/src/java/nodeData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export enum NodeKind {
Container = 3,
PackageRoot = 4,
Package = 5,
Classfile = 6,
TypeRoot = 6,
Folder = 7,
File = 8
}
Expand Down
Loading