Skip to content

Commit

Permalink
fix: Can emit group vertex and group event (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
CsCherrYY authored Nov 30, 2020
1 parent 4c3bd42 commit 4916d33
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@
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.Group;
import com.microsoft.java.lsif.core.internal.protocol.PackageInformation;
import com.microsoft.java.lsif.core.internal.protocol.Project;
import com.microsoft.java.lsif.core.internal.protocol.Group.ConflictResolution;
import com.microsoft.java.lsif.core.internal.visitors.DiagnosticVisitor;
import com.microsoft.java.lsif.core.internal.visitors.DocumentVisitor;
import com.microsoft.java.lsif.core.internal.visitors.LsifVisitor;
Expand Down Expand Up @@ -114,7 +116,10 @@ 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(
Expand All @@ -127,6 +132,8 @@ private void buildIndex(IPath path, IProgressMonitor monitor, LsifService lsif)
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()));
}

threadPool.shutdown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.microsoft.java.lsif.core.internal.protocol.Document;
import com.microsoft.java.lsif.core.internal.protocol.DocumentSymbolResult;
import com.microsoft.java.lsif.core.internal.protocol.Event;
import com.microsoft.java.lsif.core.internal.protocol.Group;
import com.microsoft.java.lsif.core.internal.protocol.HoverResult;
import com.microsoft.java.lsif.core.internal.protocol.ImplementationResult;
import com.microsoft.java.lsif.core.internal.protocol.MetaData;
Expand All @@ -30,6 +31,7 @@
import com.microsoft.java.lsif.core.internal.protocol.ReferenceResult;
import com.microsoft.java.lsif.core.internal.protocol.ResultSet;
import com.microsoft.java.lsif.core.internal.protocol.TypeDefinitionResult;
import com.microsoft.java.lsif.core.internal.protocol.Group.ConflictResolution;

public final class VertexBuilder {

Expand All @@ -47,6 +49,10 @@ public Event event(String scope, String kind, String data) {
return new Event(generator.next(), scope, kind, data);
}

public Group group(String uri, ConflictResolution resolution, String name, String rootUri) {
return new Group(generator.next(), uri, resolution, name, rootUri);
}

public Project project(String name) {
return new Project(generator.next(), name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public String getData() {
}

public static class EventScope {
public static final String Group = "group";
public static final String Project = "project";
public static final String DOCUMENT = "document";
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */

package com.microsoft.java.lsif.core.internal.protocol;

public class Group extends Vertex {

public enum ConflictResolution {
TAKEDUMP("takeDump"), TAKEDB("takeDB");

private final String resolution;

private ConflictResolution(String resolution) {
this.resolution = resolution;
}

@Override
public String toString() {
return this.resolution;
}
}

private String uri;

private String resolution;

private String name;

private String rootUri;

public Group(String id, String uri, ConflictResolution resolution, String name, String rootUri) {
super(id, Vertex.GROUP);
this.uri = uri;
this.resolution = resolution.toString();
this.name = name;
this.rootUri = rootUri;
}

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

public static final String IMPLEMENTATIONRESULT = "implementationResult";

public static final String GROUP = "group";

public static final String MONIKER = "moniker";

public static final String PACKAGEINFORMATION = "packageInformation";
Expand Down

0 comments on commit 4916d33

Please sign in to comment.