Skip to content

Commit

Permalink
Merge pull request #2330 from apache/master
Browse files Browse the repository at this point in the history
Sync master to release121 for 12.1-beta4
  • Loading branch information
neilcsmith-net authored Aug 24, 2020
2 parents 26e6ce8 + 35c4357 commit cade258
Show file tree
Hide file tree
Showing 30 changed files with 1,283 additions and 547 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,16 @@ public void propertyChange(PropertyChangeEvent evt) {
// selection is not removed when text is input via IME
// so, just remove it when the caret is changed
if ("caret".equals(evt.getPropertyName())) { // NOI18N
if (evt.getOldValue() instanceof Caret) {
if (evt.getOldValue() instanceof Caret
&& evt.getNewValue() instanceof Caret) { // NETBEANS-4620 check new value is not null but Caret
Caret oldCaret = (Caret) evt.getOldValue();
if (oldCaret != null) {
int dotPosition = oldCaret.getDot();
int markPosition = oldCaret.getMark();
if (dotPosition != markPosition) {
try {
editorPane.getDocument().remove(Math.min(markPosition, dotPosition), Math.abs(markPosition - dotPosition));
} catch (BadLocationException ex) {
LOG.log(Level.WARNING, "Invalid removal offset: {0}", ex.offsetRequested()); // NOI18N
}
int dotPosition = oldCaret.getDot();
int markPosition = oldCaret.getMark();
if (dotPosition != markPosition) {
try {
editorPane.getDocument().remove(Math.min(markPosition, dotPosition), Math.abs(markPosition - dotPosition));
} catch (BadLocationException ex) {
LOG.log(Level.WARNING, "Invalid removal offset: {0}", ex.offsetRequested()); // NOI18N
}
}
}
Expand Down Expand Up @@ -412,4 +411,4 @@ public String getOriginalActionName() {
return originalActionName;
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import java.awt.Component;
import java.awt.Dimension;
import java.awt.GraphicsEnvironment;
import java.awt.Toolkit;
import java.awt.event.ActionListener;
import java.awt.event.ContainerEvent;
import java.awt.event.ContainerListener;
Expand Down Expand Up @@ -313,6 +315,9 @@ private DebuggerAction getDebuggerAction(Component c) {
}

private void setupToolbar(final DebuggerEngine engine) {
if (GraphicsEnvironment.isHeadless()) {
return;
}
final List<Component> buttonsToClose = new ArrayList<Component>();
buttonsToClose.add(new java.awt.Label("EMPTY"));
final boolean isFirst;
Expand Down
1 change: 1 addition & 0 deletions java/debugger.jpda.truffle/manifest.mf
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ OpenIDE-Module-Specification-Version: 1.6
OpenIDE-Module-Provides: org.netbeans.modules.debugger.jpda.truffle
OpenIDE-Module-Requires: org.netbeans.api.debugger.jpda.JPDADebuggerEngineImpl,
org.netbeans.spi.debugger.ui
OpenIDE-Module-Recommends: cnb.org.netbeans.modules.java.kit
OpenIDE-Module-Package-Dependencies: com.sun.jdi[VirtualMachineManager]
6 changes: 0 additions & 6 deletions java/debugger.jpda.truffle/nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,6 @@
<specification-version>1.4</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.modules.java.kit</code-name-base>
<run-dependency>
<specification-version>1.0</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.modules.java.platform</code-name-base>
<build-prerequisite/>
Expand Down
1 change: 1 addition & 0 deletions java/java.lsp.server/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<copy todir="${lsp.build.dir}/etc" file="script/etc/nb-java-lsp-server.conf" />
<copy todir="${lsp.build.dir}/etc" file="script/etc/nb-java-lsp-server.clusters" />
<chmod file="${lsp.build.dir}/bin/nb-java-lsp-server" perm="u+x" />
<chmod file="${lsp.build.dir}/java/maven/bin/mvn" perm="u+x" />
<delete file="${lsp.build.dir}/lib/nb-javac-9-api.jar" />
<delete file="${lsp.build.dir}/lib/nb-javac-9-impl.jar" />
<delete file="${lsp.build.dir}/lib/org-netbeans-modules-java-source-nbjavac.jar" />
Expand Down
9 changes: 9 additions & 0 deletions java/java.lsp.server/licenseinfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
<file>vscode/src/extension.ts</file>
<license ref="MIT-vscode-ext" />
</fileset>
<fileset>
<file>vscode/.vscodeignore</file>
<file>vscode/.eslintrc.json</file>
<file>vscode/.vscode/extensions.json</file>
<file>vscode/.vscode/launch.json</file>
<file>vscode/.vscode/tasks.json</file>
<file>vscode/.vscode/settings.json</file>
<license ref="Apache-2.0" />
</fileset>
<fileset>
<file>script/etc/nb-java-lsp-server.clusters</file>
<license ref="Apache-2.0-ASF" />
Expand Down
2 changes: 1 addition & 1 deletion java/java.lsp.server/script/etc/nb-java-lsp-server.conf
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ default_cachedir="${DEFAULT_CACHEDIR_ROOT}/dev"

# options used by the launcher by default, can be overridden by explicit
# command line switches
default_options="--nogui --nosplash -J-Djava.awt.headless=true --start-java-language-server -J--add-opens=java.base/java.net=ALL-UNNAMED -J--add-opens=java.base/java.lang.ref=ALL-UNNAMED -J--add-opens=java.base/java.lang=ALL-UNNAMED -J--add-opens=java.base/java.security=ALL-UNNAMED -J--add-opens=java.base/java.util=ALL-UNNAMED -J--add-opens=java.desktop/javax.swing.plaf.basic=ALL-UNNAMED -J--add-opens=java.desktop/javax.swing.text=ALL-UNNAMED -J--add-opens=java.desktop/javax.swing=ALL-UNNAMED -J--add-opens=java.desktop/java.awt=ALL-UNNAMED -J--add-opens=java.desktop/java.awt.event=ALL-UNNAMED -J--add-opens=java.prefs/java.util.prefs=ALL-UNNAMED -J--add-opens=jdk.jshell/jdk.jshell=ALL-UNNAMED -J--add-modules=jdk.jshell -J--add-exports=java.desktop/sun.awt=ALL-UNNAMED -J--add-exports=java.desktop/java.awt.peer=ALL-UNNAMED -J--add-exports=java.desktop/com.sun.beans.editors=ALL-UNNAMED -J--add-exports=java.desktop/sun.swing=ALL-UNNAMED -J--add-exports=java.desktop/sun.awt.im=ALL-UNNAMED -J--add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED -J--add-exports=java.management/sun.management=ALL-UNNAMED -J--add-exports=java.base/sun.reflect.annotation=ALL-UNNAMED -J-XX:+IgnoreUnrecognizedVMOptions"
default_options="--nogui --nosplash -J-Dnetbeans.logger.console=true -J-Djava.awt.headless=true -J--add-opens=java.base/java.net=ALL-UNNAMED -J--add-opens=java.base/java.lang.ref=ALL-UNNAMED -J--add-opens=java.base/java.lang=ALL-UNNAMED -J--add-opens=java.base/java.security=ALL-UNNAMED -J--add-opens=java.base/java.util=ALL-UNNAMED -J--add-opens=java.desktop/javax.swing.plaf.basic=ALL-UNNAMED -J--add-opens=java.desktop/javax.swing.text=ALL-UNNAMED -J--add-opens=java.desktop/javax.swing=ALL-UNNAMED -J--add-opens=java.desktop/java.awt=ALL-UNNAMED -J--add-opens=java.desktop/java.awt.event=ALL-UNNAMED -J--add-opens=java.prefs/java.util.prefs=ALL-UNNAMED -J--add-opens=jdk.jshell/jdk.jshell=ALL-UNNAMED -J--add-modules=jdk.jshell -J--add-exports=java.desktop/sun.awt=ALL-UNNAMED -J--add-exports=java.desktop/java.awt.peer=ALL-UNNAMED -J--add-exports=java.desktop/com.sun.beans.editors=ALL-UNNAMED -J--add-exports=java.desktop/sun.swing=ALL-UNNAMED -J--add-exports=java.desktop/sun.awt.im=ALL-UNNAMED -J--add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED -J--add-exports=java.management/sun.management=ALL-UNNAMED -J--add-exports=java.base/sun.reflect.annotation=ALL-UNNAMED -J-XX:+IgnoreUnrecognizedVMOptions"
# for development purposes you may wish to append: -J-Dnetbeans.logger.console=true -J-ea

# default location of JDK/JRE, can be overridden by using --jdkhome <dir> switch
Expand Down
19 changes: 19 additions & 0 deletions java/java.lsp.server/vscode/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"@typescript-eslint/class-name-casing": "warn",
"@typescript-eslint/semi": "warn",
"curly": "warn",
"eqeqeq": "warn",
"no-throw-literal": "warn",
"semi": "off"
}
}
7 changes: 7 additions & 0 deletions java/java.lsp.server/vscode/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"dbaeumer.vscode-eslint"
]
}
36 changes: 36 additions & 0 deletions java/java.lsp.server/vscode/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// A launch configuration that compiles the extension and then opens it inside a new window
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [
{
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
},
{
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
],
"outFiles": [
"${workspaceFolder}/out/test/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
}
]
}
11 changes: 11 additions & 0 deletions java/java.lsp.server/vscode/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Place your settings in this file to overwrite default and user settings.
{
"files.exclude": {
"out": false // set this to true to hide the "out" folder with the compiled JS files
},
"search.exclude": {
"out": true // set this to false to include "out" folder in search results
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off"
}
20 changes: 20 additions & 0 deletions java/java.lsp.server/vscode/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
10 changes: 10 additions & 0 deletions java/java.lsp.server/vscode/.vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.vscode/**
.vscode-test/**
out/test/**
src/**
.gitignore
vsc-extension-quickstart.md
**/tsconfig.json
**/.eslintrc.json
**/*.map
**/*.ts
50 changes: 41 additions & 9 deletions java/java.lsp.server/vscode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,48 @@ https://github.com/microsoft/vscode-extension-samples
# Building

To build the VS Code extension do:
* cd java/java.lsp.server
* ant build-vscode-ext

The resulting extension is then in the build directory, with the vsix extension.
```bash
netbeans$ cd java/java.lsp.server
java.lsp.server$ ant build-vscode-ext
```

#Building for Development
The resulting extension is then in the `build` directory, with the `.vsix` extension.

# Building for Development

If you want to develop the extension, use these steps for building instead:
* cd java/java.lsp.server
* ant build-lsp-server
* cd vscode
* npm install
* npm run compile

```bash
netbeans$ cd java/java.lsp.server
java.lsp.server$ ant build-lsp-server
java.lsp.server$ cd vscode
vscode$ npm install
vscode$ npm run compile
```

# Running and Debugging

To use the extension created for developement you can run VSCode with
following parameter:

```bash
vscode$ code --extensionDevelopmentPath=`pwd` name_of_folder_to_open
```

Or you can open the `vscode` folder in `code` directly and use **F5** to
debug the extension's typescript code.

The idea when debugging Java code is to launch the NetBeans part of the LSP
system first, provide suitable debug arguments:

```bash
vscode$ ./nb-java-lsp-server/bin/nb-java-lsp-server -J-agentlib:jdwp=transport=dt_socket,server=y,address=8000
```

and then connect to with debugger setup all breakpoints and then also connect
from the VSCode extension:

```bash
vscode$ code --extensionDevelopmentPath=`pwd` name_of_folder_to_open
```
Loading

0 comments on commit cade258

Please sign in to comment.