[TxMt] Java Syntax
Soryu
Soryu at serenity.de
Wed Nov 2 22:32:05 UTC 2005
Because it came up yesterday and I already have the bad reputation to
like Java, here it goes:
A somewhat better Java Syntax than the included one:
Features:
- Better colouring (due to the old syntax being outdated)
- Goto Symbol popup working
Bugs:
- Keep the closing parentheses and the opening brace ) { of a method
declaration on the same line, otherwise the end pattern won't match
- More to come soon ;)
Soryu
{ scopeName = 'source.java';
comment = '
Credits to Brian Lalor, who wrote the Java syntax included in TM.
I might have adapted some of his syntax.
Soryu
Comments:
• I excluded overridden anonymous Constructors from
"declaration.function.method.java", so they won''t show up in the
Goto Symbol popup to reduce clutter a little.
';
fileTypes = ( 'java' );
foldingStartMarker = '/\*\*|\{\s*$';
foldingStopMarker = '\*\*/|^\s*\}';
patterns = (
{ name = 'comment.line.double-slash.java';
begin = '//';
end = '$';
swallow = '\\\s*\n';
},
{ name = 'comment.documentation.java';
begin = '/\*\*';
end = '\*/';
patterns = (
{ match = '\*\s*(@)(param)\s*([a-z][a-zA-Z0-9_]+)\s*';
captures =
{ 1 = { name = 'keyword.other.documentation.control'; };
2 = { name = 'keyword.other.documentation.params.java'; };
3 = { name = 'keyword.other.documentation.value.java'; };
};
},
{ match = '\*\s*(@)([a-zA-Z0-9_-]+)\s*';
captures =
{ 1 = { name = 'keyword.embedded-docs.control.java'; };
2 = { name = 'keyword.embedded-docs.params.java'; };
};
},
);
},
{ name = 'comment.block.java';
begin = '/\*';
end = '\*/';
},
{ name = 'meta.package.java';
match = '(package)\s+([^ ;]+?)\s*;';
captures =
{ 1 = { name = 'keyword.other.java'; };
2 = { name = 'entity.name.package.java'; };
};
},
{ name = 'meta.import.java';
match = '(import)\s+([^ ;]+?);';
captures =
{ 1 = { name = 'keyword.other.java'; };
2 = { name = 'entity.name.class.java'; };
};
},
{ name = 'declaration.class.java';
match = '\b(?<=class|interface|enum)\s+(\w+)';
captures = { 1 = { name = 'entity.name.class.java'; }; };
},
{ name = 'other.inheritance.class.java';
comment = 'TODO: implements has multiple Parameters, Extends does
not';
match = '\b(?<=extends|implements)\s+(\w+)';
captures = { 1 = { name = 'entity.name.class.java'; }; };
},
{ name = 'declaration.function.method.java';
begin = '\b(?<!new)\s+(\w+)\s*\(';
end = '\)\s*{';
captures = { 1 = { name = 'entity.name.function.java'; }; };
patterns = ( { include = '#keywords'; } );
},
{ name = 'constant.numeric.java';
comment = 'stolen from c syntax without looking very much at it';
match = '\b((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|
E)(\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\b';
},
{ name = 'keyword.flow.java';
match = '\b(if|else|while|for|return|continue|break|switch|do|goto|
case|try|catch|finally|throw)\b';
},
{ name = 'keyword.other.simple-types.java';
match = '\b(int|char|float|long|double|boolean|byte|short)\b';
},
{ name = 'keyword.operator.comparison.java';
match = '(==|!=|<=|>=|<>|<|>)';
},
{ name = 'keyword.operator.increment-decrement.java';
match = '(\-\-|\+\+)';
},
{ name = 'keyword.operator.arithmetic.java';
match = '(\-|\+|\*|\/|%)';
},
{ name = 'keyword.operator.logical.java';
match = '(!|&&|\|\|)';
},
{ name = 'storage.modifier.java';
match = '\b(private|public|protected|static|transient|final|
abstract|native|threadsafe|synchronized|volatile|strictfp)\b';
},
{ name = 'storage.type.java';
match = '\b(class|interface|enum)\b';
},
{ include = '#string-double-quoted'; },
{ include = '#keywords'; },
);
repository =
{ keywords =
{ name = 'keyword.other.java';
match = '\b(new|abstract|assert|default|synchronized|private|
protected|public|throws|enum|instanceof|transient|final|interface|
static|void|null|class|finally|strictfp|volatile|const|native|import|
package|extends|implements|this|super|true|false|if|else|while|for|
return|continue|break|switch|do|goto|case|try|catch|finally|throw|int|
char|float|long|double|boolean|byte|short)\b';
};
string-double-quoted =
{ name = 'string.quoted.double.java';
begin = '"';
end = '"';
patterns = (
{ name = 'constant.character.escaped.java';
match = '\\.';
}
);
};
};
}
More information about the textmate
mailing list