Skip to content

Commit

Permalink
Adding declarative Java hints to the LSP server. (apache#2905)
Browse files Browse the repository at this point in the history
  • Loading branch information
jlahoda authored Jun 16, 2021
1 parent d16d867 commit a2446ef
Show file tree
Hide file tree
Showing 27 changed files with 3,252 additions and 317 deletions.
17 changes: 17 additions & 0 deletions ide/api.lsp/apichanges.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

<?xml-stylesheet href="../../nbbuild/javadoctools/apichanges.xsl" type="text/xsl"?>
Expand Down Expand Up @@ -47,6 +51,19 @@
<!-- ACTUAL CHANGES BEGIN HERE: -->

<changes>
<change id="ErrorProvider">
<api name="LSP_API"/>
<summary>Adding ErrorProvider</summary>
<version major="1" minor="3"/>
<date day="10" month="6" year="2021"/>
<author login="jlahoda"/>
<compatibility binary="compatible" source="compatible" addition="yes" deletion="no"/>
<description>
An <code>ErrorProvider</code> interface introduced that allows to
compute errors/warnings for a given file.
</description>
<class package="org.netbeans.api.lsp" name="ErrorProvider"/>
</change>
<change id="HoverProvider">
<api name="LSP_API"/>
<summary>Adding Hover and HoverProvider</summary>
Expand Down
2 changes: 1 addition & 1 deletion ide/api.lsp/manifest.mf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Manifest-Version: 1.0
OpenIDE-Module: org.netbeans.api.lsp/1
OpenIDE-Module-Localizing-Bundle: org/netbeans/api/lsp/Bundle.properties
OpenIDE-Module-Specification-Version: 1.2
OpenIDE-Module-Specification-Version: 1.3
AutoUpdate-Show-In-Client: false

2 changes: 1 addition & 1 deletion ide/api.lsp/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ javac.compilerargs=-Xlint -Xlint:-serial
javadoc.name=LSP APIs
javadoc.title=LSP APIs
javadoc.arch=${basedir}/arch.xml
javadoc.apichanges=${basedir}/apichanges.xml
javadoc.apichanges=${basedir}/apichanges.xml
91 changes: 91 additions & 0 deletions ide/api.lsp/src/org/netbeans/api/lsp/CodeAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.netbeans.api.lsp;

/**
*An action over the code.
*
* @since 1.3
*/
public class CodeAction {

private final String title;
private final Command command;
private final WorkspaceEdit edit;

/**
* Construct the {@code CodeAction}.
*
* @param title the name of the action
* @param command the command that should be invoked
*/
public CodeAction(String title, Command command) {
this(title, command, null);
}

/**
* Construct the {@code CodeAction}.
*
* @param title the name of the action
* @param edit the {@code WorkspaceEdit} that should be performed
*/
public CodeAction(String title, WorkspaceEdit edit) {
this(title, null, edit);
}

/**
* Construct the {@code CodeAction}.
*
* @param text the name of the action
* @param command the command that should be invoked
* @param edit the {@code WorkspaceEdit} that should be performed
*/
public CodeAction(String title, Command command, WorkspaceEdit edit) {
this.title = title;
this.command = command;
this.edit = edit;
}

/**
* Return the name of the action.
*
* @return the name of the action
*/
public String getTitle() {
return title;
}

/**
* Return the command of the action.
*
* @return the command of the action
*/
public Command getCommand() {
return command;
}

/**
* Return the edit associated with the action.
*
* @return the edit associated with the action.
*/
public WorkspaceEdit getEdit() {
return edit;
}
}
61 changes: 61 additions & 0 deletions ide/api.lsp/src/org/netbeans/api/lsp/Command.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.netbeans.api.lsp;

/**
* A command. The exact list of known commands depends on
* the implementation of the server.
*
* @since 1.3
*/
public class Command {

private final String title;
private final String command;

/**
* Construct a new {@code Command}.
*
* @param title the title of the command
* @param command the code of the command that should be invoked
*/
public Command(String title, String command) {
this.title = title;
this.command = command;
}

/**
* The title of the command.
*
* @return the title of the command
*/
public String getTitle() {
return title;
}

/**
* The code of the command that should be invoked.
*
* @return the code of the command that should be invoked
*/
public String getCommand() {
return command;
}

}
Loading

0 comments on commit a2446ef

Please sign in to comment.