Skip to content

Commit 08ed2f7

Browse files
authored
Merge pull request #292 from Achal1607/lsp-refactored-code
Refactored codebase
2 parents aaed076 + cffad1f commit 08ed2f7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+3663
-4677
lines changed

BUILD.md

Lines changed: 79 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
## Prerequisities
2929

30-
- JDK, version 11 or later upto JDK 22
30+
- JDK, version 17 or later
3131
- Ant, latest version
3232
- Maven, latest version
3333
- Node.js, latest LTS (to build VSIX)
@@ -36,11 +36,12 @@
3636

3737
```bash
3838
$ git clone --recurse-submodules https://github.com/oracle/javavscode.git
39+
$ cd javavscode
3940
# the following target requires git executable to be on PATH:
4041
$ ant apply-patches
4142
$ ant build-netbeans
4243

43-
#Note if you do not wish to have l10n in scope then add no-l10n before any ant invocation target at beginning as below, by default l10n is enabled
44+
# Note if you do not wish to have l10n in scope then add no-l10n before any ant invocation target at beginning as below, by default l10n is enabled
4445
$ ant no-l10n apply-patches
4546
$ ant no-l10n build-netbeans
4647
```
@@ -58,26 +59,82 @@ The typical file name is `oracle-java-0.1.0.vsix`.
5859

5960
### Building for Development
6061

61-
If you want to develop the extension, use these steps for building instead:
62-
63-
```bash
64-
ant build-lsp-server
65-
```
66-
67-
This target is faster than building the `.vsix` file. Find the instructions
68-
for running and debugging below.
69-
70-
### Cleaning
62+
If you're developing the extension, follow these steps to build the project for faster iterations without packaging a `.vsix` file:
63+
64+
1. Run the following command to build the Language Server Protocol (LSP) server:
65+
```bash
66+
$ ant build-lsp-server
67+
```
68+
2. Navigate to the `vscode` folder:
69+
```bash
70+
$ cd vscode
71+
```
72+
3. Install the necessary Node.js dependencies:
73+
```bash
74+
$ npm install
75+
```
76+
4. Start the build watcher to automatically rebuild the extension on file changes:
77+
```bash
78+
$ npm run watch
79+
```
80+
81+
This process is faster than packaging the extension as a `.vsix` file, allowing for quicker development cycles.
82+
83+
### Debugging the Extension
84+
85+
Follow these steps to debug both the extension's TypeScript code and the NetBeans server code:
86+
87+
#### 1. Debugging TypeScript Code (VS Code Extension)
88+
1. Open the `vscode` folder in VS Code.
89+
2. Press `F5` to launch and debug the extension.
90+
91+
#### 2. Debugging NetBeans Code (Server Side)
92+
1. Open the **Command Palette** using `Ctrl+Shift+P` (or `Cmd+Shift+P` on macOS).
93+
2. Search for **Preferences: Open User Settings (JSON)** and select it.
94+
3. Locate or add the `jdk.serverVmOptions` setting in the JSON file and append the following arguments:
95+
```json
96+
"jdk.serverVmOptions": [
97+
"-Xdebug",
98+
"-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000"
99+
]
100+
```
101+
4. Start your debugging session. The NetBeans server will suspend execution and wait for a remote debugger to connect at port `8000`.
102+
103+
[NOTE: If you are using multiple profiles in VS Code, then set above configuration in appropriate profile
104+
105+
This configuration will enable you to debug both the extension’s TypeScript code and the NetBeans server-side code.
106+
107+
#### To enable Netbeans logs in the output channel of VS Code IDE
108+
109+
##### Option 1: Enable `jdk.verbose` Logging
110+
1. Open the **Command Palette** using `Ctrl+Shift+P` (or `Cmd+Shift+P` on macOS).
111+
2. Search for **Preferences: Open User Settings (JSON)** and select it.
112+
3. In the settings JSON file, add or update the following setting:
113+
```json
114+
"jdk.verbose": true
115+
```
116+
117+
##### Option 2: Enable NetBeans Logs via JVM Options
118+
1. Open the **Command Palette** using `Ctrl+Shift+P` (or `Cmd+Shift+P` on macOS).
119+
2. Search for **Preferences: Open User Settings (JSON)** and select it.
120+
3. Locate or add the `jdk.serverVmOptions` setting and append the following argument to the array:
121+
```json
122+
"jdk.serverVmOptions": ["-J-Dnetbeans.logger.console=true"]
123+
```
124+
125+
Both options will enable logging from the NetBeans server in the VS Code Output Channel.
126+
127+
### Cleaning the Extension
71128

72129
Often it is also important to properly clean everything. Use:
73130

74131
```bash
75-
ant clean-vscode-ext
76-
cd netbeans/
77-
netbeans$ ant clean
132+
$ ant clean-vscode-ext
133+
$ cd netbeans/
134+
$ ant clean
78135
```
79136

80-
### Testing
137+
### Testing the Extension
81138

82139
The `java.lsp.server` module has classical (as other NetBeans modules) tests.
83140
The most important one is [ServerTest](https://github.com/apache/netbeans/blob/master/java/java.lsp.server/test/unit/src/org/netbeans/modules/java/lsp/server/protocol/ServerTest.java)
@@ -99,15 +156,20 @@ $ npm_config_https_proxy=http://your.proxy.com:port ant test-vscode-ext
99156
when executing the tests for the first time. That shall overcome the proxy
100157
and download an instance of `code` to execute the tests with.
101158

102-
## Working with submodules
159+
## Working with git submodules
160+
103161
This project uses [git submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules) . In particular netbeans and netbeans-l10n are submodules pointing to specific commits in their respective repositories .
162+
104163
### Switching Branches
164+
105165
Add the --recurse-submodules flag to the git checkout command to update the submodules during the checkout.
106166
```bash
107167
git checkout --recurse-submodules <branch_name>
108168
```
109169
Note:- Merging branches with submodules pointing to different commits can be tricky. Refer the [git submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules) for more details on the same.
170+
110171
### Changing submodules versions
172+
111173
```bash
112174
# Fetching changes from remote submodule repositories
113175
git submodule update --remote

0 commit comments

Comments
 (0)