Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 16 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,7 @@
"test": "npm run compile && node ./out/test/index.js"
},
"devDependencies": {
"@types/glob": "^7.1.3",
"@types/lodash": "^4.14.137",
"@types/mocha": "^5.2.7",
"@types/node": "^8.10.51",
Expand Down
2 changes: 1 addition & 1 deletion src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function checkErrorsReportedByJavaExtension(): boolean {
}

async function showFixSuggestions(operationId: string) {
let buildFiles = [];
let buildFiles: string[] = [];
try {
buildFiles = await lsPlugin.resolveBuildFiles();
} catch (error) {
Expand Down
4 changes: 2 additions & 2 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ export const JAVA_RESOLVE_CLASSFILTERS = "vscode.java.resolveClassFilters";

export const JAVA_RESOLVE_SOURCE_URI = "vscode.java.resolveSourceUri";

export function executeJavaLanguageServerCommand(...rest) {
export function executeJavaLanguageServerCommand(...rest: any[]) {
return executeJavaExtensionCommand(JAVA_EXECUTE_WORKSPACE_COMMAND, ...rest);
}

export async function executeJavaExtensionCommand(commandName: string, ...rest) {
export async function executeJavaExtensionCommand(commandName: string, ...rest: any[]) {
// TODO: need to handle error and trace telemetry
const javaExtension = utility.getJavaExtension();
if (!javaExtension) {
Expand Down
29 changes: 15 additions & 14 deletions src/configurationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import * as fs from "fs";
import * as _ from "lodash";
import * as os from "os";
import * as path from "path";
import { debug } from "util";
import * as vscode from "vscode";

import { instrumentOperation, sendInfo } from "vscode-extension-telemetry-wrapper";
Expand All @@ -19,7 +18,7 @@ import { mainClassPicker } from "./mainClassPicker";
import { resolveJavaProcess } from "./processPicker";
import * as utility from "./utility";

const platformNameMappings = {
const platformNameMappings: {[key: string]: string} = {
win32: "windows",
linux: "linux",
darwin: "osx",
Expand All @@ -38,20 +37,22 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
this.isUserSettingsDirty = true;
}
}
return undefined;
});
}

// Returns an initial debug configurations based on contextual information.
public provideDebugConfigurations(folder: vscode.WorkspaceFolder | undefined, token?: vscode.CancellationToken):
public provideDebugConfigurations(folder: vscode.WorkspaceFolder | undefined, _token?: vscode.CancellationToken):
vscode.ProviderResult<vscode.DebugConfiguration[]> {
const provideDebugConfigurationsHandler = instrumentOperation("provideDebugConfigurations", (operationId: string) => {
const provideDebugConfigurationsHandler = instrumentOperation("provideDebugConfigurations", (_operationId: string) => {
return <Thenable<vscode.DebugConfiguration[]>>this.provideDebugConfigurationsAsync(folder);
});
return provideDebugConfigurationsHandler();
}

// Try to add all missing attributes to the debug configuration being launched.
public resolveDebugConfiguration(folder: vscode.WorkspaceFolder | undefined, config: vscode.DebugConfiguration, token?: vscode.CancellationToken):
public resolveDebugConfiguration(_folder: vscode.WorkspaceFolder | undefined,
config: vscode.DebugConfiguration, _token?: vscode.CancellationToken):
vscode.ProviderResult<vscode.DebugConfiguration> {
// If no debug configuration is provided, then generate one in memory.
if (this.isEmptyConfig(config)) {
Expand All @@ -67,8 +68,8 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
public resolveDebugConfigurationWithSubstitutedVariables(
folder: vscode.WorkspaceFolder | undefined,
config: vscode.DebugConfiguration,
token?: vscode.CancellationToken): vscode.ProviderResult<vscode.DebugConfiguration> {
const resolveDebugConfigurationHandler = instrumentOperation("resolveDebugConfiguration", (operationId: string) => {
_token?: vscode.CancellationToken): vscode.ProviderResult<vscode.DebugConfiguration> {
const resolveDebugConfigurationHandler = instrumentOperation("resolveDebugConfiguration", (_operationId: string) => {
try {
// See https://github.com/microsoft/vscode-java-debug/issues/778
// Merge the platform specific properties to the global config to simplify the subsequent resolving logic.
Expand All @@ -85,9 +86,9 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
return resolveDebugConfigurationHandler();
}

private provideDebugConfigurationsAsync(folder: vscode.WorkspaceFolder | undefined, token?: vscode.CancellationToken) {
private provideDebugConfigurationsAsync(folder: vscode.WorkspaceFolder | undefined, _token?: vscode.CancellationToken) {
return vscode.window.withProgress({ location: vscode.ProgressLocation.Window }, (p) => {
return new Promise(async (resolve, reject) => {
return new Promise(async (resolve, _reject) => {
p.report({ message: "Auto generating configuration..." });
const defaultLaunchConfig = {
type: "java",
Expand All @@ -104,7 +105,7 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
}

const mainClasses = await lsPlugin.resolveMainClass(folder ? folder.uri : undefined);
let cache;
let cache: {[key: string]: any};
cache = {};
const launchConfigs = mainClasses.map((item) => {
return {
Expand All @@ -126,7 +127,7 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
});
}

private mergePlatformProperties(folder: vscode.WorkspaceFolder, config: vscode.DebugConfiguration) {
private mergePlatformProperties(_folder: vscode.WorkspaceFolder, config: vscode.DebugConfiguration) {
if (config && platformName && config[platformName]) {
try {
for (const key of Object.keys(config[platformName])) {
Expand All @@ -139,7 +140,7 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
}
}

private constructLaunchConfigName(mainClass: string, projectName: string, cache: {}) {
private constructLaunchConfigName(mainClass: string, projectName: string, cache: {[key: string]: any}) {
const prefix = "Debug (Launch)-";
let name = prefix + mainClass.substr(mainClass.lastIndexOf(".") + 1);
if (projectName !== undefined) {
Expand Down Expand Up @@ -199,7 +200,7 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
const mainClassOption = await this.resolveLaunchConfig(folder ? folder.uri : undefined, config);
if (!mainClassOption || !mainClassOption.mainClass) { // Exit silently if the user cancels the prompt fix by ESC.
// Exit the debug session.
return;
return undefined;
}

config.mainClass = mainClassOption.mainClass;
Expand Down Expand Up @@ -406,7 +407,7 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
return selectedFix;
}
// return undefined if the user clicks "Learn More".
return;
return undefined;
}

throw new utility.UserError({
Expand Down
6 changes: 3 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { initializeCodeLensProvider, startDebugging } from "./debugCodeLensProvi
import { handleHotCodeReplaceCustomEvent, initializeHotCodeReplace, NO_BUTTON, YES_BUTTON } from "./hotCodeReplace";
import { JavaDebugAdapterDescriptorFactory } from "./javaDebugAdapterDescriptorFactory";
import { logJavaException, logJavaInfo } from "./javaLogger";
import { IMainClassOption, IMainMethod, resolveMainClass, resolveMainMethod } from "./languageServerPlugin";
import { IMainClassOption, IMainMethod, resolveMainMethod } from "./languageServerPlugin";
import { logger, Type } from "./logger";
import { mainClassPicker } from "./mainClassPicker";
import { pickJavaProcess } from "./processPicker";
Expand All @@ -29,7 +29,7 @@ export async function activate(context: vscode.ExtensionContext) {
await instrumentOperation("activation", initializeExtension)(context);
}

function initializeExtension(operationId: string, context: vscode.ExtensionContext) {
function initializeExtension(_operationId: string, context: vscode.ExtensionContext) {
// Deprecated
logger.initialize(context, true);

Expand Down Expand Up @@ -123,7 +123,7 @@ function registerDebugEventListener(context: vscode.ExtensionContext) {
}));
}

function handleUserNotification(customEvent) {
function handleUserNotification(customEvent: vscode.DebugSessionCustomEvent) {
if (customEvent.body.notificationType === "ERROR") {
utility.showErrorMessageWithTroubleshooting({
message: customEvent.body.message,
Expand Down
3 changes: 2 additions & 1 deletion src/hotCodeReplace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function initializeHotCodeReplace(context: vscode.ExtensionContext) {
}));
}

export function handleHotCodeReplaceCustomEvent(hcrEvent) {
export function handleHotCodeReplaceCustomEvent(hcrEvent: vscode.DebugSessionCustomEvent) {
if (hcrEvent.body.changeType === HcrChangeType.BUILD_COMPLETE) {
if (getHotReloadFlag() === "auto") {
return vscode.window.withProgress({ location: vscode.ProgressLocation.Window }, (progress) => {
Expand All @@ -62,6 +62,7 @@ export function handleHotCodeReplaceCustomEvent(hcrEvent) {
});
}
}
return undefined;
}

function getHotReloadFlag(): string {
Expand Down
6 changes: 4 additions & 2 deletions src/hoverProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ class DebugHoverProvider implements Disposable {
}

class InternalDebugHoverProvider implements HoverProvider {
public provideHover(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<Hover> {
public provideHover(document: TextDocument, position: Position, _token: CancellationToken): ProviderResult<Hover> {
const range = document.getWordRangeAtPosition(position, /\w+/);
if (!range || document.getText(range) !== "main") {
return;
return undefined;
}

const line = document.lineAt(position);
Expand All @@ -69,6 +69,8 @@ class InternalDebugHoverProvider implements HoverProvider {
contributed.isTrusted = true;
return new Hover(contributed);
}

return undefined;
}

private isMainMethod(line: string): boolean {
Expand Down
5 changes: 3 additions & 2 deletions src/javaDebugAdapterDescriptorFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { Type } from "./logger";
import { convertErrorToMessage, showErrorMessageWithTroubleshooting } from "./utility";

export class JavaDebugAdapterDescriptorFactory implements DebugAdapterDescriptorFactory {
public async createDebugAdapterDescriptor(session: DebugSession, executable: DebugAdapterExecutable): Promise<DebugAdapterDescriptor> {
let error;
public async createDebugAdapterDescriptor(_session: DebugSession, _executable: DebugAdapterExecutable): Promise<DebugAdapterDescriptor> {
let error: Error;
try {
const debugServerPort = <number> (await startDebugSession());
if (debugServerPort) {
Expand All @@ -28,5 +28,6 @@ export class JavaDebugAdapterDescriptorFactory implements DebugAdapterDescriptor
message: "Failed to start debug server.",
};
showErrorMessageWithTroubleshooting(message);
return undefined;
}
}
2 changes: 1 addition & 1 deletion src/javaLogger.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

import { sendError, sendInfo, sendOperationError } from "vscode-extension-telemetry-wrapper";
import { sendInfo, sendOperationError } from "vscode-extension-telemetry-wrapper";

export function logJavaException(errorProperties: any): void {
/**
Expand Down
4 changes: 2 additions & 2 deletions src/languageServerPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function startDebugSession() {
return commands.executeJavaLanguageServerCommand(commands.JAVA_START_DEBUGSESSION);
}

export function resolveClasspath(mainClass, projectName) {
export function resolveClasspath(mainClass: string, projectName: string) {
return commands.executeJavaLanguageServerCommand(commands.JAVA_RESOLVE_CLASSPATH, mainClass, projectName);
}

Expand Down Expand Up @@ -101,7 +101,7 @@ export async function isOnClasspath(uri: string): Promise<boolean> {
}
}

export function resolveJavaExecutable(mainClass, projectName) {
export function resolveJavaExecutable(mainClass: string, projectName: string) {
return commands.executeJavaLanguageServerCommand(commands.JAVA_RESOLVE_JAVAEXECUTABLE, mainClass, projectName);
}

Expand Down
4 changes: 2 additions & 2 deletions src/launchCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ export async function addMoreHelpfulVMArgs(config: vscode.DebugConfiguration) {
}

function checkJavaVersion(javaExec: string): Promise<number> {
return new Promise((resolve, reject) => {
cp.execFile(javaExec, ["-version"], {}, (error, stdout, stderr) => {
return new Promise((resolve, _reject) => {
cp.execFile(javaExec, ["-version"], {}, (_error, _stdout, stderr) => {
const javaVersion = parseMajorVersion(stderr);
resolve(javaVersion);
});
Expand Down
6 changes: 4 additions & 2 deletions src/mainClassPicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class MainClassPicker {
}

if (!options || !options.length) {
return;
return undefined;
} else if (autoPick && options.length === 1) {
return options[0];
}
Expand All @@ -53,6 +53,7 @@ class MainClassPicker {
if (selected) {
return selected.data;
}
return undefined;
}

// tslint:disable-next-line
Expand All @@ -77,7 +78,7 @@ class MainClassPicker {
}

if (!options || !options.length) {
return;
return undefined;
} else if (autoPick && options.length === 1) {
return options[0];
}
Expand Down Expand Up @@ -146,6 +147,7 @@ class MainClassPicker {
this.updateMRUTimestamp(selected.data);
return selected.data;
}
return undefined;
}

private getMRUTimestamp(mainClassOption: IMainClassOption): number {
Expand Down
8 changes: 6 additions & 2 deletions src/processPicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT license.

import * as path from "path";
import { DebugConfiguration, window } from "vscode";
import { window } from "vscode";
import { getProcesses, getProcessTree } from "./processTree";

const JAVA_PATTERN = /(?:java|javaw|j9|j9w)$/i;
Expand Down Expand Up @@ -42,12 +42,14 @@ function convertToJavaProcess(pid: number, command: string, args: string): IJava
};
}
}

return undefined;
}

export async function pickJavaProcess(): Promise<IJavaProcess> {
const javaProcesses: IJavaProcess[] = [];
try {
await getProcesses((pid: number, ppid: number, command: string, args: string, date: number) => {
await getProcesses((pid: number, _ppid: number, command: string, args: string, _date: number) => {
const javaProcess = convertToJavaProcess(pid, command, args);
if (javaProcess) {
javaProcesses.push(javaProcess);
Expand Down Expand Up @@ -79,6 +81,8 @@ export async function pickJavaProcess(): Promise<IJavaProcess> {
if (pick) {
return pick.process;
}

return undefined;
}

export async function resolveJavaProcess(pid: number): Promise<IJavaProcess | undefined> {
Expand Down
4 changes: 3 additions & 1 deletion src/terminalLinkProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class JavaTerminalLinkProvder implements TerminalLinkProvider<IJavaTermin
* @param token A cancellation token.
* @return A list of terminal links for the given line.
*/
public provideTerminalLinks(context: TerminalLinkContext, token: CancellationToken): ProviderResult<IJavaTerminalLink[]> {
public provideTerminalLinks(context: TerminalLinkContext, _token: CancellationToken): ProviderResult<IJavaTerminalLink[]> {
if (context.terminal.name !== "Java Debug Console" && context.terminal.name !== "Java Process Console") {
return [];
}
Expand All @@ -32,6 +32,8 @@ export class JavaTerminalLinkProvder implements TerminalLinkProvider<IJavaTermin
lineNumber: sourceLineNumber,
}];
}

return [];
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/utility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class UserError extends Error {
}

export class JavaExtensionNotEnabledError extends Error {
constructor(message) {
constructor(message: string) {
super(message);
setUserError(this);
}
Expand Down Expand Up @@ -95,7 +95,7 @@ export async function showErrorMessageWithTroubleshooting(message: ITroubleshoot
function handleTroubleshooting(choice: string, message: string, anchor: string): string | undefined {
if (choice === LEARN_MORE) {
openTroubleshootingPage(message, anchor);
return;
return undefined;
}

return choice;
Expand Down
Loading