Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Javadoc comment support
  • Loading branch information
georgewfraser committed May 23, 2016
1 parent a8fb080 commit a7fd1f1
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
48 changes: 48 additions & 0 deletions lib/Main.ts
Expand Up @@ -64,6 +64,54 @@ export function activate(ctx: VSCode.ExtensionContext) {
if (Path.basename(document.fileName) == 'javaconfig.json')
Finder.invalidateCaches();
}));

// Set indentation rules
VSCode.languages.setLanguageConfiguration('java', {
indentationRules: {
// ^(.*\*/)?\s*\}.*$
decreaseIndentPattern: /^(.*\*\/)?\s*\}.*$/,
// ^.*\{[^}"']*$
increaseIndentPattern: /^.*\{[^}"']*$/
},
wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
comments: {
lineComment: '//',
blockComment: ['/*', '*/']
},
brackets: [
['{', '}'],
['[', ']'],
['(', ')'],
],
onEnterRules: [
{
// e.g. /** | */
beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/,
afterText: /^\s*\*\/$/,
action: { indentAction: VSCode.IndentAction.IndentOutdent, appendText: ' * ' }
},
{
// e.g. /** ...|
beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/,
action: { indentAction: VSCode.IndentAction.None, appendText: ' * ' }
},
{
// e.g. * ...|
beforeText: /^(\t|(\ \ ))*\ \*(\ ([^\*]|\*(?!\/))*)?$/,
action: { indentAction: VSCode.IndentAction.None, appendText: '* ' }
},
{
// e.g. */|
beforeText: /^(\t|(\ \ ))*\ \*\/\s*$/,
action: { indentAction: VSCode.IndentAction.None, removeText: 1 }
}
],

// TODO equivalent of this from typescript when replacement for __electricCharacterSupport API is released
// __electricCharacterSupport: {
// docComment: { scope: 'comment.documentation', open: '/**', lineStart: ' * ', close: ' */' }
// }
});
}

function onErrorWithoutRequestId(message: string) {
Expand Down
4 changes: 4 additions & 0 deletions package.json
Expand Up @@ -38,6 +38,10 @@
]
}
],
"snippets": [{
"language": "java",
"path": "./snippets/java.json"
}],
"jsonValidation": [
{
"fileMatch": "javaconfig.json",
Expand Down
11 changes: 11 additions & 0 deletions snippets/java.json
@@ -0,0 +1,11 @@
{
"Javadoc": {
"prefix": "doc",
"body": [
"/**",
" * $0",
" */"
],
"description": "Javadoc"
}
}

0 comments on commit a7fd1f1

Please sign in to comment.