Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on Jun 15, 2026. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork 19
Support Moniker#63
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Support Moniker #63
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
22834ab
Update project monikers
CsCherrYY e5c2ea0
Update scheme moniker
CsCherrYY d057f84
Update packageInformation
CsCherrYY d961799
Update Indexer.java
CsCherrYY eee7af7
Fix format
CsCherrYY 92bd228
Update scheme monikers
CsCherrYY a35f2b8
Fix gradle packageInformation bug
CsCherrYY cf14866
Remove test codes
CsCherrYY de62e4d
Apply changes
CsCherrYY 726779c
Apply changes
CsCherrYY 00b55ac
Apply changes
CsCherrYY 61e466d
Apply changes
CsCherrYY 85c6686
Apply comments
CsCherrYY 57b1db5
Apply changes
CsCherrYY 1dece7c
Apply changes
CsCherrYY baa070e
Update LsifVisitor.java
CsCherrYY cfed442
Apply changes
CsCherrYY 41b5520
Make `resolveMoniker` synchronized
CsCherrYY File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| // Use IntelliSense to learn about possible attributes. | ||
| // Hover to view descriptions of existing attributes. | ||
| // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
| "version": "0.2.0", | ||
| "configurations": [ | ||
| { | ||
| "type": "java", | ||
| "name": "Debug (Attach)", | ||
| "request": "attach", | ||
| "hostName": "localhost", | ||
| "projectName": "com.microsoft.java.lsif.core", | ||
| "port": 6006 | ||
| } | ||
| ] | ||
| } |
Large diffs are not rendered by default.
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 24 additions & 4 deletions
28 com.microsoft.java.lsif.core/.settings/org.eclipse.jdt.core.prefs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1 com.microsoft.java.lsif.core/src/com/microsoft/java/lsif/core/internal/indexer/ASTUtil.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12 ...crosoft.java.lsif.core/src/com/microsoft/java/lsif/core/internal/indexer/EdgeBuilder.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 113 additions & 8 deletions
121 com.microsoft.java.lsif.core/src/com/microsoft/java/lsif/core/internal/indexer/Indexer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -5,13 +5,21 @@ | ||
| package com.microsoft.java.lsif.core.internal.indexer; | ||
| import java.io.File; | ||
| import java.util.HashMap; | ||
| import java.util.LinkedList; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.concurrent.ExecutorService; | ||
| import java.util.concurrent.Executors; | ||
| import org.apache.maven.model.Model; | ||
| import org.apache.maven.model.Scm; | ||
| import org.apache.maven.project.MavenProject; | ||
| import org.apache.maven.scm.provider.ScmUrlUtils; | ||
| import org.apache.maven.shared.utils.StringUtils; | ||
| import org.eclipse.buildship.core.GradleBuild; | ||
| import org.eclipse.buildship.core.GradleCore; | ||
| import org.eclipse.core.resources.IProject; | ||
| import org.eclipse.core.resources.ResourcesPlugin; | ||
| import org.eclipse.core.runtime.IPath; | ||
| @@ -27,13 +35,20 @@ | ||
| import org.eclipse.jdt.core.JavaModelException; | ||
| import org.eclipse.jdt.core.dom.CompilationUnit; | ||
| import org.eclipse.jdt.ls.core.internal.BuildWorkspaceStatus; | ||
| import org.eclipse.jdt.ls.core.internal.IProjectImporter; | ||
| import org.eclipse.jdt.ls.core.internal.JavaLanguageServerPlugin; | ||
| import org.eclipse.jdt.ls.core.internal.ResourceUtils; | ||
| import org.eclipse.jdt.ls.core.internal.managers.GradleProjectImporter; | ||
| import org.eclipse.jdt.ls.core.internal.managers.MavenProjectImporter; | ||
| import org.eclipse.lsp4j.ClientCapabilities; | ||
| import org.gradle.tooling.model.GradleModuleVersion; | ||
| import org.gradle.tooling.model.gradle.GradlePublication; | ||
| import org.gradle.tooling.model.gradle.ProjectPublications; | ||
| import com.microsoft.java.lsif.core.internal.emitter.LsifEmitter; | ||
| import com.microsoft.java.lsif.core.internal.protocol.Document; | ||
| import com.microsoft.java.lsif.core.internal.protocol.Event; | ||
| import com.microsoft.java.lsif.core.internal.protocol.PackageInformation.PackageManager; | ||
| import com.microsoft.java.lsif.core.internal.protocol.Project; | ||
| import com.microsoft.java.lsif.core.internal.visitors.DiagnosticVisitor; | ||
| import com.microsoft.java.lsif.core.internal.visitors.DocumentVisitor; | ||
| @@ -90,16 +105,24 @@ private void buildIndex(IPath path, IProgressMonitor monitor, LsifService lsif) | ||
| if (!javaProject.exists()) { | ||
| continue; | ||
| } | ||
| boolean hasPackageInformation = false; | ||
| try { | ||
| hasPackageInformation = generateExportPackageInformation(proj, monitor, lsif, javaProject); | ||
| } catch (Exception e) { | ||
| // OperationCanceledException, CoreException from WorkspaceHandler.getImporter | ||
| // GradleConnectionException, IllegalStateException from | ||
| // ProjectConnection.getModel | ||
| JavaLanguageServerPlugin.logException(e.getMessage(), e); | ||
| } | ||
| Project projVertex = lsif.getVertexBuilder().project(); | ||
| LsifEmitter.getInstance().emit(projVertex); | ||
| LsifEmitter.getInstance() | ||
| .emit(lsif.getVertexBuilder().event(Event.EventScope.Project, Event.EventKind.BEGIN, | ||
| projVertex.getId())); | ||
| LsifEmitter.getInstance().emit( | ||
| lsif.getVertexBuilder().event(Event.EventScope.Project, Event.EventKind.BEGIN, projVertex.getId())); | ||
| List<ICompilationUnit> sourceList = getAllSourceFiles(javaProject); | ||
| dumpParallely(sourceList, threadPool, projVertex, lsif, monitor); | ||
| dumpParallelly(sourceList, threadPool, projVertex, lsif, hasPackageInformation, monitor); | ||
| VisitorUtils.endAllDocument(lsif); | ||
| LsifEmitter.getInstance().emit( | ||
| @@ -139,8 +162,89 @@ private List<ICompilationUnit> getAllSourceFiles(IJavaProject javaProject) throw | ||
| return res; | ||
| } | ||
| private void dumpParallely(List<ICompilationUnit> sourceList, ExecutorService threadPool, Project projVertex, | ||
| LsifService lsif, IProgressMonitor monitor) { | ||
| /** | ||
| * Generate and emit the package information of the given project and return if | ||
| * the project is published. | ||
| * | ||
| * @param proj the project | ||
| * @param monitor the IProgressMonitor | ||
| * @param lsif the lsif instance | ||
| * @param javaProject the javaProject of proj | ||
| * @return <code>true</code> if the given project is published | ||
| */ | ||
| private boolean generateExportPackageInformation(IProject proj, IProgressMonitor monitor, LsifService lsif, | ||
CsCherrYY marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| IJavaProject javaProject) throws Exception { | ||
| IPath folderPath = proj.getLocation(); | ||
| if (folderPath == null) { | ||
| return false; | ||
| } | ||
| IProjectImporter importer = this.handler.getImporter(folderPath.toFile(), monitor); | ||
| if (importer instanceof MavenProjectImporter) { | ||
| File pomfile = VisitorUtils.findPom(proj.getLocation(), 0); | ||
| if (pomfile == null) { | ||
| return false; | ||
| } | ||
| MavenProject mavenProject = Repository.getInstance().enlistMavenProject(lsif, pomfile); | ||
| if (mavenProject == null) { | ||
| return false; | ||
| } | ||
| Model model = mavenProject.getModel(); | ||
| String groupId = model.getGroupId(); | ||
| if (groupId == null) { | ||
| return false; | ||
| } | ||
| String artifactId = model.getArtifactId(); | ||
| if (artifactId == null) { | ||
| return false; | ||
| } | ||
| String version = model.getVersion(); | ||
| if (version == null) { | ||
| return false; | ||
| } | ||
| Scm scm = model.getScm(); | ||
| String url = null; | ||
| String type = null; | ||
| // scm is optional | ||
| if (scm != null) { | ||
| url = scm.getUrl(); | ||
| String connect = scm.getConnection(); | ||
| if (connect != null) { | ||
| type = ScmUrlUtils.getProvider(connect); | ||
| } | ||
| } | ||
| Repository.getInstance().enlistPackageInformation(lsif, javaProject.getPath().toString(), | ||
| groupId + "/" + artifactId, PackageManager.MAVEN, version, type, url); | ||
| return true; | ||
| } else if (importer instanceof GradleProjectImporter) { | ||
| GradleBuild build = GradleCore.getWorkspace().getBuild(proj).get(); | ||
| ProjectPublications model = build | ||
| .withConnection(connection -> connection.getModel(ProjectPublications.class), monitor); | ||
| List<? extends GradlePublication> publications = model.getPublications().getAll(); | ||
| if (publications.size() == 0) { | ||
| return false; | ||
| } | ||
| GradleModuleVersion gradleModuleVersion = publications.get(0).getId(); | ||
| String groupId = gradleModuleVersion.getGroup(); | ||
| if (StringUtils.isEmpty(groupId)) { | ||
| return false; | ||
| } | ||
| String artifactId = gradleModuleVersion.getName(); | ||
| if (StringUtils.isEmpty(artifactId)) { | ||
| return false; | ||
| } | ||
| String version = gradleModuleVersion.getVersion(); | ||
| if (StringUtils.isEmpty(version)) { | ||
| return false; | ||
| } | ||
| Repository.getInstance().enlistPackageInformation(lsif, javaProject.getPath().toString(), | ||
| groupId + "/" + artifactId, PackageManager.MAVEN, version, null, null); | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
| private void dumpParallelly(List<ICompilationUnit> sourceList, ExecutorService threadPool, Project projVertex, | ||
| LsifService lsif, boolean hasPackageInformation, IProgressMonitor monitor) { | ||
| Observable.fromIterable(sourceList) | ||
| .flatMap(item -> Observable.just(item).observeOn(Schedulers.from(threadPool)).map(sourceFile -> { | ||
| CompilationUnit cu = ASTUtil.createAST(sourceFile, monitor); | ||
| @@ -150,7 +254,7 @@ private void dumpParallely(List<ICompilationUnit> sourceList, ExecutorService th | ||
| } | ||
| IndexerContext context = new IndexerContext(docVertex, cu, projVertex); | ||
| LsifVisitor lsifVisitor = new LsifVisitor(lsif, context); | ||
| LsifVisitor lsifVisitor = new LsifVisitor(lsif, context, hasPackageInformation); | ||
| cu.accept(lsifVisitor); | ||
| DiagnosticVisitor diagnosticVisitor = new DiagnosticVisitor(lsif, context); | ||
| @@ -161,4 +265,5 @@ private void dumpParallely(List<ICompilationUnit> sourceList, ExecutorService th | ||
| return 0; | ||
| })).blockingSubscribe(); | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.