Skip to content

Commit

Permalink
fix #55
Browse files Browse the repository at this point in the history
wrap type with parentheses
  • Loading branch information
tangzx committed Sep 25, 2017
1 parent fc7fe00 commit a44a43f
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 9 deletions.
22 changes: 17 additions & 5 deletions gen/com/tang/intellij/lua/comment/parser/LuaDocParser.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions gen/com/tang/intellij/lua/comment/psi/LuaDocParTy.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions gen/com/tang/intellij/lua/comment/psi/LuaDocTypes.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions gen/com/tang/intellij/lua/comment/psi/LuaDocVisitor.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions gen/com/tang/intellij/lua/comment/psi/impl/LuaDocParTyImpl.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,8 @@ fun getReturnType(luaDocFunctionTy: LuaDocFunctionTy): ITy {

fun getType(luaDocGenericTy: LuaDocGenericTy): ITy {
return TyDocGeneric(luaDocGenericTy)
}

fun getType(luaDocParTy: LuaDocParTy): ITy {
return luaDocParTy.ty?.getType() ?: Ty.UNKNOWN
}
6 changes: 5 additions & 1 deletion src/main/java/com/tang/intellij/lua/doc.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private after_dash ::= doc_item | STRING { recoverWhile=after_dash_recover }
private after_dash_recover ::= !(DASHES)
private doc_item ::= '@' (param_def | return_def | class_def | field_def | type_def | lan_def | overload_def | tag_def)

ty ::= function_ty | generic_ty | arr_ty | general_ty {
ty ::= function_ty | generic_ty | arr_ty | general_ty | par_ty {
implements = ['com.tang.intellij.lua.comment.psi.LuaDocType']
}

Expand All @@ -81,6 +81,10 @@ arr_ty ::= ty '[]' {
general_ty ::= class_name_ref {
methods = [getType]
}
par_ty ::= '(' ty ')' {
pin = 1
methods = [getType]
}

private generic_param_list ::= (ty ',')* ty
generic_ty ::= ty '<' generic_param_list '>' {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class LuaCommentCompletionContributor : CompletionContributor() {
init {
extend(CompletionType.BASIC, SHOW_DOC_TAG, object : CompletionProvider<CompletionParameters>() {
override fun addCompletions(completionParameters: CompletionParameters, processingContext: ProcessingContext, completionResultSet: CompletionResultSet) {
val set = LuaSyntaxHighlighter.DOC_KEYWORD_TOKENS
val set = LuaSyntaxHighlighter.DOC_TAG_TOKENS
for (type in set.types) {
completionResultSet.addElement(LookupElementBuilder.create(type).withIcon(LuaIcons.ANNOTATION))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class LuaSyntaxHighlighter extends SyntaxHighlighterBase {
LuaTypes.NIL,
LuaTypes.TRUE
);
public static final TokenSet DOC_KEYWORD_TOKENS = TokenSet.create(
public static final TokenSet DOC_TAG_TOKENS = TokenSet.create(
LuaDocTypes.TAG_PARAM,
LuaDocTypes.TAG_RETURN,
LuaDocTypes.CLASS,
Expand All @@ -77,6 +77,9 @@ public class LuaSyntaxHighlighter extends SyntaxHighlighterBase {
LuaDocTypes.LANGUAGE,
LuaDocTypes.OVERLOAD
);
public static final TokenSet DOC_KEYWORD_TOKENS = TokenSet.create(
LuaDocTypes.FUN
);

private static final Map<IElementType, TextAttributesKey> ourMap1;
private static final Map<IElementType, TextAttributesKey> ourMap2;
Expand All @@ -99,8 +102,12 @@ public class LuaSyntaxHighlighter extends SyntaxHighlighterBase {

fillMap(ourMap1, LuaHighlightingData.LINE_COMMENT, LuaTypes.SHORT_COMMENT, LuaTypes.BLOCK_COMMENT);
fillMap(ourMap1, LuaHighlightingData.DOC_COMMENT, LuaTypes.REGION, LuaTypes.ENDREGION);
fillMap(ourMap1, DOC_KEYWORD_TOKENS, LuaHighlightingData.DOC_COMMENT_TAG);
fillMap(ourMap1, DOC_TAG_TOKENS, LuaHighlightingData.DOC_COMMENT_TAG);
fillMap(ourMap1, LuaHighlightingData.DOC_COMMENT_TAG, LuaDocTypes.TAG_NAME);
fillMap(ourMap1, DOC_KEYWORD_TOKENS, LuaHighlightingData.KEYWORD);
fillMap(ourMap1, LuaHighlightingData.BRACKETS, LuaDocTypes.ARR);
fillMap(ourMap1, LuaHighlightingData.PARENTHESES, LuaDocTypes.LPAREN, LuaDocTypes.RPAREN);

//primitive types
fillMap(ourMap1, LuaHighlightingData.NUMBER, LuaTypes.NUMBER);
fillMap(ourMap1, LuaHighlightingData.STRING, LuaTypes.STRING);
Expand Down

0 comments on commit a44a43f

Please sign in to comment.