Skip to content

Commit

Permalink
fix: Add belongsTo edge and expand group (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
CsCherrYY authored Jan 28, 2021
1 parent d277ce0 commit 7ca2344
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,8 @@ public Edge packageInformation(Vertex from, Vertex to) {
public Edge diagnostic(Vertex from, Vertex to) {
return new Edge(generator.next(), Edge.T_DIAGNOSTIC, from.getId(), to.getId());
}

public Edge belongsTo(Vertex from, Vertex to) {
return new Edge(generator.next(), Edge.BELONGSTO, from.getId(), to.getId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ private void buildIndex(IPath path, IProgressMonitor monitor, LsifService lsif)

final ExecutorService threadPool = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());

Group groupVertex = lsif.getVertexBuilder().group(ResourceUtils.fixURI(path.toFile().toURI()),
ConflictResolution.TAKEDB, path.lastSegment(), ResourceUtils.fixURI(path.toFile().toURI()));
LsifEmitter.getInstance().emit(groupVertex);
LsifEmitter.getInstance().emit(
lsif.getVertexBuilder().event(Event.EventScope.Group, Event.EventKind.BEGIN, groupVertex.getId()));

for (IProject proj : projects) {
if (proj == null) {
return;
Expand All @@ -116,26 +122,25 @@ private void buildIndex(IPath path, IProgressMonitor monitor, LsifService lsif)
// ProjectConnection.getModel
JavaLanguageServerPlugin.logException(e.getMessage(), e);
}
Group groupVertex = lsif.getVertexBuilder().group(ResourceUtils.fixURI(path.toFile().toURI()), ConflictResolution.TAKEDB, javaProject.getElementName(), ResourceUtils.fixURI(path.toFile().toURI()));
LsifEmitter.getInstance().emit(groupVertex);
LsifEmitter.getInstance().emit(
lsif.getVertexBuilder().event(Event.EventScope.Group, Event.EventKind.BEGIN, groupVertex.getId()));

Project projVertex = lsif.getVertexBuilder().project(javaProject.getElementName());
LsifEmitter.getInstance().emit(projVertex);
LsifEmitter.getInstance().emit(
lsif.getVertexBuilder().event(Event.EventScope.Project, Event.EventKind.BEGIN, projVertex.getId()));

LsifEmitter.getInstance().emit(lsif.getEdgeBuilder().belongsTo(projVertex, groupVertex));
List<ICompilationUnit> sourceList = getAllSourceFiles(javaProject);

dumpParallelly(sourceList, threadPool, projVertex, lsif, hasPackageInformation, monitor);

VisitorUtils.endAllDocument(lsif);
LsifEmitter.getInstance().emit(
lsif.getVertexBuilder().event(Event.EventScope.Project, Event.EventKind.END, projVertex.getId()));
LsifEmitter.getInstance().emit(
lsif.getVertexBuilder().event(Event.EventScope.Group, Event.EventKind.END, groupVertex.getId()));
}

LsifEmitter.getInstance()
.emit(lsif.getVertexBuilder().event(Event.EventScope.Group, Event.EventKind.END, groupVertex.getId()));

threadPool.shutdown();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public class Edge extends Element {

public final static String PACKAGEINFORMATION = "packageInformation";

public final static String BELONGSTO = "belongsTo";

private String outV;

private String inV;
Expand Down

0 comments on commit 7ca2344

Please sign in to comment.