commit
c8483a7ae5
6 changed files with 782 additions and 2 deletions
21
demo/kitchen-sink/docs/vala.vala
Normal file
21
demo/kitchen-sink/docs/vala.vala
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
using Gtk;
|
||||
|
||||
int main (string[] args) {
|
||||
Gtk.init (ref args);
|
||||
var foo = new MyFoo<string[](), MyBar<string, int>>();
|
||||
|
||||
var window = new Window();
|
||||
window.title = "Hello, World!";
|
||||
window.border_width = 10;
|
||||
window.window_position = WindowPosition.CENTER;
|
||||
window.set_default_size(350, 70);
|
||||
window.destroy.connect(Gtk.main_quit);
|
||||
|
||||
var label = new Label("Hello, World!");
|
||||
|
||||
window.add(label);
|
||||
window.show_all();
|
||||
|
||||
Gtk.main();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -108,8 +108,9 @@ var loadSnippetFile = function(id) {
|
|||
config.loadModule(snippetFilePath, function(m) {
|
||||
if (m) {
|
||||
snippetManager.files[id] = m;
|
||||
m.snippets = snippetManager.parseSnippetFile(m.snippetText);
|
||||
snippetManager.register(m.snippets, m.scope);
|
||||
if (!m.snippets && m.snippetText)
|
||||
m.snippets = snippetManager.parseSnippetFile(m.snippetText);
|
||||
snippetManager.register(m.snippets || [], m.scope);
|
||||
if (m.includeScopes) {
|
||||
snippetManager.snippetMap[m.scope].includeScopes = m.includeScopes;
|
||||
m.includeScopes.forEach(function(x) {
|
||||
|
|
|
|||
|
|
@ -143,6 +143,7 @@ var supportedModes = {
|
|||
Toml: ["toml"],
|
||||
Twig: ["twig"],
|
||||
Typescript: ["ts|typescript|str"],
|
||||
Vala: ["vala"],
|
||||
VBScript: ["vbs"],
|
||||
Velocity: ["vm"],
|
||||
Verilog: ["v|vh|sv|svh"],
|
||||
|
|
|
|||
105
lib/ace/mode/vala.js
Normal file
105
lib/ace/mode/vala.js
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Distributed under the BSD license:
|
||||
*
|
||||
* Copyright (c) 2012, Ajax.org B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Ajax.org B.V. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
THIS FILE WAS AUTOGENERATED BY mode.tmpl.js
|
||||
*/
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextMode = require("./text").Mode;
|
||||
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||
var ValaHighlightRules = require("./vala_highlight_rules").ValaHighlightRules;
|
||||
var FoldMode = require("./folding/cstyle").FoldMode;
|
||||
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
|
||||
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
|
||||
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
|
||||
|
||||
var Mode = function() {
|
||||
this.HighlightRules = ValaHighlightRules;
|
||||
|
||||
this.$outdent = new MatchingBraceOutdent();
|
||||
this.$behaviour = new CstyleBehaviour();
|
||||
this.foldingRules = new CStyleFoldMode();
|
||||
};
|
||||
oop.inherits(Mode, TextMode);
|
||||
|
||||
(function() {
|
||||
this.lineCommentStart = "//";
|
||||
this.blockComment = {start: "/*", end: "*/"};
|
||||
|
||||
this.getNextLineIndent = function(state, line, tab) {
|
||||
var indent = this.$getIndent(line);
|
||||
|
||||
var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
|
||||
var tokens = tokenizedLine.tokens;
|
||||
var endState = tokenizedLine.state;
|
||||
|
||||
if (tokens.length && tokens[tokens.length-1].type == "comment") {
|
||||
return indent;
|
||||
}
|
||||
|
||||
if (state == "start" || state == "no_regex") {
|
||||
var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);
|
||||
if (match) {
|
||||
indent += tab;
|
||||
}
|
||||
} else if (state == "doc-start") {
|
||||
if (endState == "start" || endState == "no_regex") {
|
||||
return "";
|
||||
}
|
||||
var match = line.match(/^\s*(\/?)\*/);
|
||||
if (match) {
|
||||
if (match[1]) {
|
||||
indent += " ";
|
||||
}
|
||||
indent += "* ";
|
||||
}
|
||||
}
|
||||
|
||||
return indent;
|
||||
};
|
||||
|
||||
this.checkOutdent = function(state, line, input) {
|
||||
return this.$outdent.checkOutdent(line, input);
|
||||
};
|
||||
|
||||
this.autoOutdent = function(state, doc, row) {
|
||||
this.$outdent.autoOutdent(doc, row);
|
||||
};
|
||||
|
||||
// Extra logic goes here.
|
||||
this.$id = "ace/mode/vala"
|
||||
}).call(Mode.prototype);
|
||||
|
||||
exports.Mode = Mode;
|
||||
});
|
||||
457
lib/ace/mode/vala_highlight_rules.js
Normal file
457
lib/ace/mode/vala_highlight_rules.js
Normal file
|
|
@ -0,0 +1,457 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Distributed under the BSD license:
|
||||
*
|
||||
* Copyright (c) 2012, Ajax.org B.V.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of Ajax.org B.V. nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/* This file was autogenerated from https://raw.githubusercontent.com/technosophos/Vala-TMBundle/master/Syntaxes/Vala.tmLanguage (uuid: ) */
|
||||
/****************************************************************************************
|
||||
* IT MIGHT NOT BE PERFECT ...But it's a good start from an existing *.tmlanguage file. *
|
||||
* fileTypes *
|
||||
****************************************************************************************/
|
||||
|
||||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
var oop = require("../lib/oop");
|
||||
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||
|
||||
var ValaHighlightRules = function() {
|
||||
// regexp must not have capturing parentheses. Use (?:) instead.
|
||||
// regexps are ordered -> the first match is used
|
||||
|
||||
this.$rules = { start:
|
||||
[ { token:
|
||||
[ 'meta.using.vala',
|
||||
'keyword.other.using.vala',
|
||||
'meta.using.vala',
|
||||
'storage.modifier.using.vala',
|
||||
'meta.using.vala',
|
||||
'punctuation.terminator.vala' ],
|
||||
regex: '^(\\s*)(using)\\b(?:(\\s*)([^ ;$]+)(\\s*)((?:;)?))?' },
|
||||
{ include: '#code' } ],
|
||||
'#all-types':
|
||||
[ { include: '#primitive-arrays' },
|
||||
{ include: '#primitive-types' },
|
||||
{ include: '#object-types' } ],
|
||||
'#annotations':
|
||||
[ { token:
|
||||
[ 'storage.type.annotation.vala',
|
||||
'punctuation.definition.annotation-arguments.begin.vala' ],
|
||||
regex: '(@[^ (]+)(\\()',
|
||||
push:
|
||||
[ { token: 'punctuation.definition.annotation-arguments.end.vala',
|
||||
regex: '\\)',
|
||||
next: 'pop' },
|
||||
{ token:
|
||||
[ 'constant.other.key.vala',
|
||||
'text',
|
||||
'keyword.operator.assignment.vala' ],
|
||||
regex: '(\\w*)(\\s*)(=)' },
|
||||
{ include: '#code' },
|
||||
{ token: 'punctuation.seperator.property.vala', regex: ',' },
|
||||
{ defaultToken: 'meta.declaration.annotation.vala' } ] },
|
||||
{ token: 'storage.type.annotation.vala', regex: '@\\w*' } ],
|
||||
'#anonymous-classes-and-new':
|
||||
[ { token: 'keyword.control.new.vala',
|
||||
regex: '\\bnew\\b',
|
||||
push_disabled:
|
||||
[ { token: 'text',
|
||||
regex: '(?<=\\)|\\])(?!\\s*{)|(?<=})|(?=;)',
|
||||
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
||||
originalRegex: '(?<=\\)|\\])(?!\\s*{)|(?<=})|(?=;)',
|
||||
next: 'pop' },
|
||||
{ token: [ 'storage.type.vala', 'text' ],
|
||||
regex: '(\\w+)(\\s*)(?=\\[)',
|
||||
push:
|
||||
[ { token: 'text', regex: '}|(?=;|\\))', next: 'pop' },
|
||||
{ token: 'text',
|
||||
regex: '\\[',
|
||||
push:
|
||||
[ { token: 'text', regex: '\\]', next: 'pop' },
|
||||
{ include: '#code' } ] },
|
||||
{ token: 'text',
|
||||
regex: '{',
|
||||
push:
|
||||
[ { token: 'text', regex: '(?=})', next: 'pop' },
|
||||
{ include: '#code' } ] } ] },
|
||||
{ token: 'text',
|
||||
regex: '(?=\\w.*\\()',
|
||||
push:
|
||||
[ { token: 'text',
|
||||
regex: '(?<=\\))',
|
||||
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
||||
originalRegex: '(?<=\\))',
|
||||
next: 'pop' },
|
||||
{ include: '#object-types' },
|
||||
{ token: 'text',
|
||||
regex: '\\(',
|
||||
push:
|
||||
[ { token: 'text', regex: '\\)', next: 'pop' },
|
||||
{ include: '#code' } ] } ] },
|
||||
{ token: 'meta.inner-class.vala',
|
||||
regex: '{',
|
||||
push:
|
||||
[ { token: 'meta.inner-class.vala', regex: '}', next: 'pop' },
|
||||
{ include: '#class-body' },
|
||||
{ defaultToken: 'meta.inner-class.vala' } ] } ] } ],
|
||||
'#assertions':
|
||||
[ { token:
|
||||
[ 'keyword.control.assert.vala',
|
||||
'meta.declaration.assertion.vala' ],
|
||||
regex: '\\b(assert|requires|ensures)(\\s)',
|
||||
push:
|
||||
[ { token: 'meta.declaration.assertion.vala',
|
||||
regex: '$',
|
||||
next: 'pop' },
|
||||
{ token: 'keyword.operator.assert.expression-seperator.vala',
|
||||
regex: ':' },
|
||||
{ include: '#code' },
|
||||
{ defaultToken: 'meta.declaration.assertion.vala' } ] } ],
|
||||
'#class':
|
||||
[ { token: 'meta.class.vala',
|
||||
regex: '(?=\\w?[\\w\\s]*(?:class|(?:@)?interface|enum|struct|namespace)\\s+\\w+)',
|
||||
push:
|
||||
[ { token: 'punctuation.section.class.end.vala',
|
||||
regex: '}',
|
||||
next: 'pop' },
|
||||
{ include: '#storage-modifiers' },
|
||||
{ include: '#comments' },
|
||||
{ token:
|
||||
[ 'storage.modifier.vala',
|
||||
'meta.class.identifier.vala',
|
||||
'entity.name.type.class.vala' ],
|
||||
regex: '(class|(?:@)?interface|enum|struct|namespace)(\\s+)([\\w\\.]+)' },
|
||||
{ token: 'storage.modifier.extends.vala',
|
||||
regex: ':',
|
||||
push:
|
||||
[ { token: 'meta.definition.class.inherited.classes.vala',
|
||||
regex: '(?={|,)',
|
||||
next: 'pop' },
|
||||
{ include: '#object-types-inherited' },
|
||||
{ include: '#comments' },
|
||||
{ defaultToken: 'meta.definition.class.inherited.classes.vala' } ] },
|
||||
{ token:
|
||||
[ 'storage.modifier.implements.vala',
|
||||
'meta.definition.class.implemented.interfaces.vala' ],
|
||||
regex: '(,)(\\s)',
|
||||
push:
|
||||
[ { token: 'meta.definition.class.implemented.interfaces.vala',
|
||||
regex: '(?=\\{)',
|
||||
next: 'pop' },
|
||||
{ include: '#object-types-inherited' },
|
||||
{ include: '#comments' },
|
||||
{ defaultToken: 'meta.definition.class.implemented.interfaces.vala' } ] },
|
||||
{ token: 'meta.class.body.vala',
|
||||
regex: '{',
|
||||
push:
|
||||
[ { token: 'meta.class.body.vala', regex: '(?=})', next: 'pop' },
|
||||
{ include: '#class-body' },
|
||||
{ defaultToken: 'meta.class.body.vala' } ] },
|
||||
{ defaultToken: 'meta.class.vala' } ],
|
||||
comment: 'attempting to put namespace in here.' } ],
|
||||
'#class-body':
|
||||
[ { include: '#comments' },
|
||||
{ include: '#class' },
|
||||
{ include: '#enums' },
|
||||
{ include: '#methods' },
|
||||
{ include: '#annotations' },
|
||||
{ include: '#storage-modifiers' },
|
||||
{ include: '#code' } ],
|
||||
'#code':
|
||||
[ { include: '#comments' },
|
||||
{ include: '#class' },
|
||||
{ token: 'text',
|
||||
regex: '{',
|
||||
push:
|
||||
[ { token: 'text', regex: '}', next: 'pop' },
|
||||
{ include: '#code' } ] },
|
||||
{ include: '#assertions' },
|
||||
{ include: '#parens' },
|
||||
{ include: '#constants-and-special-vars' },
|
||||
{ include: '#anonymous-classes-and-new' },
|
||||
{ include: '#keywords' },
|
||||
{ include: '#storage-modifiers' },
|
||||
{ include: '#strings' },
|
||||
{ include: '#all-types' } ],
|
||||
'#comments':
|
||||
[ { token: 'punctuation.definition.comment.vala',
|
||||
regex: '/\\*\\*/' },
|
||||
{ include: 'text.html.javadoc' },
|
||||
{ include: '#comments-inline' } ],
|
||||
'#comments-inline':
|
||||
[ { token: 'punctuation.definition.comment.vala',
|
||||
regex: '/\\*',
|
||||
push:
|
||||
[ { token: 'punctuation.definition.comment.vala',
|
||||
regex: '\\*/',
|
||||
next: 'pop' },
|
||||
{ defaultToken: 'comment.block.vala' } ] },
|
||||
{ token:
|
||||
[ 'text',
|
||||
'punctuation.definition.comment.vala',
|
||||
'comment.line.double-slash.vala' ],
|
||||
regex: '(\\s*)(//)(.*$)' } ],
|
||||
'#constants-and-special-vars':
|
||||
[ { token: 'constant.language.vala',
|
||||
regex: '\\b(?:true|false|null)\\b' },
|
||||
{ token: 'variable.language.vala',
|
||||
regex: '\\b(?:this|base)\\b' },
|
||||
{ token: 'constant.numeric.vala',
|
||||
regex: '\\b(?:0(?:x|X)[0-9a-fA-F]*|(?:[0-9]+\\.?[0-9]*|\\.[0-9]+)(?:(?:e|E)(?:\\+|-)?[0-9]+)?)(?:[LlFfUuDd]|UL|ul)?\\b' },
|
||||
{ token: [ 'keyword.operator.dereference.vala', 'constant.other.vala' ],
|
||||
regex: '((?:\\.)?)\\b([A-Z][A-Z0-9_]+)(?!<|\\.class|\\s*\\w+\\s*=)\\b' } ],
|
||||
'#enums':
|
||||
[ { token: 'text',
|
||||
regex: '^(?=\\s*[A-Z0-9_]+\\s*(?:{|\\(|,))',
|
||||
push:
|
||||
[ { token: 'text', regex: '(?=;|})', next: 'pop' },
|
||||
{ token: 'constant.other.enum.vala',
|
||||
regex: '\\w+',
|
||||
push:
|
||||
[ { token: 'meta.enum.vala', regex: '(?=,|;|})', next: 'pop' },
|
||||
{ include: '#parens' },
|
||||
{ token: 'text',
|
||||
regex: '{',
|
||||
push:
|
||||
[ { token: 'text', regex: '}', next: 'pop' },
|
||||
{ include: '#class-body' } ] },
|
||||
{ defaultToken: 'meta.enum.vala' } ] } ] } ],
|
||||
'#keywords':
|
||||
[ { token: 'keyword.control.catch-exception.vala',
|
||||
regex: '\\b(?:try|catch|finally|throw)\\b' },
|
||||
{ token: 'keyword.control.vala', regex: '\\?|:|\\?\\?' },
|
||||
{ token: 'keyword.control.vala',
|
||||
regex: '\\b(?:return|break|case|continue|default|do|while|for|foreach|switch|if|else|in|yield|get|set|value)\\b' },
|
||||
{ token: 'keyword.operator.vala',
|
||||
regex: '\\b(?:typeof|is|as)\\b' },
|
||||
{ token: 'keyword.operator.comparison.vala',
|
||||
regex: '==|!=|<=|>=|<>|<|>' },
|
||||
{ token: 'keyword.operator.assignment.vala', regex: '=' },
|
||||
{ token: 'keyword.operator.increment-decrement.vala',
|
||||
regex: '\\-\\-|\\+\\+' },
|
||||
{ token: 'keyword.operator.arithmetic.vala',
|
||||
regex: '\\-|\\+|\\*|\\/|%' },
|
||||
{ token: 'keyword.operator.logical.vala', regex: '!|&&|\\|\\|' },
|
||||
{ token: 'keyword.operator.dereference.vala',
|
||||
regex: '\\.(?=\\S)',
|
||||
originalRegex: '(?<=\\S)\\.(?=\\S)' },
|
||||
{ token: 'punctuation.terminator.vala', regex: ';' },
|
||||
{ token: 'keyword.operator.ownership', regex: 'owned|unowned' } ],
|
||||
'#methods':
|
||||
[ { token: 'meta.method.vala',
|
||||
regex: '(?!new)(?=\\w.*\\s+)(?=[^=]+\\()',
|
||||
push:
|
||||
[ { token: 'meta.method.vala', regex: '}|(?=;)', next: 'pop' },
|
||||
{ include: '#storage-modifiers' },
|
||||
{ token: [ 'entity.name.function.vala', 'meta.method.identifier.vala' ],
|
||||
regex: '([\\~\\w\\.]+)(\\s*\\()',
|
||||
push:
|
||||
[ { token: 'meta.method.identifier.vala',
|
||||
regex: '\\)',
|
||||
next: 'pop' },
|
||||
{ include: '#parameters' },
|
||||
{ defaultToken: 'meta.method.identifier.vala' } ] },
|
||||
{ token: 'meta.method.return-type.vala',
|
||||
regex: '(?=\\w.*\\s+\\w+\\s*\\()',
|
||||
push:
|
||||
[ { token: 'meta.method.return-type.vala',
|
||||
regex: '(?=\\w+\\s*\\()',
|
||||
next: 'pop' },
|
||||
{ include: '#all-types' },
|
||||
{ defaultToken: 'meta.method.return-type.vala' } ] },
|
||||
{ include: '#throws' },
|
||||
{ token: 'meta.method.body.vala',
|
||||
regex: '{',
|
||||
push:
|
||||
[ { token: 'meta.method.body.vala', regex: '(?=})', next: 'pop' },
|
||||
{ include: '#code' },
|
||||
{ defaultToken: 'meta.method.body.vala' } ] },
|
||||
{ defaultToken: 'meta.method.vala' } ] } ],
|
||||
'#namespace':
|
||||
[ { token: 'text',
|
||||
regex: '^(?=\\s*[A-Z0-9_]+\\s*(?:{|\\(|,))',
|
||||
push:
|
||||
[ { token: 'text', regex: '(?=;|})', next: 'pop' },
|
||||
{ token: 'constant.other.namespace.vala',
|
||||
regex: '\\w+',
|
||||
push:
|
||||
[ { token: 'meta.namespace.vala', regex: '(?=,|;|})', next: 'pop' },
|
||||
{ include: '#parens' },
|
||||
{ token: 'text',
|
||||
regex: '{',
|
||||
push:
|
||||
[ { token: 'text', regex: '}', next: 'pop' },
|
||||
{ include: '#code' } ] },
|
||||
{ defaultToken: 'meta.namespace.vala' } ] } ],
|
||||
comment: 'This is not quite right. See the class grammar right now' } ],
|
||||
'#object-types':
|
||||
[ { token: 'storage.type.generic.vala',
|
||||
regex: '\\b(?:[a-z]\\w*\\.)*[A-Z]+\\w*<',
|
||||
push:
|
||||
[ { token: 'storage.type.generic.vala',
|
||||
regex: '>|[^\\w\\s,\\?<\\[()\\]]',
|
||||
TODO: 'FIXME: regexp doesn\'t have js equivalent',
|
||||
originalRegex: '>|[^\\w\\s,\\?<\\[(?:[,]+)\\]]',
|
||||
next: 'pop' },
|
||||
{ include: '#object-types' },
|
||||
{ token: 'storage.type.generic.vala',
|
||||
regex: '<',
|
||||
push:
|
||||
[ { token: 'storage.type.generic.vala',
|
||||
regex: '>|[^\\w\\s,\\[\\]<]',
|
||||
next: 'pop' },
|
||||
{ defaultToken: 'storage.type.generic.vala' } ],
|
||||
comment: 'This is just to support <>\'s with no actual type prefix' },
|
||||
{ defaultToken: 'storage.type.generic.vala' } ] },
|
||||
{ token: 'storage.type.object.array.vala',
|
||||
regex: '\\b(?:[a-z]\\w*\\.)*[A-Z]+\\w*(?=\\[)',
|
||||
push:
|
||||
[ { token: 'storage.type.object.array.vala',
|
||||
regex: '(?=[^\\]\\s])',
|
||||
next: 'pop' },
|
||||
{ token: 'text',
|
||||
regex: '\\[',
|
||||
push:
|
||||
[ { token: 'text', regex: '\\]', next: 'pop' },
|
||||
{ include: '#code' } ] },
|
||||
{ defaultToken: 'storage.type.object.array.vala' } ] },
|
||||
{ token:
|
||||
[ 'storage.type.vala',
|
||||
'keyword.operator.dereference.vala',
|
||||
'storage.type.vala' ],
|
||||
regex: '\\b(?:([a-z]\\w*)(\\.))*([A-Z]+\\w*\\b)' } ],
|
||||
'#object-types-inherited':
|
||||
[ { token: 'entity.other.inherited-class.vala',
|
||||
regex: '\\b(?:[a-z]\\w*\\.)*[A-Z]+\\w*<',
|
||||
push:
|
||||
[ { token: 'entity.other.inherited-class.vala',
|
||||
regex: '>|[^\\w\\s,<]',
|
||||
next: 'pop' },
|
||||
{ include: '#object-types' },
|
||||
{ token: 'storage.type.generic.vala',
|
||||
regex: '<',
|
||||
push:
|
||||
[ { token: 'storage.type.generic.vala',
|
||||
regex: '>|[^\\w\\s,<]',
|
||||
next: 'pop' },
|
||||
{ defaultToken: 'storage.type.generic.vala' } ],
|
||||
comment: 'This is just to support <>\'s with no actual type prefix' },
|
||||
{ defaultToken: 'entity.other.inherited-class.vala' } ] },
|
||||
{ token:
|
||||
[ 'entity.other.inherited-class.vala',
|
||||
'keyword.operator.dereference.vala',
|
||||
'entity.other.inherited-class.vala' ],
|
||||
regex: '\\b(?:([a-z]\\w*)(\\.))*([A-Z]+\\w*)' } ],
|
||||
'#parameters':
|
||||
[ { token: 'storage.modifier.vala', regex: 'final' },
|
||||
{ include: '#primitive-arrays' },
|
||||
{ include: '#primitive-types' },
|
||||
{ include: '#object-types' },
|
||||
{ token: 'variable.parameter.vala', regex: '\\w+' } ],
|
||||
'#parens':
|
||||
[ { token: 'text',
|
||||
regex: '\\(',
|
||||
push:
|
||||
[ { token: 'text', regex: '\\)', next: 'pop' },
|
||||
{ include: '#code' } ] } ],
|
||||
'#primitive-arrays':
|
||||
[ { token: 'storage.type.primitive.array.vala',
|
||||
regex: '\\b(?:bool|byte|sbyte|char|decimal|double|float|int|uint|long|ulong|object|short|ushort|string|void|int8|int16|int32|int64|uint8|uint16|uint32|uint64)(?:\\[\\])*\\b' } ],
|
||||
'#primitive-types':
|
||||
[ { token: 'storage.type.primitive.vala',
|
||||
regex: '\\b(?:var|bool|byte|sbyte|char|decimal|double|float|int|uint|long|ulong|object|short|ushort|string|void|signal|int8|int16|int32|int64|uint8|uint16|uint32|uint64)\\b',
|
||||
comment: 'var is not really a primitive, but acts like one in most cases' } ],
|
||||
'#storage-modifiers':
|
||||
[ { token: 'storage.modifier.vala',
|
||||
regex: '\\b(?:public|private|protected|internal|static|final|sealed|virtual|override|abstract|readonly|volatile|dynamic|async|unsafe|out|ref|weak|owned|unowned|const)\\b',
|
||||
comment: 'Not sure about unsafe and readonly' } ],
|
||||
'#strings':
|
||||
[ { token: 'punctuation.definition.string.begin.vala',
|
||||
regex: '@"',
|
||||
push:
|
||||
[ { token: 'punctuation.definition.string.end.vala',
|
||||
regex: '"',
|
||||
next: 'pop' },
|
||||
{ token: 'constant.character.escape.vala',
|
||||
regex: '\\\\.|%[\\w\\.\\-]+|\\$(?:\\w+|\\([\\w\\s\\+\\-\\*\\/]+\\))' },
|
||||
{ defaultToken: 'string.quoted.interpolated.vala' } ] },
|
||||
{ token: 'punctuation.definition.string.begin.vala',
|
||||
regex: '"',
|
||||
push:
|
||||
[ { token: 'punctuation.definition.string.end.vala',
|
||||
regex: '"',
|
||||
next: 'pop' },
|
||||
{ token: 'constant.character.escape.vala', regex: '\\\\.' },
|
||||
{ token: 'constant.character.escape.vala',
|
||||
regex: '%[\\w\\.\\-]+' },
|
||||
{ defaultToken: 'string.quoted.double.vala' } ] },
|
||||
{ token: 'punctuation.definition.string.begin.vala',
|
||||
regex: '\'',
|
||||
push:
|
||||
[ { token: 'punctuation.definition.string.end.vala',
|
||||
regex: '\'',
|
||||
next: 'pop' },
|
||||
{ token: 'constant.character.escape.vala', regex: '\\\\.' },
|
||||
{ defaultToken: 'string.quoted.single.vala' } ] },
|
||||
{ token: 'punctuation.definition.string.begin.vala',
|
||||
regex: '"""',
|
||||
push:
|
||||
[ { token: 'punctuation.definition.string.end.vala',
|
||||
regex: '"""',
|
||||
next: 'pop' },
|
||||
{ token: 'constant.character.escape.vala',
|
||||
regex: '%[\\w\\.\\-]+' },
|
||||
{ defaultToken: 'string.quoted.triple.vala' } ] } ],
|
||||
'#throws':
|
||||
[ { token: 'storage.modifier.vala',
|
||||
regex: 'throws',
|
||||
push:
|
||||
[ { token: 'meta.throwables.vala', regex: '(?={|;)', next: 'pop' },
|
||||
{ include: '#object-types' },
|
||||
{ defaultToken: 'meta.throwables.vala' } ] } ],
|
||||
'#values':
|
||||
[ { include: '#strings' },
|
||||
{ include: '#object-types' },
|
||||
{ include: '#constants-and-special-vars' } ] }
|
||||
|
||||
this.normalizeRules();
|
||||
};
|
||||
|
||||
ValaHighlightRules.metaData = {
|
||||
comment: 'Based heavily on the Java bundle\'s language syntax. TODO:\n* Closures\n* Delegates\n* Properties: Better support for properties.\n* Annotations\n* Error domains\n* Named arguments\n* Array slicing, negative indexes, multidimensional\n* construct blocks\n* lock blocks?\n* regex literals\n* DocBlock syntax highlighting. (Currently importing javadoc)\n* Folding rule for comments.\n',
|
||||
fileTypes: [ 'vala' ],
|
||||
foldingStartMarker: '(\\{\\s*(//.*)?$|^\\s*// \\{\\{\\{)',
|
||||
foldingStopMarker: '^\\s*(\\}|// \\}\\}\\}$)',
|
||||
name: 'Vala',
|
||||
scopeName: 'source.vala' }
|
||||
|
||||
|
||||
oop.inherits(ValaHighlightRules, TextHighlightRules);
|
||||
|
||||
exports.ValaHighlightRules = ValaHighlightRules;
|
||||
});
|
||||
195
lib/ace/snippets/vala.js
Normal file
195
lib/ace/snippets/vala.js
Normal file
|
|
@ -0,0 +1,195 @@
|
|||
define(function(require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
// exports.snippetText = require("../requirejs/text!./.snippets");
|
||||
exports.snippets = [
|
||||
{
|
||||
"content": "case ${1:condition}:\n\t$0\n\tbreak;\n",
|
||||
"name": "case",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "case"
|
||||
},
|
||||
{
|
||||
"content": "/**\n * ${6}\n */\n${1:public} class ${2:MethodName}${3: : GLib.Object} {\n\n\t/**\n\t * ${7}\n\t */\n\tpublic ${2}(${4}) {\n\t\t${5}\n\t}\n\n\t$0\n}",
|
||||
"name": "class",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "class"
|
||||
},
|
||||
{
|
||||
"content": "(${1}) => {\n\t${0}\n}\n",
|
||||
"name": "closure",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "=>"
|
||||
},
|
||||
{
|
||||
"content": "/*\n * $0\n */",
|
||||
"name": "Comment (multiline)",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "/*"
|
||||
},
|
||||
{
|
||||
"content": "Console.WriteLine($1);\n$0",
|
||||
"name": "Console.WriteLine (writeline)",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "writeline"
|
||||
},
|
||||
{
|
||||
"content": "[DBus(name = \"$0\")]",
|
||||
"name": "DBus annotation",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "[DBus"
|
||||
},
|
||||
{
|
||||
"content": "delegate ${1:void} ${2:DelegateName}($0);",
|
||||
"name": "delegate",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "delegate"
|
||||
},
|
||||
{
|
||||
"content": "do {\n\t$0\n} while ($1);\n",
|
||||
"name": "do while",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "dowhile"
|
||||
},
|
||||
{
|
||||
"content": "/**\n * $0\n */",
|
||||
"name": "DocBlock",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "/**"
|
||||
},
|
||||
{
|
||||
"content": "else if ($1) {\n\t$0\n}\n",
|
||||
"name": "else if (elseif)",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "elseif"
|
||||
},
|
||||
{
|
||||
"content": "else {\n\t$0\n}",
|
||||
"name": "else",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "else"
|
||||
},
|
||||
{
|
||||
"content": "enum {$1:EnumName} {\n\t$0\n}",
|
||||
"name": "enum",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "enum"
|
||||
},
|
||||
{
|
||||
"content": "public errordomain ${1:Error} {\n\t$0\n}",
|
||||
"name": "error domain",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "errordomain"
|
||||
},
|
||||
{
|
||||
"content": "for ($1;$2;$3) {\n\t$0\n}",
|
||||
"name": "for",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "for"
|
||||
},
|
||||
{
|
||||
"content": "foreach ($1 in $2) {\n\t$0\n}",
|
||||
"name": "foreach",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "foreach"
|
||||
},
|
||||
{
|
||||
"content": "Gee.ArrayList<${1:G}>($0);",
|
||||
"name": "Gee.ArrayList",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "ArrayList"
|
||||
},
|
||||
{
|
||||
"content": "Gee.HashMap<${1:K},${2:V}>($0);",
|
||||
"name": "Gee.HashMap",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "HashMap"
|
||||
},
|
||||
{
|
||||
"content": "Gee.HashSet<${1:G}>($0);",
|
||||
"name": "Gee.HashSet",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "HashSet"
|
||||
},
|
||||
{
|
||||
"content": "if ($1) {\n\t$0\n}",
|
||||
"name": "if",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "if"
|
||||
},
|
||||
{
|
||||
"content": "interface ${1:InterfaceName}{$2: : SuperInterface} {\n\t$0\n}",
|
||||
"name": "interface",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "interface"
|
||||
},
|
||||
{
|
||||
"content": "public static int main(string [] argv) {\n\t${0}\n\treturn 0;\n}",
|
||||
"name": "Main function",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "main"
|
||||
},
|
||||
{
|
||||
"content": "namespace $1 {\n\t$0\n}\n",
|
||||
"name": "namespace (ns)",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "ns"
|
||||
},
|
||||
{
|
||||
"content": "stdout.printf($0);",
|
||||
"name": "printf",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "printf"
|
||||
},
|
||||
{
|
||||
"content": "${1:public} ${2:Type} ${3:Name} {\n\tset {\n\t\t$0\n\t}\n\tget {\n\n\t}\n}",
|
||||
"name": "property (prop)",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "prop"
|
||||
},
|
||||
{
|
||||
"content": "${1:public} ${2:Type} ${3:Name} {\n\tget {\n\t\t$0\n\t}\n}",
|
||||
"name": "read-only property (roprop)",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "roprop"
|
||||
},
|
||||
{
|
||||
"content": "@\"${1:\\$var}\"",
|
||||
"name": "String template (@)",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "@"
|
||||
},
|
||||
{
|
||||
"content": "struct ${1:StructName} {\n\t$0\n}",
|
||||
"name": "struct",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "struct"
|
||||
},
|
||||
{
|
||||
"content": "switch ($1) {\n\t$0\n}",
|
||||
"name": "switch",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "switch"
|
||||
},
|
||||
{
|
||||
"content": "try {\n\t$2\n} catch (${1:Error} e) {\n\t$0\n}",
|
||||
"name": "try/catch",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "try"
|
||||
},
|
||||
{
|
||||
"content": "\"\"\"$0\"\"\";",
|
||||
"name": "Verbatim string (\"\"\")",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "verbatim"
|
||||
},
|
||||
{
|
||||
"content": "while ($1) {\n\t$0\n}",
|
||||
"name": "while",
|
||||
"scope": "vala",
|
||||
"tabTrigger": "while"
|
||||
}
|
||||
];
|
||||
exports.scope = "";
|
||||
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue