-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[languages][java]Move java grammars from java extension to textmate-g…
…rammars Signed-off-by: Valeriy Svydenko <vsvydenk@redhat.com>
- Loading branch information
Showing
8 changed files
with
80 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
33 changes: 0 additions & 33 deletions
33
packages/java/src/browser/monaco-contribution/java-monaco-language.ts
This file was deleted.
Oops, something went wrong.
47 changes: 0 additions & 47 deletions
47
packages/java/src/browser/monaco-contribution/java-textmate-contribution.ts
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/******************************************************************************** | ||
* Copyright (C) 2019 Red Hat, Inc. and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
|
||
import { LanguageGrammarDefinitionContribution, TextmateRegistry } from '@theia/monaco/lib/browser/textmate'; | ||
import { injectable } from 'inversify'; | ||
|
||
@injectable() | ||
export class JavaContribution implements LanguageGrammarDefinitionContribution { | ||
private readonly id = 'java'; | ||
private readonly javaScope = 'source.java'; | ||
private readonly javaDocScope = 'text.html.javadoc'; | ||
|
||
registerTextmateLanguage(registry: TextmateRegistry) { | ||
monaco.languages.register({ | ||
id: this.id, | ||
extensions: [ | ||
'.java', | ||
'.jav', | ||
'.class' | ||
], | ||
firstLine: '(\\<\\?xml.*)|(\\<svg)|(\\<\\!doctype\\s+svg)', | ||
aliases: ['Java', 'java'], | ||
mimetypes: ['text/x-java-source', 'text/x-java'] | ||
}); | ||
monaco.languages.setLanguageConfiguration(this.id, { | ||
// the default separators except `@$` | ||
wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g, | ||
comments: { | ||
lineComment: '//', | ||
blockComment: ['/*', '*/'], | ||
}, | ||
brackets: [['{', '}'], ['[', ']'], ['(', ')'], ['<', '>']], | ||
autoClosingPairs: [ | ||
{ open: '"', close: '"', notIn: ['string', 'comment'] }, | ||
{ open: '\'', close: '\'', notIn: ['string', 'comment'] }, | ||
{ open: '{', close: '}', notIn: ['string', 'comment'] }, | ||
{ open: '[', close: ']', notIn: ['string', 'comment'] }, | ||
{ open: '(', close: ')', notIn: ['string', 'comment'] }, | ||
{ open: '<', close: '>', notIn: ['string', 'comment'] }, | ||
] | ||
}); | ||
|
||
const javaDocGrammar = require('../../data/java.tmLanguage.json'); | ||
registry.registerTextmateGrammarScope(this.javaDocScope, { | ||
async getGrammarDefinition() { | ||
return { | ||
format: 'json', | ||
content: javaDocGrammar | ||
}; | ||
} | ||
}); | ||
const javaGrammar = require('../../data/java.tmLanguage.json'); | ||
registry.registerTextmateGrammarScope(this.javaScope, { | ||
async getGrammarDefinition() { | ||
return { | ||
format: 'json', | ||
content: javaGrammar | ||
}; | ||
} | ||
}); | ||
registry.mapLanguageIdToTextmateGrammar(this.id, this.javaScope); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters