-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2370 from lf-lang/extending
Changes in the Lingua Franca Language Server to support improvements in the VSCode extension
- Loading branch information
Showing
6 changed files
with
257 additions
and
5 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
lsp/src/main/java/org/lflang/diagram/lsp/LFLanguageClient.java
This file contains 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,11 @@ | ||
package org.lflang.diagram.lsp; | ||
|
||
import de.cau.cs.kieler.klighd.lsp.KGraphLanguageClient; | ||
import org.eclipse.lsp4j.jsonrpc.services.JsonNotification; | ||
import org.eclipse.lsp4j.services.LanguageClient; | ||
|
||
public interface LFLanguageClient extends KGraphLanguageClient, LanguageClient { | ||
|
||
@JsonNotification("notify/sendLibraryReactors") | ||
public void sendLibraryReactors(LibraryFile libraryFile); | ||
} |
This file contains 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 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 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,53 @@ | ||
package org.lflang.diagram.lsp; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Represents a Lingua Franca (LF) file. This file can contain multiple ReactorNode elements, with | ||
* each node potentially having zero or more of these reactors. | ||
*/ | ||
public class LibraryFile { | ||
private String label; // The label (name) associated with the LF file. | ||
private String uri; // The URI specifying the location of the LF file. | ||
private List<ReactorNode> children; // The list of reactors included within the LF file. | ||
|
||
/** | ||
* Constructs a new LibraryFile with the specified URI. | ||
* | ||
* @param uri The URI specifying the location of the LF file. | ||
*/ | ||
public LibraryFile(String uri) { | ||
this.uri = uri; | ||
String[] splits = uri.split("/"); | ||
this.label = splits[splits.length - 1]; | ||
this.children = new ArrayList<>(); | ||
} | ||
|
||
/** | ||
* Retrieves the label (name) of the LF file. | ||
* | ||
* @return The label (name) of the LF file. | ||
*/ | ||
public String getLabel() { | ||
return label; | ||
} | ||
|
||
/** | ||
* Retrieves the URI specifying the location of the LF file. | ||
* | ||
* @return The URI specifying the location of the LF file. | ||
*/ | ||
public String getUri() { | ||
return uri; | ||
} | ||
|
||
/** | ||
* Retrieves the list of children nodes of the tree. | ||
* | ||
* @return The list of children nodes of the tree. | ||
*/ | ||
public List<ReactorNode> getChildren() { | ||
return children; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
lsp/src/main/java/org/lflang/diagram/lsp/NodePosition.java
This file contains 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,39 @@ | ||
package org.lflang.diagram.lsp; | ||
|
||
/** | ||
* @brief Position of a node within a text document or code file. | ||
* <p>A position is a pair of integers representing the starting and ending line numbers. | ||
*/ | ||
public class NodePosition { | ||
private int start; // The starting position of the node. | ||
private int end; // The ending position of the node. | ||
|
||
/** | ||
* Constructs a new NodePosition with the specified start and end positions. | ||
* | ||
* @param start The starting position of the node. | ||
* @param end The ending position of the node. | ||
*/ | ||
public NodePosition(int start, int end) { | ||
this.start = start; | ||
this.end = end; | ||
} | ||
|
||
/** | ||
* Retrieves the starting position of the node. | ||
* | ||
* @return The starting position of the node. | ||
*/ | ||
public int getStart() { | ||
return start; | ||
} | ||
|
||
/** | ||
* Retrieves the ending position of the node. | ||
* | ||
* @return The ending position of the node. | ||
*/ | ||
public int getEnd() { | ||
return end; | ||
} | ||
} |
This file contains 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,54 @@ | ||
package org.lflang.diagram.lsp; | ||
|
||
/** | ||
* Represents a node in a hierarchical structure where each node has a label, a URI, and positional | ||
* information. This node typically represents a reactor within a Lingua Franca (LF) file. | ||
* | ||
* @see LibraryFile | ||
*/ | ||
public class ReactorNode { | ||
|
||
private String label; // The name or label of the reactor. | ||
private String uri; // The URI indicating the location of the LF file that contains the reactor. | ||
private NodePosition position; // The position of the reactor within the LF file. | ||
|
||
/** | ||
* Constructs a new ReactorNode with the specified label, URI, and position. | ||
* | ||
* @param label The label or name of the reactor. | ||
* @param uri The URI that specifies the location of the LF file containing the reactor. | ||
* @param position The position of the reactor within the LF file. | ||
*/ | ||
public ReactorNode(String label, String uri, NodePosition position) { | ||
this.label = label; | ||
this.uri = uri; | ||
this.position = position; | ||
} | ||
|
||
/** | ||
* Returns the label of the reactor. | ||
* | ||
* @return The label of the reactor. | ||
*/ | ||
public String getLabel() { | ||
return label; | ||
} | ||
|
||
/** | ||
* Returns the URI of the LF file that contains the reactor. | ||
* | ||
* @return The URI of the LF file. | ||
*/ | ||
public String getUri() { | ||
return uri; | ||
} | ||
|
||
/** | ||
* Returns the position information of the reactor within the LF file. | ||
* | ||
* @return The position information of the reactor. | ||
*/ | ||
public NodePosition getPosition() { | ||
return position; | ||
} | ||
} |