Refine the code. (#99)
This commit is contained in:
parent
e08d0177c7
commit
6e258f754c
|
@ -1,6 +1,8 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
import * as vscode from "vscode";
|
||||
|
||||
export const VSCODE_STARTDEBUG = "vscode.startDebug";
|
||||
|
||||
export const VSCODE_ADD_DEBUGCONFIGURATION = "debug.addConfiguration";
|
||||
|
@ -16,3 +18,8 @@ export const JAVA_EXECUTE_WORKSPACE_COMMAND = "java.execute.workspaceCommand";
|
|||
export const JAVA_FETCH_USAGE_DATA = "vscode.java.fetchUsageData";
|
||||
|
||||
export const JAVA_CONFIG_LOG_LEVEL = "vscode.java.configLogLevel";
|
||||
|
||||
export function executeJavaLanguageServerCommand(...rest) {
|
||||
// TODO: need to handle error and trace telemetry
|
||||
return vscode.commands.executeCommand(JAVA_EXECUTE_WORKSPACE_COMMAND, ...rest);
|
||||
}
|
||||
|
|
|
@ -114,33 +114,28 @@ export class JavaDebugConfigurationProvider implements vscode.DebugConfiguration
|
|||
}
|
||||
}
|
||||
|
||||
export function executeJavaLanguageServerCommand(...rest) {
|
||||
// TODO: need to handle error and trace telemetry
|
||||
return vscode.commands.executeCommand(commands.JAVA_EXECUTE_WORKSPACE_COMMAND, ...rest);
|
||||
}
|
||||
|
||||
function startDebugSession() {
|
||||
return executeJavaLanguageServerCommand(commands.JAVA_START_DEBUGSESSION);
|
||||
return commands.executeJavaLanguageServerCommand(commands.JAVA_START_DEBUGSESSION);
|
||||
}
|
||||
|
||||
function resolveClasspath(mainClass, projectName) {
|
||||
return executeJavaLanguageServerCommand(commands.JAVA_RESOLVE_CLASSPATH, mainClass, projectName);
|
||||
return commands.executeJavaLanguageServerCommand(commands.JAVA_RESOLVE_CLASSPATH, mainClass, projectName);
|
||||
}
|
||||
|
||||
function configLogLevel(level) {
|
||||
return executeJavaLanguageServerCommand(commands.JAVA_CONFIG_LOG_LEVEL, convertLogLevel(level));
|
||||
return commands.executeJavaLanguageServerCommand(commands.JAVA_CONFIG_LOG_LEVEL, convertLogLevel(level));
|
||||
}
|
||||
|
||||
function convertLogLevel(commonLogLevel: string) {
|
||||
// convert common log level to java log level
|
||||
switch (commonLogLevel.toLowerCase()) {
|
||||
case "verbose" :
|
||||
switch (commonLogLevel.toLowerCase()) {
|
||||
case "verbose":
|
||||
return "FINE";
|
||||
case "warn" :
|
||||
case "warn":
|
||||
return "WARNING";
|
||||
case "error" :
|
||||
case "error":
|
||||
return "SEVERE";
|
||||
case "info" :
|
||||
case "info":
|
||||
return "INFO";
|
||||
default:
|
||||
return "FINE";
|
||||
|
|
|
@ -5,7 +5,7 @@ import * as path from "path";
|
|||
import * as vscode from "vscode";
|
||||
import TelemetryReporter from "vscode-extension-telemetry";
|
||||
import * as commands from "./commands";
|
||||
import { executeJavaLanguageServerCommand, JavaDebugConfigurationProvider } from "./configurationProvider";
|
||||
import { JavaDebugConfigurationProvider } from "./configurationProvider";
|
||||
|
||||
export function activate(context: vscode.ExtensionContext) {
|
||||
// The reporter will be initialized by the later telemetry handler.
|
||||
|
@ -52,5 +52,5 @@ export function deactivate() {
|
|||
}
|
||||
|
||||
function fetchUsageData() {
|
||||
return executeJavaLanguageServerCommand(commands.JAVA_FETCH_USAGE_DATA);
|
||||
return commands.executeJavaLanguageServerCommand(commands.JAVA_FETCH_USAGE_DATA);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue