Skip to content

Commit

Permalink
Check for source level java compatibility
Browse files Browse the repository at this point in the history
Get java version from Maven projects

Util for checking if extension command is available

Move file

Get java version from installation path

Project abstraction with methos to retreive java version

Initial position of breakpoints view is next to navigator

Always open expression evaluator view

PHP: removed built-in type real
  - deleted the built-in type real
    (php does not have a built-in real type: https://www.php.net/manual/en/language.types.intro.php
    Also see the warning under "Scalar Types": https://www.php.net/manual/en/language.types.declarations.php)
  - fixed broken tests
  - new tests added
  - fixes generation of return type real instead of float for a method when overriding a base class method with an autocomplete
  - fixes generation of return type real instead of float for a function in phpDoc

Fix "Fix Imports" [apacheGH-7546]

- apache#7546
- Compare segments of namespace names to avoid adding incorrect items
- Add a unit test

Reduce redundant cast warnings. These happen as a side result of code cleanup..

Reduce warnings that look like this:

   [repeat] /home/bwalker/src/netbeans/enterprise/tomcat5/src/org/netbeans/modules/tomcat5/util/LogManager.java:271: warning: [cast] redundant cast to LogViewer
   [repeat]         contextLog = (LogViewer)contextLogViewers.get(moduleID);
   [repeat]                      ^Cleanup redundant casts. These are a side effect of work done doing code cleanup.

Fix unit tests

- Use `checkCompletionOnlyDocumentation` test method because there are functions that have the same prefix

Micronaut: Clear symbol cache on ClasspathInfo changes.

Remove downloader from NBI

 - the download manager relied on suspend/resume/stop from
   java.lang.Thread which were deprecated since Java 1.2
 - JDK 23 removes suspend/resume, others are already no-ops
 - fixing this would require a completely different approach,
   and since NBI is no longer maintained and in the process
   to be replaced by nbpackage this is th easiest option

Remove redundant code

Remove new lines

Await on NbLanguageClient

Removed unused code

Reduce number of resolve(undefined)

Explicitly set xml2js parser to be sync

Shorten array element check

Recursively search for subprojects

Reference github issue inside comment

Use vscode.Uri.file

Modify regex to support whitespaces between identifiers, literals and symbols

Use vscode.Uri.parse

Removed explicit check for the command as no longer needed

Add licence header

NBI: disable update check again

 - Hide check-for-updates step from the (windows) installer again
   since it is a no-op with the current NB release model
 - reverts apache#1348 without changing codepaths outside the checkbox
   logic to reduce risks of other side effects
 - can be re-enabled using a property

Docker - Load images

Docker images don't load because `VirtualSize` attribute was removed from Docker Engine in v1.44.

---

Using `getOrDefault` for the `Created`, `Size` and `VirtualSize` attributes.

Using `Size` as default value to `VirtualSize`.

Annotating the `VirtualSize` attribute as deprecated

CI: start testing on 23-ea

 - move from 22 to 23-ea (all except java hints which would require
   nb-javac 23)
 - merge APISupport job into another job

JDK 23 related test fixes

 - '-proc:full' is now required for annotation processing
 - java.lang.Thread finally lost a few methods

Improving multistep infrastructure, command for uploading cloud assets to config map
  • Loading branch information
petrovic-d committed Jul 10, 2024
1 parent 50be12a commit 8b31dac
Show file tree
Hide file tree
Showing 7 changed files with 439 additions and 3 deletions.
66 changes: 65 additions & 1 deletion java/java.lsp.server/vscode/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion java/java.lsp.server/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1256,6 +1256,7 @@
"@types/ps-node": "^0.1.0",
"@types/vscode": "^1.76.0",
"@types/vscode-webview": "^1.57.1",
"@types/xml2js": "^0.4.14",
"@vscode/codicons": "0.0.29",
"esbuild": "^0.16.17",
"glob": "^7.1.6",
Expand All @@ -1269,7 +1270,8 @@
"@vscode/webview-ui-toolkit": "^1.2.2",
"jdk-utils": "^0.4.4",
"jsonc-parser": "3.0.0",
"vscode-languageclient": "8.0.1"
"vscode-languageclient": "8.0.1",
"xml2js": "^0.6.2"
},
"__metadata": {
"id": "66c7d7dc-934c-499b-94af-5375e8234fdd",
Expand Down
4 changes: 3 additions & 1 deletion java/java.lsp.server/vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,13 @@ import { InputStep, MultiStepInput } from './utils';
import { PropertiesView } from './propertiesView/propertiesView';
import * as configuration from './jdk/configuration';
import * as jdk from './jdk/jdk';
import { validateJDKCompatibility } from './jdk/validation/validation';

const API_VERSION : string = "1.0";
export const COMMAND_PREFIX : string = "nbls";
const DATABASE: string = 'Database';
const listeners = new Map<string, string[]>();
let client: Promise<NbLanguageClient>;
export let client: Promise<NbLanguageClient>;
let testAdapter: NbTestAdapter | undefined;
let nbProcess : ChildProcess | null = null;
let debugPort: number = -1;
Expand Down Expand Up @@ -184,6 +185,7 @@ function findJDK(onChange: (path : string | null) => void): void {
}

let currentJdk = find();
validateJDKCompatibility(currentJdk);
let timeout: NodeJS.Timeout | undefined = undefined;
workspace.onDidChangeConfiguration(params => {
if (timeout) {
Expand Down
32 changes: 32 additions & 0 deletions java/java.lsp.server/vscode/src/jdk/validation/extensionUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* 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.
*/

import * as vscode from 'vscode';
import { client as nblsClient } from '../../extension';

const RH_EXTENSION_ID = 'redhat.java';

export function isRHExtensionActive(): boolean {
const rh = vscode.extensions.getExtension(RH_EXTENSION_ID);
return rh ? true : false;
}

export async function waitForNblsCommandToBeAvailable() {
await nblsClient;
}
78 changes: 78 additions & 0 deletions java/java.lsp.server/vscode/src/jdk/validation/javaUtil.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* 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.
*/

import * as fs from 'fs';
import * as path from 'path';
import * as cp from 'child_process';

const JAVA_VERSION_REGEX = /version\s+"(\S+)"/;

function findExecutable(program: string, home: string): string | undefined {
if (home) {
let executablePath = path.join(home, 'bin', program);
if (process.platform === 'win32') {
if (fs.existsSync(executablePath + '.cmd')) {
return executablePath + '.cmd';
}
if (fs.existsSync(executablePath + '.exe')) {
return executablePath + '.exe';
}
} else if (fs.existsSync(executablePath)) {
return executablePath;
}
}
return undefined;
}

export function normalizeJavaVersion(version: string): string {
return version.startsWith("1.") ? version.substring(2) : version;
}

export async function getJavaVersion(homeFolder: string): Promise<string | undefined> {
return new Promise<string | undefined>(resolve => {
if (homeFolder && fs.existsSync(homeFolder)) {
const executable: string | undefined = findExecutable('java', homeFolder);
if (executable) {
cp.execFile(executable, ['-version'], { encoding: 'utf8' }, (_error, _stdout, stderr) => {
if (stderr) {
let javaVersion: string | undefined;
stderr.split('\n').forEach((line: string) => {
const javaInfo: string[] | null = line.match(JAVA_VERSION_REGEX);
if (javaInfo && javaInfo.length > 1) {
javaVersion = javaInfo[1];
}
});
if (javaVersion) {
let majorVersion = normalizeJavaVersion(javaVersion);
let i = majorVersion.indexOf('.');
if (i > -1) {
majorVersion = majorVersion.slice(0, i);
}
resolve(majorVersion);
return;
}
}
resolve(undefined);
});
}
} else {
resolve(undefined);
}
});
}
Loading

0 comments on commit 8b31dac

Please sign in to comment.