Skip to content
Open
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
134 changes: 134 additions & 0 deletions language-support/java/language-configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,139 @@
"<",
">"
]
],
"autoCloseBefore": ";:.,=}])>` \n\t",
"folding": {
"markers": {
"start": "^\\s*//\\s*#?region\\b",
"end": "^\\s*//\\s*#?endregion\\b"
}
},
"wordPattern": {
"pattern": "(-?\\d*\\.\\d\\w*)|([^\\`\\~\\!\\@\\#\\%\\^\\&\\*\\(\\)\\-\\=\\+\\[\\{\\]\\}\\\\\\|\\;\\:\\'\\\"\\,\\.\\<\\>\\/\\?\\s]+)"
},
"indentationRules": {
"decreaseIndentPattern": {
"pattern": "^((?!.*?\\/\\*).*\\*/)?\\s*[\\)\\}\\]].*$"
},
"increaseIndentPattern": {
"pattern": "^((?!\\/\\/).)*(\\{[^}\"'`]*|\\([^)\"'`]*|\\[[^\\]\"'`]*)$"
},
"unIndentedLinePattern": {
"pattern": "^(\\t|[ ])*[ ]\\*[^/]*\\*/\\s*$|^(\\t|[ ])*[ ]\\*/\\s*$|^(\\t|[ ])*[ ]\\*([ ]([^\\*]|\\*(?!/))*)?$"
},
"indentNextLinePattern": {
"pattern": "^((.*=>\\s*)|((.*[^\\w]+|\\s*)((if|while|for)\\s*\\(.*\\)\\s*|else\\s*)))$"
}
},
"onEnterRules": [
{
"beforeText": {
"pattern": "^\\s*/\\*\\*(?!/)([^\\*]|\\*(?!/))*$"
},
"afterText": {
"pattern": "^\\s*\\*/$"
},
"action": {
"indent": "indentOutdent",
"appendText": " * "
}
},
{
"beforeText": {
"pattern": "^\\s*/\\*\\*(?!/)([^\\*]|\\*(?!/))*$"
},
"action": {
"indent": "none",
"appendText": " * "
}
},
{
"beforeText": {
"pattern": "^(\\t|[ ])*[ ]\\*([ ]([^\\*]|\\*(?!/))*)?$"
},
"previousLineText": {
"pattern": "(?=^(\\s*(/\\*\\*|\\*)).*)(?=(?!(\\s*\\*/)))"
},
"action": {
"indent": "none",
"appendText": "* "
}
},
{
"beforeText": {
"pattern": "^(\\t|[ ])*[ ]\\*/\\s*$"
},
"action": {
"indent": "none",
"removeText": 1
}
},
{
"beforeText": {
"pattern": "^(\\t|[ ])*[ ]\\*[^/]*\\*/\\s*$"
},
"action": {
"indent": "none",
"removeText": 1
}
},
{
"beforeText": {
"pattern": "^\\s*(\\bcase\\s.+:|\\bdefault:)$"
},
"afterText": {
"pattern": "^(?!\\s*(\\bcase\\b|\\bdefault\\b))"
},
"action": {
"indent": "indent"
}
},
{
"previousLineText": "^\\s*(((else ?)?if|for|while)\\s*\\(.*\\)\\s*|else\\s*)$",
"beforeText": "^\\s+([^{i\\s]|i(?!f\\b))",
"action": {
"indent": "outdent"
}
},
{
"beforeText": "^.*\\([^\\)]*$",
"afterText": "^\\s*\\).*$",
"action": {
"indent": "indentOutdent",
"appendText": "\t"
}
},
{
"beforeText": "^.*\\{[^\\}]*$",
"afterText": "^\\s*\\}.*$",
"action": {
"indent": "indentOutdent",
"appendText": "\t"
}
},
{
"beforeText": "^.*\\[[^\\]]*$",
"afterText": "^\\s*\\].*$",
"action": {
"indent": "indentOutdent",
"appendText": "\t"
}
},
{
"beforeText": "(?<!\\\\|\\w:)\\/\\/\\s*\\S",
"afterText": "^(?!\\s*$).+",
"action": {
"indent": "none",
"appendText": "// "
}
},
{
"beforeText": "^\\s*\\/\\/\\/(.*)?$",
"action": {
"indent": "none",
"appendText": "/// "
}
}
]
}
50 changes: 1 addition & 49 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as path from 'path';
import * as semver from 'semver';
import {
CodeActionContext, commands, CompletionItem, ConfigurationTarget, Diagnostic, env, EventEmitter, ExtensionContext, extensions,
IndentAction, InputBoxOptions, languages, Location, MarkdownString, RelativePattern,
InputBoxOptions, Location, MarkdownString, RelativePattern,
SnippetString, SnippetTextEdit, TextDocument, TextEditorRevealType, UIKind, Uri, version, ViewColumn, window, workspace, WorkspaceConfiguration
} from 'vscode';
import { CancellationToken, CodeActionParams, CodeActionRequest, CodeActionResolveRequest, Command, CompletionRequest, DidChangeConfigurationNotification, ExecuteCommandParams, ExecuteCommandRequest, LanguageClientOptions, RevealOutputChannelOn } from 'vscode-languageclient';
Expand Down Expand Up @@ -169,8 +169,6 @@ export async function activate(context: ExtensionContext): Promise<ExtensionAPI>

Telemetry.startTelemetry(context);

enableJavadocSymbols();

registerOutOfMemoryDetection(storagePath);

cleanJavaWorkspaceStorage();
Expand Down Expand Up @@ -814,52 +812,6 @@ export async function getActiveLanguageClient(): Promise<LanguageClient | undefi
return languageClient;
}

function enableJavadocSymbols() {
// Let's enable Javadoc symbols autocompletion, shamelessly copied from MIT licensed code at
// https://github.com/Microsoft/vscode/blob/9d611d4dfd5a4a101b5201b8c9e21af97f06e7a7/extensions/typescript/src/typescriptMain.ts#L186
languages.setLanguageConfiguration('java', {
indentationRules: {
// ^(.*\*/)?\s*\}.*$
decreaseIndentPattern: /^(.*\*\/)?\s*\}.*$/,
// ^.*\{[^}"']*$
increaseIndentPattern: /^.*\{[^}"']*$/
},
wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
onEnterRules: [
{
// e.g. /** | */ or /* | */
beforeText: /^\s*\/\*\*?(?!\/)([^\*]|\*(?!\/))*$/,
afterText: /^\s*\*\/$/,
action: { indentAction: IndentAction.IndentOutdent, appendText: ' * ' }
},
{
// e.g. /** ...|
beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/,
action: { indentAction: IndentAction.None, appendText: ' * ' }
},
{
// e.g. * ...|
beforeText: /^(\t|(\ \ ))*\ \*(\ ([^\*]|\*(?!\/))*)?$/,
action: { indentAction: IndentAction.None, appendText: '* ' }
},
{
// e.g. */|
beforeText: /^(\t|(\ \ ))*\ \*\/\s*$/,
action: { indentAction: IndentAction.None, removeText: 1 }
},
{
// e.g. *-----*/|
beforeText: /^(\t|(\ \ ))*\ \*[^/]*\*\/\s*$/,
action: { indentAction: IndentAction.None, removeText: 1 }
},
{
// e.g. /// ...| (Markdown javadoc)
beforeText: /^\s*\/\/\/(.*)?$/,
action: { indentAction: IndentAction.None, appendText: '/// ' }
}
]
});
}

export function getTempWorkspace() {
return path.resolve(os.tmpdir(), `vscodesws_${makeRandomHexString(5)}`);
Expand Down