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
5 changes: 4 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": [ "${workspaceRoot}/out/src/**/*.js" ],
"preLaunchTask": "npm: watch"
"preLaunchTask": "npm: watch",
"env": {
"DEBUG_VSCODE_JAVA":"true"
}
},
{
"name": "Extension Tests",
Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ Please also check the documentation of [Language Support for Java by Red Hat](ht
- `argfile` - Generate the classpath parameters to a temporary argument file, and launch the program with the command line 'java @argfile [args]'. This value only applies to Java 9 and higher.
- `auto` - Automatically detect the command line length and determine whether to shorten the command line via an appropriate approach.
- `stepFilters` - Skip specified classes or methods when stepping.
- `classNameFilters` - Skip the specified classes when stepping. Class names should be fully qualified. Wildcard is supported.
- `classNameFilters` - [**Deprecated** - replaced by `skipClasses`] Skip the specified classes when stepping. Class names should be fully qualified. Wildcard is supported.
- `skipClasses` - Skip the specified classes when stepping. You could use the built-in variables such as '$JDK' and '$Libraries' to skip a group of classes, or add a specific class name expression, e.g. java.*, *.Foo
- `skipSynthetics` - Skip synthetic methods when stepping.
- `skipStaticInitializers` - Skip static initializer methods when stepping.
- `skipConstructors` - Skip constructor methods when stepping.
Expand All @@ -85,7 +86,8 @@ Please also check the documentation of [Language Support for Java by Red Hat](ht
- `sourcePaths` - The extra source directories of the program. The debugger looks for source code from project settings by default. This option allows the debugger to look for source code in extra directories.
- `projectName` - The preferred project in which the debugger searches for classes. There could be duplicated class names in different projects. It is required when the workspace has multiple java projects, otherwise the expression evaluation and conditional breakpoint may not work.
- `stepFilters` - Skip specified classes or methods when stepping.
- `classNameFilters` - Skip the specified classes when stepping. Class names should be fully qualified. Wildcard is supported.
- `classNameFilters` - [**Deprecated** - replaced by `skipClasses`] Skip the specified classes when stepping. Class names should be fully qualified. Wildcard is supported.
- `skipClasses` - Skip the specified classes when stepping. You could use the built-in variables such as '$JDK' and '$Libraries' to skip a group of classes, or add a specific class name expression, e.g. java.*, *.Foo
- `skipSynthetics` - Skip synthetic methods when stepping.
- `skipStaticInitializers` - Skip static initializer methods when stepping.
- `skipConstructors` - Skip constructor methods when stepping.
Expand All @@ -110,6 +112,11 @@ Please also check the documentation of [Language Support for Java by Red Hat](ht
- `internalConsole` - VS Code debug console (input stream not supported).
- `integratedTerminal` - VS Code integrated terminal.
- `externalTerminal` - External terminal that can be configured in user settings.
- `java.debug.settings.exceptionBreakpoint.skipClasses`: Skip the specified classes when breaking on exception. You could use the built-in variables such as '$JDK' and '$Libraries' to skip a group of classes, or add a specific class name expression, e.g. java.*, *.Foo
- `java.debug.settings.stepping.skipClasses`: Skip the specified classes when stepping. You could use the built-in variables such as '$JDK' and '$Libraries' to skip a group of classes, or add a specific class name expression, e.g. java.*, *.Foo
- `java.debug.settings.stepping.skipSynthetics`: Skip synthetic methods when stepping.
- `java.debug.settings.stepping.skipStaticInitializers`: Skip static initializer methods when stepping.
- `java.debug.settings.stepping.skipConstructors`: Skip constructor methods when stepping.

Pro Tip: The documentation [Configuration.md](https://github.com/microsoft/vscode-java-debug/blob/master/Configuration.md) provides lots of samples to demonstrate how to use these debug configurations, recommend to take a look.

Expand Down
147 changes: 113 additions & 34 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -287,32 +287,40 @@
"type": "object",
"description": "%java.debugger.launch.stepFilters.description%",
"default": {
"classNameFilters": [
"java.*",
"javax.*",
"com.sun.*",
"sun.*",
"sunw.*",
"org.omg.*"
"skipClasses": [
"$JDK",
"junit.*"
],
"skipSynthetics": false,
"skipStaticInitializers": false,
"skipConstructors": false
},
"properties": {
"classNameFilters": {
"skipClasses": {
"type": "array",
"description": "%java.debugger.launch.classNameFilters.description%",
"item": {
"type": "string"
"description": "%java.debugger.launch.skipClasses.description%",
"items": {
"anyOf": [
{
"enum": [
"$JDK",
"$Libraries",
"java.lang.ClassLoader",
""
],
"enumDescriptions": [
"%java.debugger.launch.skipClasses.skipJDK%",
"%java.debugger.launch.skipClasses.skipLibraries%",
"%java.debugger.launch.skipClasses.skipClassLoader%",
"%java.debugger.launch.skipClasses.skipClassPattern%"
]
},
"string"
]
},
"default": [
"java.*",
"javax.*",
"com.sun.*",
"sun.*",
"sunw.*",
"org.omg.*"
"$JDK",
"junit.*"
]
},
"skipSynthetics": {
Expand Down Expand Up @@ -382,32 +390,40 @@
"type": "object",
"description": "%java.debugger.launch.stepFilters.description%",
"default": {
"classNameFilters": [
"java.*",
"javax.*",
"com.sun.*",
"sun.*",
"sunw.*",
"org.omg.*"
"skipClasses": [
"$JDK",
"junit.*"
],
"skipSynthetics": false,
"skipStaticInitializers": false,
"skipConstructors": false
},
"properties": {
"classNameFilters": {
"skipClasses": {
"type": "array",
"description": "%java.debugger.launch.classNameFilters.description%",
"item": {
"type": "string"
"description": "%java.debugger.launch.skipClasses.description%",
"items": {
"anyOf": [
{
"enum": [
"$JDK",
"$Libraries",
"java.lang.ClassLoader",
""
],
"enumDescriptions": [
"%java.debugger.launch.skipClasses.skipJDK%",
"%java.debugger.launch.skipClasses.skipLibraries%",
"%java.debugger.launch.skipClasses.skipClassLoader%",
"%java.debugger.launch.skipClasses.skipClassPattern%"
]
},
"string"
]
},
"default": [
"java.*",
"javax.*",
"com.sun.*",
"sun.*",
"sunw.*",
"org.omg.*"
"$JDK",
"junit.*"
]
},
"skipSynthetics": {
Expand Down Expand Up @@ -592,6 +608,69 @@
],
"description": "%java.debugger.configuration.console%",
"default": "integratedTerminal"
},
"java.debug.settings.exceptionBreakpoint.skipClasses": {
"type": "array",
"description": "%java.debugger.configuration.exceptionBreakpoint.skipClasses%",
"items": {
"anyOf": [
{
"enum": [
"$JDK",
"$Libraries",
"java.lang.ClassLoader",
""
],
"enumDescriptions": [
"%java.debugger.launch.skipClasses.skipJDK%",
"%java.debugger.launch.skipClasses.skipLibraries%",
"%java.debugger.launch.skipClasses.skipClassLoader%",
"%java.debugger.launch.skipClasses.skipClassPattern%"
]
},
"string"
]
},
"default": []
},
"java.debug.settings.stepping.skipClasses": {
"type": "array",
"description": "%java.debugger.launch.skipClasses.description%",
"items": {
"anyOf": [
{
"enum": [
"$JDK",
"$Libraries",
"java.lang.ClassLoader",
""
],
"enumDescriptions": [
"%java.debugger.launch.skipClasses.skipJDK%",
"%java.debugger.launch.skipClasses.skipLibraries%",
"%java.debugger.launch.skipClasses.skipClassLoader%",
"%java.debugger.launch.skipClasses.skipClassPattern%"
]
},
"string"
]
},
"default": []
},
"java.debug.settings.stepping.skipSynthetics": {
"type": "boolean",
"description": "%java.debugger.launch.skipSynthetics.description%",
"default": false
},
"java.debug.settings.stepping.skipStaticInitializers": {
"type": "boolean",
"description": "%java.debugger.launch.skipStaticInitializers.description%",
"default": false
},
"java.debug.settings.stepping.skipConstructors": {
"type": "boolean",
"description": "%java.debugger.launch.skipConstructors.description%",
"default": false
}
}
}
Expand Down
9 changes: 7 additions & 2 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
"java.debugger.launch.shortenCommandLine.argfile": "Generate the classpath parameters to a temporary argument file, and launch the program with the command line 'java @argfile [args]'. This value only applies to Java 9 and higher.",
"java.debugger.launch.shortenCommandLine.description": "When the project has long classpath or big VM arguments, the command line to launch the program may exceed the maximum command line string limitation allowed by the OS. This configuration item provides multiple approaches to shorten the command line.",
"java.debugger.launch.stepFilters.description": "Skip specified classes or methods when stepping.",
"java.debugger.launch.classNameFilters.description": "Skip the specified classes when stepping. Class names should be fully qualified. Wildcard is supported.",
"java.debugger.launch.skipClasses.description": "Skip the specified classes when stepping. You could use the built-in variables such as '$JDK' and '$Libraries' to skip a group of classes, or add a specific class name expression, e.g. java.*, *.Foo",
"java.debugger.launch.skipClasses.skipJDK": "Skip the JDK classes from the default system bootstrap classpath, such as rt.jar, jrt-fs.jar.",
"java.debugger.launch.skipClasses.skipLibraries": "Skip the classes from application libraries, such as Maven, Gradle dependencies.",
"java.debugger.launch.skipClasses.skipClassLoader": "Skip the class loaders.",
"java.debugger.launch.skipClasses.skipClassPattern": "Skip the specified classes. Class names should be fully qualified. Wildcard is supported, e.g. java.*, *.Foo",
"java.debugger.launch.skipSynthetics.description": "Skip synthetic methods when stepping.",
"java.debugger.launch.skipStaticInitializers.description": "Skip static initializer methods when stepping.",
"java.debugger.launch.skipConstructors.description": "Skip constructor methods when stepping.",
Expand Down Expand Up @@ -49,5 +53,6 @@
"java.debugger.configuration.hotCodeReplace.description": "Reload the changed Java classes during debugging. Make sure 'java.autobuild.enabled' is not disabled.",
"java.debugger.configuration.enableRunDebugCodeLens.description": "Enable the run and debug code lens providers over main methods.",
"java.debugger.configuration.forceBuildBeforeLaunch": "Force building the workspace before launching java program.",
"java.debugger.configuration.console": "The specified console to launch Java program. If you want to customize the console for a specific debug session, please modify the 'console' config in launch.json."
"java.debugger.configuration.console": "The specified console to launch Java program. If you want to customize the console for a specific debug session, please modify the 'console' config in launch.json.",
"java.debugger.configuration.exceptionBreakpoint.skipClasses": "Skip the specified classes when breaking on exception. You could use the built-in variables such as '$JDK' and '$Libraries' to skip a group of classes, or add a specific class name expression, e.g. java.*, *.Foo"
}
9 changes: 7 additions & 2 deletions package.nls.zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
"java.debugger.launch.shortenCommandLine.argfile": "将类路径参数生成到临时 argument 文件中, 并使用命令行 'java @argfile [args]' 启动应用程序。该值仅适用于 Java 9 及以上版本。",
"java.debugger.launch.shortenCommandLine.description": "当项目具有较长的类路径或较大的VM参数时,启动程序的命令行可能会超出OS允许的最大命令行字符串限制。此配置项提供了多种缩短命令行的方法。",
"java.debugger.launch.stepFilters.description": "Step时跳过指定的类或方法。",
"java.debugger.launch.classNameFilters.description": "Step时跳过指定的类。仅支持全名,以及通配符。",
"java.debugger.launch.skipClasses.description": "Step时跳过指定的类。你可以使用内置变量,如'$JDK'和'$Libraries'来跳过一组类,或者添加一个特定的类名表达式,如java.*,*.Foo。",
"java.debugger.launch.skipClasses.skipJDK": "跳过系统默认的启动路径中的JDK类,如rt.jar、jrt-fs.jar。",
"java.debugger.launch.skipClasses.skipLibraries": "跳过应用库中的类,如Maven、Gradle依赖。",
"java.debugger.launch.skipClasses.skipClassLoader": "跳过类加载器。",
"java.debugger.launch.skipClasses.skipClassPattern": "跳过指定的类。仅支持全名,以及通配符,如java.*,*.Foo。",
"java.debugger.launch.skipSynthetics.description": "Step时跳过合成方法。",
"java.debugger.launch.skipStaticInitializers.description": "Step时跳过静态初始化方法。",
"java.debugger.launch.skipConstructors.description": "Step时跳过构造函数。",
Expand Down Expand Up @@ -48,5 +52,6 @@
"java.debugger.configuration.hotCodeReplace.description": "在调试期间重新加载已更改的Java类。确保未禁用'java.autobuild.enabled'。",
"java.debugger.configuration.enableRunDebugCodeLens.description": "在main方法上启用CodeLens标记。",
"java.debugger.configuration.forceBuildBeforeLaunch": "在启动java程序之前强制编译整个工作空间。",
"java.debugger.configuration.console": "指定的控制台用于启动Java程序。如果要为特定的调试会话自定义控制台,请修改launch.json中的“console”配置。"
"java.debugger.configuration.console": "指定的控制台用于启动Java程序。如果要为特定的调试会话自定义控制台,请修改launch.json中的“console”配置。",
"java.debugger.configuration.exceptionBreakpoint.skipClasses": "当发生异常时,跳过指定的类。你可以使用内置变量,如'$JDK'和'$Libraries'来跳过一组类,或者添加一个特定的类名表达式,如java.*,*.Foo。"
}
49 changes: 49 additions & 0 deletions src/classFilter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

import * as vscode from "vscode";
import { resolveClassFilters } from "./languageServerPlugin";

export async function populateStepFilters(config: vscode.DebugConfiguration) {
if (!config.stepFilters) {
return;
}

const skipClasses = await substituteFilterVariables(config.stepFilters.skipClasses);
// Migrate classNameFilters to skipClasses.
if (Array.isArray(config.stepFilters.classNameFilters)) {
mergeResult(config.stepFilters.classNameFilters, skipClasses);
}
config.stepFilters.classNameFilters = undefined;
config.stepFilters.skipClasses = skipClasses;
}

export async function substituteFilterVariables(skipClasses: string[]): Promise<any> {
if (!skipClasses) {
return [];
}

try {
// Preprocess skipClasses configurations.
if (Array.isArray(skipClasses)) {
const hasReservedName = skipClasses.some((filter) => filter === "$JDK" || filter === "$Libraries");
return hasReservedName ? await resolveClassFilters(skipClasses) : skipClasses;
} else {
// tslint:disable-next-line:no-console
console.error("Invalid type for skipClasses config:" + skipClasses);
}
} catch (e) {
// tslint:disable-next-line:no-console
console.error(e);
}

return [];
}

function mergeResult(newItems: any[], result: string[]) {
newItems.forEach((item) => {
if (result.indexOf(item) < 0) {
result.push(String(item));
}
});
}
2 changes: 2 additions & 0 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export const JAVA_RESOLVE_JAVAEXECUTABLE = "vscode.java.resolveJavaExecutable";

export const JAVA_FETCH_PLATFORM_SETTINGS = "vscode.java.fetchPlatformSettings";

export const JAVA_RESOLVE_CLASSFILTERS = "vscode.java.resolveClassFilters";

export function executeJavaLanguageServerCommand(...rest) {
return executeJavaExtensionCommand(JAVA_EXECUTE_WORKSPACE_COMMAND, ...rest);
}
Expand Down
Loading