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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ The following settings are supported:
* `java.settings.url` : Specifies the url or file path to the workspace Java settings. See [Setting Global Preferences](https://github.com/redhat-developer/vscode-java/wiki/Settings-Global-Preferences)
* `java.symbols.includeSourceMethodDeclarations` : Include method declarations from source files in symbol search. Defaults to `false`.

New in 1.1.0:
* `java.quickfix.showAt"` : Show quickfixes at the problem or line level.


Semantic Highlighting
===============
[Semantic Highlighting](https://github.com/redhat-developer/vscode-java/wiki/Semantic-Highlighting) fixes numerous syntax highlighting issues with the default Java Textmate grammar. However, you might experience a few minor issues, particularly a delay when it kicks in, as it needs to be computed by the Java Language server, when opening a new file or when typing. Semantic highlighting can be disabled for all languages using the `editor.semanticHighlighting.enabled` setting, or for Java only using [language-specific editor settings](https://code.visualstudio.com/docs/getstarted/settings#_languagespecific-editor-settings).
Expand Down
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,16 @@
"markdownDescription": "Include method declarations from source files in symbol search.",
"default": false,
"scope": "window"
},
"java.quickfix.showAt": {
"type": "string",
"enum": [
"line",
"problem"
],
"default": "line",
"description": "Show quickfixes at the problem or line level.",
"scope": "window"
}
}
},
Expand Down
53 changes: 51 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import * as path from 'path';
import * as os from 'os';
import * as fs from 'fs';
import * as fse from 'fs-extra';
import { workspace, extensions, ExtensionContext, window, commands, ViewColumn, Uri, languages, IndentAction, InputBoxOptions, EventEmitter, OutputChannel, TextDocument, RelativePattern, ConfigurationTarget, WorkspaceConfiguration, env, UIKind } from 'vscode';
import { ExecuteCommandParams, ExecuteCommandRequest, LanguageClientOptions, RevealOutputChannelOn, ErrorHandler, Message, ErrorAction, CloseAction, DidChangeConfigurationNotification, CancellationToken } from 'vscode-languageclient';
import { workspace, extensions, ExtensionContext, window, commands, ViewColumn, Uri, languages, IndentAction, InputBoxOptions, EventEmitter, OutputChannel, TextDocument, RelativePattern, ConfigurationTarget, WorkspaceConfiguration, env, UIKind, Selection, CodeActionContext, Diagnostic } from 'vscode';
import { ExecuteCommandParams, ExecuteCommandRequest, LanguageClientOptions, RevealOutputChannelOn, ErrorHandler, Message, ErrorAction, CloseAction, DidChangeConfigurationNotification, CancellationToken, CodeActionRequest, CodeActionParams, Command } from 'vscode-languageclient';
import { LanguageClient } from 'vscode-languageclient/node';
import { collectJavaExtensions, isContributedPartUpdated } from './plugin';
import { prepareExecutable } from './javaServerStarter';
Expand Down Expand Up @@ -205,6 +205,55 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
}
});
}
},
// https://github.com/redhat-developer/vscode-java/issues/2130
// include all diagnostics for the current line in the CodeActionContext params for the performance reason
provideCodeActions: (document, range, context, token, next) => {
const client: any = standardClient.getClient();
const params: CodeActionParams = {
textDocument: client.code2ProtocolConverter.asTextDocumentIdentifier(document),
range: client.code2ProtocolConverter.asRange(range),
context: client.code2ProtocolConverter.asCodeActionContext(context)
};
const showAt = getJavaConfiguration().get<string>("quickfix.showAt");
if (showAt === 'line' && range.start.line === range.end.line && range.start.character === range.end.character) {
const textLine = document.lineAt(params.range.start.line);
if (textLine !== null) {
const diagnostics = client.diagnostics.get(document.uri);
const allDiagnostics: Diagnostic[] = [];
for (const diagnostic of diagnostics) {
if (textLine.range.intersection(diagnostic.range)) {
const newLen = allDiagnostics.push(diagnostic);
if (newLen > 1000) {
break;
}
}
}
const codeActionContext: CodeActionContext = {
diagnostics: allDiagnostics,
only: context.only,
};
params.context = client.code2ProtocolConverter.asCodeActionContext(codeActionContext);
}
}
return client.sendRequest(CodeActionRequest.type, params, token).then((values) => {
if (values === null) {
return undefined;
}
const result = [];
for (const item of values) {
if (Command.is(item)) {
result.push(client.protocol2CodeConverter.asCommand(item));
}
else {
result.push(client.protocol2CodeConverter.asCodeAction(item));
}
}
return result;
}, (error) => {
client.logFailedRequest(CodeActionRequest.type, error);
return Promise.resolve([]);
});
}
},
revealOutputChannelOn: RevealOutputChannelOn.Never,
Expand Down