-
Notifications
You must be signed in to change notification settings - Fork 408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Deprecated]Improve the standalone java file support #843
[Deprecated]Improve the standalone java file support #843
Conversation
Signed-off-by: Jinbo Wang <[email protected]>
Can one of the admins verify this patch? |
|
||
public static String getWorkspaceInvisibleProjectName(IPath workspacePath) { | ||
String fileName = workspacePath.toFile().getName(); | ||
String projectName = fileName + "_" + Integer.toHexString(workspacePath.toPortableString().hashCode()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"_" => WORKSPACE_LINK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here _
is just a simple separator. But the WORKSPACE_LINK symbol represents a special folder. Don't like to replace it here.
IPath workspaceRoot = JDTStandaloneFileUtils.getWorkspaceRoot(containerPath); | ||
if (workspaceRoot == null) { | ||
List<String> segments = Arrays.asList(containerPath.segments()); | ||
if (segments.contains(SRC)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be first process src/main/java and src/test/java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
test this please |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have faced the following compile error:
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:1.2.0:compile (default-compile) on project org.eclipse.jdt.ls.tests: Compilation failure: Compilation failure:
[ERROR] /home/snjeza/projects/eclipse.jdt.ls/org.eclipse.jdt.ls.tests/src/org/eclipse/jdt/ls/core/internal/JDTUtilsTest.java:[172]
[ERROR] assertEquals(ProjectUtils.getWorkspaceInvisibleProjectName(workspaceRoot), project.getName());
[ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[ERROR] The method getWorkspaceInvisibleProjectName(IPath) is undefined for the type ProjectUtils
[ERROR] 1 problem (1 error)
@fbricon Jenkins builds don't work. |
@snjeza i fixed the build error, could you try again? |
The following tests fail:
|
Thanks for the catch. Fixed it. |
I have tried this case and an invisible project hasn't been created. |
@snjeza You can use vscode to open an empty folder, and new a java file there, then the invisible project will be created. This invisible project should be in the same parent directory as the default project jdt.ls-java-project.
|
public static boolean isVisibleProject(IProject project) { | ||
PreferenceManager manager = JavaLanguageServerPlugin.getPreferencesManager(); | ||
Collection<IPath> rootPaths = manager.getPreferences().getRootPaths(); | ||
return ResourceUtils.isContainedIn(project.getLocation(), rootPaths) || ProjectUtils.isGradleProject(project); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why ProjectUtils.isGradleProject(project)? why not Maven?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch. It's exactly unnecessary to add gradle check here. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do Gradle projects get a special treatment?
So, opening the new lesson1/ directory from the test projects, I get an error on HelloWorld.java:
Verbose vscode/server logs[Trace - 5:07:18 PM] Sending request 'initialize - (0)'. Params: { "processId": 84620, "rootPath": "/Users/fbricon/Dev/souk/new-standalone/lesson1", "rootUri": "file:///Users/fbricon/Dev/souk/new-standalone/lesson1", "capabilities": { "workspace": { "applyEdit": true, "workspaceEdit": { "documentChanges": true, "resourceOperations": [ "create", "rename", "delete" ], "failureHandling": "textOnlyTransactional" }, "didChangeConfiguration": { "dynamicRegistration": true }, "didChangeWatchedFiles": { "dynamicRegistration": true }, "symbol": { "dynamicRegistration": true, "symbolKind": { "valueSet": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 ] } }, "executeCommand": { "dynamicRegistration": true }, "configuration": true, "workspaceFolders": true }, "textDocument": { "publishDiagnostics": { "relatedInformation": true }, "synchronization": { "dynamicRegistration": true, "willSave": true, "willSaveWaitUntil": true, "didSave": true }, "completion": { "dynamicRegistration": true, "contextSupport": true, "completionItem": { "snippetSupport": true, "commitCharactersSupport": true, "documentationFormat": [ "markdown", "plaintext" ], "deprecatedSupport": true, "preselectSupport": true }, "completionItemKind": { "valueSet": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 ] } }, "hover": { "dynamicRegistration": true, "contentFormat": [ "markdown", "plaintext" ] }, "signatureHelp": { "dynamicRegistration": true, "signatureInformation": { "documentationFormat": [ "markdown", "plaintext" ] } }, "definition": { "dynamicRegistration": true }, "references": { "dynamicRegistration": true }, "documentHighlight": { "dynamicRegistration": true }, "documentSymbol": { "dynamicRegistration": true, "symbolKind": { "valueSet": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 ] }, "hierarchicalDocumentSymbolSupport": true }, "codeAction": { "dynamicRegistration": true, "codeActionLiteralSupport": { "codeActionKind": { "valueSet": [ "", "quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports" ] } } }, "codeLens": { "dynamicRegistration": true }, "formatting": { "dynamicRegistration": true }, "rangeFormatting": { "dynamicRegistration": true }, "onTypeFormatting": { "dynamicRegistration": true }, "rename": { "dynamicRegistration": true, "prepareSupport": true }, "documentLink": { "dynamicRegistration": true }, "typeDefinition": { "dynamicRegistration": true }, "implementation": { "dynamicRegistration": true }, "colorProvider": { "dynamicRegistration": true }, "foldingRange": { "dynamicRegistration": true, "rangeLimit": 5000, "lineFoldingOnly": true } } }, "initializationOptions": { "bundles": [ "/Users/fbricon/.vscode-insiders/extensions/vscjava.vscode-java-debug-0.15.0/server/com.microsoft.java.debug.plugin-0.15.0.jar", "/Users/fbricon/.vscode-insiders/extensions/vscjava.vscode-java-dependency-0.1.0/server/com.microsoft.jdtls.ext.core-0.1.0.jar", "/Users/fbricon/.vscode-insiders/extensions/vscjava.vscode-java-test-0.10.0/server/com.microsoft.java.test.plugin-0.10.0.jar" ], "workspaceFolders": [ "file:///Users/fbricon/Dev/souk/new-standalone/lesson1" ], "settings": { "java": { "home": "/Users/fbricon/.sdkman/candidates/java/8u141-oracle/", "jdt": { "ls": { "vmargs": "-noverify -Xmx1G -XX:+UseG1GC -XX:+UseStringDeduplication -javaagent:\"/Users/fbricon/.vscode-insiders/extensions/GabrielBB.vscode-lombok-0.9.6/server/lombok.jar\" -Xbootclasspath/a:\"/Users/fbricon/.vscode-insiders/extensions/GabrielBB.vscode-lombok-0.9.6/server/lombok.jar\"" } }, "errors": { "incompleteClasspath": { "severity": "warning" } }, "configuration": { "updateBuildConfiguration": "interactive", "maven": { "userSettings": null } }, "trace": { "server": "verbose" }, "import": { "gradle": { "enabled": false }, "maven": { "enabled": true }, "exclusions": [ "**/node_modules/**", "**/.metadata/**", "**/archetype-resources/**", "**/META-INF/maven/**" ] }, "referencesCodeLens": { "enabled": false }, "signatureHelp": { "enabled": false }, "implementationsCodeLens": { "enabled": false }, "format": { "enabled": true, "settings": { "url": null, "profile": null }, "comments": { "enabled": true }, "onType": { "enabled": true } }, "saveActions": { "organizeImports": false }, "contentProvider": { "preferred": "fernflower" }, "autobuild": { "enabled": true }, "completion": { "enabled": true, "overwrite": true, "guessMethodArguments": false, "favoriteStaticMembers": [ "org.junit.Assert.*", "org.junit.Assume.*", "org.junit.jupiter.api.Assertions.*", "org.junit.jupiter.api.Assumptions.*", "org.junit.jupiter.api.DynamicContainer.*", "org.junit.jupiter.api.DynamicTest.*", "org.mockito.Mockito.*", "org.mockito.ArgumentMatchers.*", "org.mockito.Answers.*" ], "importOrder": [ "java", "javax", "com", "org" ] }, "progressReports": { "enabled": true }, "debug": { "logLevel": "warn", "settings": { "showHex": false, "showStaticVariables": true, "showQualifiedNames": false, "maxStringLength": 0, "enableHotCodeReplace": true, "enableRunDebugCodeLens": true } }, "dependency": { "showOutline": true, "syncWithFolderExplorer": true }, "test": { "report": { "position": "sideView" } } } }, "extendedClientCapabilities": { "progressReportProvider": true, "classFileContentsSupport": true } }, "trace": "verbose", "workspaceFolders": [ { "uri": "file:///Users/fbricon/Dev/souk/new-standalone/lesson1", "name": "lesson1" } ] }objc[84657]: Class JavaLaunchHelper is implemented in both /Users/fbricon/.sdkman/candidates/java/8u141-oracle/bin/java (0x104ed74c0) and /Users/fbricon/.sdkman/candidates/java/8u141-oracle/jre/lib/libinstrument.dylib (0x104fce4e0). One of the two will be used. Which one is undefined. [Info - 5:07:23 PM] 15-Nov-2018 5:07:23 PM Main thread is waiting [Info - 5:07:23 PM] 15-Nov-2018 5:07:23 PM >> initialize [Info - 5:07:23 PM] 15-Nov-2018 5:07:23 PM Initializing Java Language Server 0.28.0.201811152204 [Trace - 5:07:23 PM] Sending notification 'initialized'. [Trace - 5:07:23 PM] Sending notification 'workspace/didChangeConfiguration'. [Trace - 5:07:23 PM] Sending notification 'textDocument/didOpen'. [Trace - 5:07:23 PM] Received notification 'window/logMessage'. [Info - 5:07:23 PM] 15-Nov-2018 5:07:23 PM >> initialized [Info - 5:07:23 PM] 15-Nov-2018 5:07:23 PM System property http.nonProxyHosts has been set to local|.local|169.254/16|.169.254/16 by an external source. This value will be overwritten using the values from the preferences [Info - 5:07:23 PM] 15-Nov-2018 5:07:23 PM Creating the Java project jdt.ls-java-project [Trace - 5:07:24 PM] Received notification 'language/progressReport'. [Trace - 5:07:25 PM] Received notification 'language/progressReport'. [Trace - 5:07:25 PM] Received notification 'language/progressReport'. [Trace - 5:07:25 PM] Received notification 'language/progressReport'. [Trace - 5:07:30 PM] Received notification 'language/progressReport'. [Trace - 5:07:30 PM] Received notification 'language/progressReport'. [Trace - 5:07:30 PM] Received notification 'window/logMessage'. [Info - 5:07:30 PM] 15-Nov-2018 5:07:30 PM Finished creating the Java project jdt.ls-java-project [Trace - 5:07:30 PM] Received notification 'language/status'. [Trace - 5:07:30 PM] Received notification 'language/status'. [Trace - 5:07:30 PM] Received notification 'window/logMessage'. [Info - 5:07:30 PM] 15-Nov-2018 5:07:30 PM Workspace initialized in 7379ms [Trace - 5:07:32 PM] Received notification 'language/status'. [Trace - 5:07:32 PM] Received notification 'language/progressReport'. [Trace - 5:07:32 PM] Received notification 'language/progressReport'. [Trace - 5:07:32 PM] Received request 'client/registerCapability - (1)'. [Trace - 5:07:32 PM] Sending response 'client/registerCapability - (1)'. Processing request took 0ms [Trace - 5:07:32 PM] Received request 'client/registerCapability - (2)'. [Trace - 5:07:32 PM] Sending response 'client/registerCapability - (2)'. Processing request took 0ms [Trace - 5:07:32 PM] Received request 'client/registerCapability - (3)'. [Trace - 5:07:32 PM] Sending response 'client/registerCapability - (3)'. Processing request took 1ms [Trace - 5:07:32 PM] Received request 'client/registerCapability - (4)'. [Trace - 5:07:32 PM] Sending response 'client/registerCapability - (4)'. Processing request took 0ms [Trace - 5:07:35 PM] Sending request 'textDocument/documentSymbol - (1)'. [Trace - 5:07:35 PM] Received request 'client/registerCapability - (5)'. [Trace - 5:07:35 PM] Sending response 'client/registerCapability - (5)'. Processing request took 1ms [Trace - 5:07:35 PM] Received request 'client/registerCapability - (6)'. [Trace - 5:07:35 PM] Sending response 'client/registerCapability - (6)'. Processing request took 1ms [Trace - 5:07:35 PM] Received request 'client/registerCapability - (7)'. [Trace - 5:07:35 PM] Sending response 'client/registerCapability - (7)'. Processing request took 1ms [Trace - 5:07:35 PM] Received request 'client/registerCapability - (8)'. [Trace - 5:07:35 PM] Sending response 'client/registerCapability - (8)'. Processing request took 0ms [Trace - 5:07:35 PM] Received request 'client/registerCapability - (9)'. [Trace - 5:07:35 PM] Sending response 'client/registerCapability - (9)'. Processing request took 1ms [Trace - 5:07:35 PM] Received request 'client/registerCapability - (10)'. [Trace - 5:07:35 PM] Sending response 'client/registerCapability - (10)'. Processing request took 0ms [Trace - 5:07:35 PM] Sending request 'workspace/executeCommand - (2)'. [Trace - 5:07:35 PM] Received request 'client/registerCapability - (11)'. [Trace - 5:07:35 PM] Sending response 'client/registerCapability - (11)'. Processing request took 22ms [Trace - 5:07:35 PM] Sending request 'workspace/executeCommand - (3)'. [Trace - 5:07:35 PM] Received request 'client/registerCapability - (12)'. [Trace - 5:07:35 PM] Sending response 'client/registerCapability - (12)'. Processing request took 1ms [Trace - 5:07:35 PM] Received request 'client/registerCapability - (13)'. [Trace - 5:07:35 PM] Sending response 'client/registerCapability - (13)'. Processing request took 1ms [Trace - 5:07:35 PM] Received request 'client/registerCapability - (14)'. [Trace - 5:07:35 PM] Sending response 'client/registerCapability - (14)'. Processing request took 1ms [Trace - 5:07:35 PM] Received request 'client/registerCapability - (15)'. [Trace - 5:07:35 PM] Sending response 'client/registerCapability - (15)'. Processing request took 0ms [Trace - 5:07:35 PM] Received request 'client/registerCapability - (16)'. [Trace - 5:07:35 PM] Sending response 'client/registerCapability - (16)'. Processing request took 42ms [Info - 5:07:35 PM] 15-Nov-2018 5:07:30 PM >> workspace/didChangeConfiguration [Info - 5:07:35 PM] 15-Nov-2018 5:07:30 PM >> registerFeature 'workspace/didChangeWatchedFiles' [Info - 5:07:35 PM] 15-Nov-2018 5:07:30 PM >>New configuration: {java={home=/Users/fbricon/.sdkman/candidates/java/8u141-oracle/, jdt={ls={vmargs=-noverify -Xmx1G -XX:+UseG1GC -XX:+UseStringDeduplication -javaagent:"/Users/fbricon/.vscode-insiders/extensions/GabrielBB.vscode-lombok-0.9.6/server/lombok.jar" -Xbootclasspath/a:"/Users/fbricon/.vscode-insiders/extensions/GabrielBB.vscode-lombok-0.9.6/server/lombok.jar"}}, errors={incompleteClasspath={severity=warning}}, configuration={updateBuildConfiguration=interactive, maven={userSettings=null}}, trace={server=verbose}, import={gradle={enabled=false}, maven={enabled=true}, exclusions=[/node_modules/, /.metadata/, /archetype-resources/, /META-INF/maven/]}, referencesCodeLens={enabled=false}, signatureHelp={enabled=false}, implementationsCodeLens={enabled=false}, format={enabled=true, settings={url=null, profile=null}, comments={enabled=true}, onType={enabled=true}}, saveActions={organizeImports=false}, contentProvider={preferred=fernflower}, autobuild={enabled=true}, completion={enabled=true, overwrite=true, guessMethodArguments=false, favoriteStaticMembers=[org.junit.Assert., org.junit.Assume., org.junit.jupiter.api.Assertions., org.junit.jupiter.api.Assumptions., org.junit.jupiter.api.DynamicContainer., org.junit.jupiter.api.DynamicTest., org.mockito.Mockito., org.mockito.ArgumentMatchers., org.mockito.Answers.*], importOrder=[java, javax, com, org]}, progressReports={enabled=true}, debug={logLevel=warn, settings={showHex=false, showStaticVariables=true, showQualifiedNames=false, maxStringLength=0.0, enableHotCodeReplace=true, enableRunDebugCodeLens=true}}, dependency={showOutline=true, syncWithFolderExplorer=true}, test={report={position=sideView}}}} [Info - 5:07:35 PM] 15-Nov-2018 5:07:30 PM >> document/didOpen [Info - 5:07:35 PM] 15-Nov-2018 5:07:30 PM Creating the Java project lesson1_78ab5ec9 [Info - 5:07:35 PM] 15-Nov-2018 5:07:30 PM Finished creating the Java project lesson1_78ab5ec9 [Trace - 5:07:35 PM] Received notification 'language/progressReport'. [Trace - 5:07:35 PM] Received notification 'language/progressReport'. [Trace - 5:07:35 PM] Received notification 'language/progressReport'. [Trace - 5:07:35 PM] Received notification 'language/progressReport'. [Trace - 5:07:35 PM] Received notification 'language/progressReport'. [Trace - 5:07:35 PM] Received notification 'textDocument/publishDiagnostics'. [Trace - 5:07:35 PM] Received notification 'textDocument/publishDiagnostics'. [Trace - 5:07:35 PM] Received notification 'language/progressReport'. [Trace - 5:07:35 PM] Received notification 'language/progressReport'. [Trace - 5:07:35 PM] Received notification 'language/progressReport'. [Trace - 5:07:35 PM] Received notification 'language/progressReport'. [Trace - 5:07:35 PM] Received notification 'window/logMessage'. [Info - 5:07:35 PM] 15-Nov-2018 5:07:33 PM begin problem for /Test.java [Info - 5:07:35 PM] 15-Nov-2018 5:07:33 PM 0 problems reported for /Test.java [Trace - 5:07:35 PM] Received notification 'window/logMessage'. [Info - 5:07:35 PM] 15-Nov-2018 5:07:33 PM Reconciled 0, validated: 1. Took 655 ms [Trace - 5:07:35 PM] Received notification 'language/progressReport'. [Trace - 5:07:35 PM] Received notification 'language/progressReport'. [Trace - 5:07:35 PM] Received notification 'language/progressReport'. [Trace - 5:07:35 PM] Received notification 'window/logMessage'. [Info - 5:07:35 PM] 15-Nov-2018 5:07:35 PM >> document/documentSymbol [Trace - 5:07:35 PM] Received notification 'window/logMessage'. [Info - 5:07:35 PM] 15-Nov-2018 5:07:35 PM >> workspace/executeCommand vscode.java.test.search.all [Info - 5:07:35 PM] 15-Nov-2018 5:07:35 PM >> workspace/executeCommand java.project.list [Trace - 5:07:35 PM] Sending request 'workspace/executeCommand - (4)'. [Trace - 5:07:35 PM] Received notification 'window/logMessage'. [Info - 5:07:35 PM] 15-Nov-2018 5:07:35 PM >> workspace/executeCommand vscode.java.resolveMainMethod [Info - 5:07:35 PM] 15-Nov-2018 5:07:35 PM Starting com.microsoft.java.debug.plugin [Trace - 5:07:40 PM] Received response 'workspace/executeCommand - (2)' in 4796ms. [Trace - 5:07:40 PM] Sending request 'workspace/executeCommand - (5)'. [Trace - 5:07:40 PM] Received notification 'window/logMessage'. [Info - 5:07:40 PM] 15-Nov-2018 5:07:40 PM >> workspace/executeCommand vscode.java.test.project.info [Trace - 5:07:40 PM] Sending request 'workspace/executeCommand - (6)'. [Trace - 5:07:40 PM] Sending request 'workspace/executeCommand - (7)'. [Trace - 5:07:40 PM] Received notification 'window/logMessage'. [Info - 5:07:40 PM] 15-Nov-2018 5:07:40 PM >> workspace/executeCommand vscode.java.test.fetch [Info - 5:07:40 PM] 15-Nov-2018 5:07:40 PM >> workspace/executeCommand vscode.java.resolveMainMethod [Trace - 5:07:40 PM] Received response 'workspace/executeCommand - (6)' in 13ms. [Trace - 5:09:29 PM] Sending request 'workspace/executeCommand - (8)'. [Trace - 5:09:29 PM] Received notification 'window/logMessage'. [Info - 5:09:29 PM] 15-Nov-2018 5:09:29 PM >> workspace/executeCommand java.resolvePath [Trace - 5:09:29 PM] Sending request 'workspace/executeCommand - (9)'. [Trace - 5:09:29 PM] Received notification 'window/logMessage'. [Info - 5:09:29 PM] 15-Nov-2018 5:09:29 PM >> workspace/executeCommand java.project.list [Trace - 5:09:31 PM] Sending notification 'textDocument/didClose'. [Trace - 5:09:31 PM] Received notification 'window/logMessage'. [Info - 5:09:31 PM] 15-Nov-2018 5:09:31 PM >> document/didClose [Trace - 5:09:31 PM] Sending request 'textDocument/codeAction - (10)'. [Trace - 5:09:31 PM] Sending request 'textDocument/codeAction - (11)'. [Trace - 5:09:31 PM] Sending request 'workspace/executeCommand - (12)'. [Trace - 5:09:31 PM] Sending request 'textDocument/documentSymbol - (13)'. [Trace - 5:09:31 PM] Received notification 'window/logMessage'. [Info - 5:09:31 PM] 15-Nov-2018 5:09:31 PM >> document/didOpen [Info - 5:09:31 PM] 15-Nov-2018 5:09:31 PM >> document/codeAction [Info - 5:09:31 PM] 15-Nov-2018 5:09:31 PM >> document/codeAction [Info - 5:09:31 PM] 15-Nov-2018 5:09:31 PM >> workspace/executeCommand java.resolvePath [Trace - 5:09:31 PM] Sending request 'workspace/executeCommand - (14)'. [Trace - 5:09:31 PM] Received notification 'window/logMessage'. [Info - 5:09:31 PM] 15-Nov-2018 5:09:31 PM >> document/documentSymbol [Info - 5:09:31 PM] 15-Nov-2018 5:09:31 PM >> workspace/executeCommand java.project.list [Trace - 5:09:32 PM] Received notification 'language/progressReport'. [Trace - 5:09:32 PM] Sending request 'workspace/executeCommand - (15)'. [Trace - 5:09:32 PM] Sending request 'workspace/executeCommand - (16)'. [Trace - 5:09:32 PM] Received notification 'window/logMessage'. [Info - 5:09:32 PM] 15-Nov-2018 5:09:32 PM >> workspace/executeCommand vscode.java.test.fetch [Info - 5:09:32 PM] 15-Nov-2018 5:09:32 PM >> workspace/executeCommand vscode.java.resolveMainMethod [Trace - 5:09:32 PM] Sending notification '$/cancelRequest'. [Trace - 5:09:32 PM] Received notification 'window/logMessage'. [Info - 5:09:32 PM] 15-Nov-2018 5:09:32 PM >> document/codeAction [Trace - 5:09:32 PM] Received notification 'language/progressReport'. [Trace - 5:09:32 PM] Received notification 'window/logMessage'. [Info - 5:09:32 PM] 15-Nov-2018 5:09:32 PM begin problem for /HelloWorld.java [Info - 5:09:32 PM] 15-Nov-2018 5:09:32 PM 1 problems reported for /HelloWorld.java [Trace - 5:09:32 PM] Received notification 'window/logMessage'. [Info - 5:09:32 PM] 15-Nov-2018 5:09:32 PM Reconciled 0, validated: 1. Took 138 ms [Trace - 5:09:32 PM] Received response 'workspace/executeCommand - (14)' in 547ms. [Trace - 5:09:32 PM] Received response 'workspace/executeCommand - (15)' in 425ms. [Trace - 5:09:32 PM] Received response 'textDocument/documentSymbol - (13)' in 625ms. [Trace - 5:09:32 PM] Received response 'workspace/executeCommand - (16)' in 430ms. [Trace - 5:09:32 PM] Received response 'textDocument/codeAction - (17)' in 465ms. [Trace - 5:09:32 PM] Received response 'textDocument/codeAction - (10)' in 706ms. [Trace - 5:09:33 PM] Received notification 'language/progressReport'. [Trace - 5:09:33 PM] Received notification 'language/progressReport'. [Trace - 5:11:09 PM] Sending request 'workspace/executeCommand - (18)'. [Trace - 5:11:09 PM] Sending request 'textDocument/codeAction - (19)'. [Trace - 5:11:09 PM] Received notification 'window/logMessage'. [Info - 5:11:09 PM] 15-Nov-2018 5:11:09 PM >> workspace/executeCommand java.resolvePath [Info - 5:11:09 PM] 15-Nov-2018 5:11:09 PM >> document/codeAction [Trace - 5:11:09 PM] Sending request 'workspace/executeCommand - (20)'. [Trace - 5:11:09 PM] Received response 'textDocument/codeAction - (19)' in 32ms. [Trace - 5:11:09 PM] Received notification 'window/logMessage'. [Info - 5:11:09 PM] 15-Nov-2018 5:11:09 PM >> workspace/executeCommand java.project.list [Trace - 5:11:11 PM] Sending request 'textDocument/codeAction - (21)'. [Trace - 5:11:11 PM] Sending request 'textDocument/codeAction - (22)'. [Trace - 5:11:11 PM] Received notification 'window/logMessage'. [Info - 5:11:11 PM] 15-Nov-2018 5:11:11 PM >> document/codeAction [Info - 5:11:11 PM] 15-Nov-2018 5:11:11 PM >> document/codeAction [Trace - 5:11:11 PM] Received response 'textDocument/codeAction - (22)' in 6ms. Using the package src.main.java.demosamples;
/**
* Empty1
*/
public class Empty1 {
} |
Signed-off-by: Jinbo Wang <[email protected]>
@fbricon This is a pretty good question. i analysed your log, i should get your problem. Below is the lesson1 directory structure. The first java file you opened is My current policy on handling standalone files is relatively conservative. It will only mark the containing folder of the first opening file as source root. If the workspace contains multiple source roots, opening other source roots standalone files may receive " Back to the current scenario you got, i got another idea. When creating the invisible project for standalone java files, i think the language server could be more intelligent. It should not only mark the containing folder of the opened file as Source Root, but also automatically mark the conventional source directories such as @fbricon How do you think? |
Signed-off-by: Jinbo Wang <[email protected]>
test this please |
for (IProject project : getWorkspaceRoot().getProjects()) { | ||
if (project.exists() && (ResourceUtils.isContainedIn(project.getLocation(), rootPaths) || ProjectUtils.isGradleProject(project))) { | ||
if (project.exists() && (ResourceUtils.isContainedIn(project.getLocation(), rootPaths) || ProjectUtils.isGradleProject(project)) || workspaceProjects.contains(project.getName())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gradle check here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The gradle check is added by another PR 320401b#diff-54b8440d3466866733ad3374655cf2bf, not sure the underlying reason.
Signed-off-by: Jinbo Wang <[email protected]>
Actually this is the same behavior as eclipse. |
Have more investigation on the Eclipse behavior. It supports importing a folder without project descriptor. It will automatically convert the opening folder to an eclipse project silently, and smartly detect all possible source folders (The containing folder which contains *.java file). As comparison, our current approach will create an invisible project for the root folder, it doesn't pollute the user's code space(.project, .classpath). But currently we only mark the open file's containing folder as source folder. This is one difference. Of course, if you feel it's necessary to auto detect all potential source folders, we can do that at the second stage (in new PR). One of my concern for the auto-detection is performance issue for big directories opened in VS Code. Like what i mentioned previously, another option is to simplify the detection and limit it to the top level folders with the name convention On the other hand, i understand your approach of |
@fbricon ping... any more comments? |
I think I'd go with a different approach:
that way, truly standalone files opened outside of the root uri are still behaving the same way, when a sub folder of a package is opened (my previous example), the package directory structure is not completely under the root uri, so no invisible project is created, we keep the same behaviour as before. I think it should cover most of the use cases while also requiring minimal changes to the current code |
Yeah, i accept the concept of InvisibleProjectImporter. One more question about the triggering condition of creating the invisible project.
Do you mean searching IMHO, we follow a certain sequence to deal with the *.java file.
|
So, in the case of vscode, the server will be started once vscode opens a java file. But only the root uris will be sent to the server, so the server will need to (re)discover the java files. It should search for java files with a rather large max depth (10? more?), to account for stuff like src/main/java/one/very/package/name/Foo.java. But at least, once a java file is found, it should just stop the file detection |
The background i asked this question is Java Language Server may be activated when the user is debugging a non-java project (For example, C++, python). See a known bug microsoft/vscode-java-debug#238. If Java LS is pending on searching *.java for a long time (especially for some projects with deep directories, such as node_modules), this is probably a disaster for them. |
then we might need to pass the opened java file as an initialization parameter, to avoid deep searches |
Exactly. when vscode client is activating LS, we can put the |
The parameter mustn't be vscode specific. You can call it triggerFile or something better |
superseded by #880 |
Signed-off-by: Jinbo Wang [email protected]
Below are the thoughts on improving the support for standalone Java file.
The opening standalone file is an external Java file. (Not belonging to any workspace root).
I'd like to keep the current behavior. Link the external file to the default project, and use the default project to manage it. And jdt.ls will take it as single file. That means if the file only used the standard jdk library, Run/Debug works well. But if it used other dependency or class file, jdt build will fail and Run/Debug doesn't work. This behavior is same as the
javac
build policy.When use
javac
to compile a single file, if it only used JDK library, build succeeded.If it used other dependency,
javac
will try to resolve them from current working directory (cwd), if not found, build failed.If all dependencies could be resolved in the cwd, build succeeded.
The opening standalone file is inside one of workspace root.
If the workspace root contains any visible eclipse/maven/gradle project, take the standalone Java file as a normal text file.
If the workspace root doesn't have any visible project in its sub folders, then create an invisible project in the workspace storage, and link the workspace root to a special folder
_
under the invisible project, and mark the containing folder of the opened standalone java file as Source Root of the invisible project.The invisible project brings two benefits. One is to hide the eclipse project metadata files (.project/.classpath/bin/.settings). The other is to separate the workspace standalone files with the external standalone java files. The build server will report the build errors from the workspace invisible project.