Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
05f159d
fix deprecations and raise minimum required version
Trias Apr 27, 2021
53aae34
add / clarify documentation
Trias Apr 27, 2021
eca4495
fix deprecations (untested)
Trias Apr 27, 2021
fbe1b26
fix deprecations
Trias Apr 27, 2021
0ce14b9
update build.gradle
Trias Apr 27, 2021
6b72c1b
fix tests and update dependencies
Trias Apr 27, 2021
7835633
add licence
Trias Apr 27, 2021
c05c7ab
fix deprecations / simplify code
Trias Apr 29, 2021
d8b950d
fix spotbugs warnings
Trias Apr 29, 2021
36a7390
add service to plugin.xml.example
Trias Apr 29, 2021
b9be245
Merge pull request #251 from Trias/fixDeprecations
NipunaRanasinghe Jun 19, 2021
fcd8470
Add Issue Template
anupama-pathirage Sep 7, 2021
da62cbb
Merge pull request #256 from anupama-pathirage/addIssueTemplate
keizer619 Sep 7, 2021
c98c09b
Add stale check for PRs
anupama-pathirage Sep 8, 2021
4fac273
Merge pull request #257 from anupama-pathirage/addStale
keizer619 Sep 8, 2021
4994107
Add code owners
anupama-pathirage Sep 8, 2021
cd8acce
Merge pull request #258 from anupama-pathirage/addCodeOwners
keizer619 Sep 9, 2021
49e8001
fix null pointers
snps-akashn Jul 6, 2022
21d2873
check for null before dereferencing LanguageServerWrapper on project …
snps-akashn Jul 11, 2022
4c2b17d
Remove jdk8 checks from CI build
NipunaRanasinghe Jul 14, 2022
3374b59
Merge pull request #269 from ballerina-platform/NipunaRanasinghe-patch-1
NipunaRanasinghe Jul 21, 2022
e8d2455
Merge pull request #267 from akashnagesh/fix-null-ptr
NipunaRanasinghe Jul 21, 2022
f5a9e73
Merge pull request #268 from akashnagesh/issue-254
NipunaRanasinghe Jul 21, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Lines starting with '#' are comments.
# Each line is a file pattern followed by one or more owners.

# See: https://help.github.com/articles/about-codeowners/

# These owners will be the default owners for everything in the repo.
* @hevayo @NipunaRanasinghe
24 changes: 24 additions & 0 deletions .github/ISSUE_TEMPLATE/type_bug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
name: "Bug Report"
about: "Report a bug if something is not working as expected"
labels: 'Type/Bug'

---

**Description:**
<!-- Give a brief description of the bug -->

**Steps to reproduce:**

**Affected Versions:**

**OS, DB, other environment details and versions:**

**Related Issues (optional):**
<!-- Any related issues such as sub tasks, issues reported in other repositories (e.g component repositories), similar problems, etc. -->

**Suggested Labels (optional):**
<!-- Optional comma separated list of suggested labels. Non committers can’t assign labels to issues, so this will help issue creators who are not a committer to suggest possible labels-->

**Suggested Assignees (optional):**
<!--Optional comma separated list of suggested team members who should attend the issue. Non committers can’t assign issues to assignees, so this will help issue creators who are not a committer to suggest possible assignees-->
22 changes: 22 additions & 0 deletions .github/ISSUE_TEMPLATE/type_improvement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: "Improvement Request"
about: "Create an improvement request for an existing feature"
labels: 'Type/Improvement'

---

**Description:**
<!-- Give a brief description of the improvement -->

**Describe your problem(s)**

**Describe your solution(s)**

**Related Issues (optional):**
<!-- Any related issues such as sub tasks, issues reported in other repositories (e.g component repositories), similar problems, etc. -->

**Suggested Labels (optional):**
<!-- Optional comma separated list of suggested labels. Non committers can’t assign labels to issues, so this will help issue creators who are not a committer to suggest possible labels-->

**Suggested Assignees (optional):**
<!--Optional comma separated list of suggested team members who should attend the issue. Non committers can’t assign issues to assignees, so this will help issue creators who are not a committer to suggest possible assignees-->
22 changes: 22 additions & 0 deletions .github/ISSUE_TEMPLATE/type_new_feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: "New Feature Request"
about: "Create a new feature request"
labels: 'Type/NewFeature'

---

**Description:**
<!-- Give a brief description of the new feature -->

**Describe your problem(s)**

**Describe your solution(s)**

**Related Issues (optional):**
<!-- Any related issues such as sub tasks, issues reported in other repositories (e.g component repositories), similar problems, etc. -->

**Suggested Labels (optional):**
<!-- Optional comma separated list of suggested labels. Non committers can’t assign labels to issues, so this will help issue creators who are not a committer to suggest possible labels-->

**Suggested Assignees (optional):**
<!--Optional comma separated list of suggested team members who should attend the issue. Non committers can’t assign issues to assignees, so this will help issue creators who are not a committer to suggest possible assignees-->
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/type_task.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: "Task"
about: "Create a task which you want to keep track"
labels: 'Type/Task'

---

**Description:**
<!-- Give a brief description of the task -->

**Describe your task(s)**

**Related Issues (optional):**
<!-- Any related issues such as sub tasks, issues reported in other repositories (e.g component repositories), similar problems, etc. -->

**Suggested Labels (optional):**
<!-- Optional comma separated list of suggested labels. Non committers can’t assign labels to issues, so this will help issue creators who are not a committer to suggest possible labels-->

**Suggested Assignees (optional):**
<!--Optional comma separated list of suggested team members who should attend the issue. Non committers can’t assign issues to assignees, so this will help issue creators who are not a committer to suggest possible assignees-->
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
fail-fast: false
matrix:
java_version: ['8', '11']
java_version: ['11']
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- uses: actions/checkout@v1
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/stale_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: 'Close stale pull requests'

on:
schedule:
- cron: '30 19 * * *'
workflow_dispatch:

jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v3
with:
stale-pr-message: 'This PR has been open for more than 15 days with no activity. This will be closed in 3 days unless the `stale` label is removed or commented.'
close-pr-message: 'Closed PR due to inactivity for more than 18 days.'
days-before-pr-stale: 15
days-before-pr-close: 3
days-before-issue-stale: -1
days-before-issue-close: -1
170 changes: 87 additions & 83 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,89 +43,10 @@ For instructions on adding **Lsp4IntelliJ** as a dependency when using the below
- sbt

>**Info:** - The Maven publishing process is currently WIP. Thus, the possibility to add LSP4IntelliJ as a dependency will be available soon in the Maven central.

### 2. Add the language server definition

1. Instantiate a concrete subclass of the
[LanguageServerDefinition](src/main/java/org/wso2/lsp4intellij/client/languageserver/serverdefinition/LanguageServerDefinition.java).

You can use the following concrete class:

- **RawCommandServerDefinition(string fileExtension, string[] command)**

This definition can be used to start a language server using a command.

* You can specify multiple extensions for a server by separating them with a comma (e.g., "ts,js").

* If you want to bind your language server definition only with a specific set of files, you can use that
specific file pattern as a regex expression instead of binding with the file extension (e.g., "application*.properties").

Examples:

Ballerina Language Server
```java
new RawCommandServerDefinition("bal", new String[]{"path/to/launcher-script.sh"});
```

BSL Language Server
```java
String[] command = new String[]{"java","-jar","path/to/language-server.jar"};
new RawCommandServerDefinition("bsl,os",command);
```

- **ProcessBuilderServerDefinition(string fileExtension, string[] command)**

This definition is an extended form of the **RawCommandServerDefinition**, which accepts
`java.lang.ProcessBuilder` instances so that the users will have more controllability over the language
server
process to be created.

* You can specify multiple extensions for a server by separating them with a comma (e.g., "ts,js").

* If you want to bind your language server definition only with a specific set of files, you can use that
specific file pattern as a regex expression instead of binding with the file extension (e.g., "application*.properties").

Examples:

Ballerina Language Server
```java
ProcessBuilder process = new ProcessBuilder("path/to/launcher-script.sh");
new ProcessBuilderServerDefinition("bal", process);
```

BSL Language Server
```java
ProcessBuilder process = new ProcessBuilder("java","-jar","path/to/language-server.jar");
new ProcessBuilderServerDefinition("bsl,os", process);
```

> **Note:** All of the above implementations will use server stdin/stdout to communicate.

2. To register any of the aforementioned options, implement a preloading activity in your plugin as shown
below.

>**Tip:** For other options you can use instead of implementing a preloading activity, go to [InteliJ Plugin initialization on startup](https://www.plugin-dev.com/intellij/general/plugin-initial-load/)
to)

Example:

```java
public class BallerinaPreloadingActivity extends PreloadingActivity {
IntellijLanguageClient.addServerDefinition(new RawCommandServerDefinition("bal", new String[]{"path/to/launcher-script.sh"}));
}
```

With plugin.xml containing;

```xml
<extensions defaultExtensionNs="com.intellij">
<preloadingActivity implementation="io.ballerina.plugins.idea.preloading.BallerinaPreloadingActivity"
id="io.ballerina.plugins.idea.preloading.BallerinaPreloadingActivity" />
</extensions>
```

### 3. Add configurations to the plugin.xml file

### 2. Add a plugin.xml file
<details>
<summary>deprecated "components"-based setup</summary>
1. Add `IntellijLanguageClient` as an application component.
```xml
<application-components>
Expand Down Expand Up @@ -194,10 +115,93 @@ With plugin.xml containing;
```

> **Note:** You do not need any additional configurations for the other features.

</details>

Copy the example plugin.xml [here](resources/plugin.xml.example) and place it under `src/resources/META-INF` in your plugin and adjust it to your needs.

### 3. Add a preloading activity to configure LSP

Implement a preloading activity in your plugin as shown below.

>**Tip:** For other options you can use instead of implementing a preloading activity, go to [InteliJ Plugin initialization on startup](https://www.plugin-dev.com/intellij/general/plugin-initial-load/)
to)

Example:

```java
public class BallerinaPreloadingActivity extends PreloadingActivity {
public void preload(ProgressIndicator indicator) {
IntellijLanguageClient.addServerDefinition(new RawCommandServerDefinition("bal", new String[]{"path/to/launcher-script.sh"}));
}
}
```

With plugin.xml containing;

```xml
<extensions defaultExtensionNs="com.intellij">
<preloadingActivity implementation="io.ballerina.plugins.idea.preloading.BallerinaPreloadingActivity"
id="io.ballerina.plugins.idea.preloading.BallerinaPreloadingActivity" />
</extensions>
```

If you have connected to your language server successfully, you will see a green icon at the bottom-right side of your
IDE when opening a file that has a registered file extension as shown below.

#### Alternative ways to connect to a language server
Aside RawCommandServerDefinition there are several classes implementing [LanguageServerDefinition](src/main/java/org/wso2/lsp4intellij/client/languageserver/serverdefinition/LanguageServerDefinition.java).

You can use the following concrete class:

- **RawCommandServerDefinition(string fileExtension, string[] command)**

This definition can be used to start a language server using a command.

* You can specify multiple extensions for a server by separating them with a comma (e.g., "ts,js").

* If you want to bind your language server definition only with a specific set of files, you can use that
specific file pattern as a regex expression instead of binding with the file extension (e.g., "application*.properties").

Examples:

Ballerina Language Server
```java
new RawCommandServerDefinition("bal", new String[]{"path/to/launcher-script.sh"});
```

BSL Language Server
```java
String[] command = new String[]{"java","-jar","path/to/language-server.jar"};
new RawCommandServerDefinition("bsl,os",command);
```

- **ProcessBuilderServerDefinition(string fileExtension, string[] command)**

This definition is an extended form of the **RawCommandServerDefinition**, which accepts
`java.lang.ProcessBuilder` instances so that the users will have more controllability over the language
server
process to be created.

* You can specify multiple extensions for a server by separating them with a comma (e.g., "ts,js").

* If you want to bind your language server definition only with a specific set of files, you can use that
specific file pattern as a regex expression instead of binding with the file extension (e.g., "application*.properties").

Examples:

Ballerina Language Server
```java
ProcessBuilder process = new ProcessBuilder("path/to/launcher-script.sh");
new ProcessBuilderServerDefinition("bal", process);
```

BSL Language Server
```java
ProcessBuilder process = new ProcessBuilder("java","-jar","path/to/language-server.jar");
new ProcessBuilderServerDefinition("bsl,os", process);
```
> **Note:** All of the above implementations will use server stdin/stdout to communicate.

![](resources/images/lang-server-connect.gif)

>**Tip:** You can also click on the icon to see the connected files and the timeouts.
Expand Down
25 changes: 17 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "jacoco"
id "org.jetbrains.intellij" version "0.4.9"
id "org.jetbrains.intellij" version "0.7.3"
id "com.github.hierynomus.license" version "0.15.0"
id "com.github.gradle-git-version-calculator" version "1.1.0"
id 'net.researchgate.release' version '2.6.0'
Expand All @@ -14,23 +14,29 @@ repositories {
mavenCentral()
}

tasks{
runPluginVerifier {
ideVersions = "2021.1"
}
}

group = "org.wso2.lsp4intellij"
version = gitVersionCalculator.calculateVersion("v")

intellij {
version '2020.1'
version '2021.1'
type 'IC'
updateSinceUntilBuild false
}

dependencies {
compile group: 'org.eclipse.lsp4j', name: 'org.eclipse.lsp4j', version: '0.10.0'
compile group: 'com.vladsch.flexmark', name: 'flexmark', version: '0.34.58'
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.4'
testCompile group: 'junit', name: 'junit', version: '4.11'
testCompile group: 'org.mockito', name: 'mockito-core', version: '3.3.3'
testCompile group: 'org.powermock', name: 'powermock-api-mockito2', version: '2.0.5'
testCompile group: 'org.powermock', name: 'powermock-module-junit4', version: '2.0.5'
compile group: 'com.vladsch.flexmark', name: 'flexmark', version: '0.34.60'
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0'
testCompile group: 'junit', name: 'junit', version: '4.13.2'
testCompile group: 'org.mockito', name: 'mockito-core', version: '3.9.0'
testCompile group: 'org.powermock', name: 'powermock-api-mockito2', version: '2.0.9'
testCompile group: 'org.powermock', name: 'powermock-module-junit4', version: '2.0.9'
}

sourceSets {
Expand All @@ -41,6 +47,9 @@ sourceSets {
}
}

sourceCompatibility = 11
targetCompatibility = 11

license {
header = rootProject.file("resources/license/HEADER.txt")
ext["year"] = Calendar.getInstance().get(Calendar.YEAR)
Expand Down
Loading