Skip to content

Commit

Permalink
Highlight function/method definition in Java, Kotlin, Dart, Groovy.
Browse files Browse the repository at this point in the history
Rename style name "Function Define" into "Function Definition".
  • Loading branch information
zufuliu committed Sep 1, 2021
1 parent ac64d7d commit 9948156
Show file tree
Hide file tree
Showing 35 changed files with 87 additions and 56 deletions.
2 changes: 1 addition & 1 deletion metapath/src/Helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -2224,7 +2224,7 @@ static LRESULT CALLBACK OpenSaveFileDlgSubProc(HWND hwnd, UINT umsg, WPARAM wPar
case WM_COMMAND:
switch (wParam) {
case IDOK: {
TCHAR szPath[MAX_PATH];
WCHAR szPath[MAX_PATH];
HWND hCmbPath = GetDlgItem(hwnd, cmb13); // cmb13: dlgs.h
GetWindowText(hCmbPath, szPath, MAX_PATH);
if (PathFixBackslashes(szPath)) {
Expand Down
22 changes: 13 additions & 9 deletions scintilla/include/SciLexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
#define SCE_PY_WORD 6
#define SCE_PY_WORD2 7
#define SCE_PY_CLASS 8
#define SCE_PY_FUNCTION_DEFINE 9
#define SCE_PY_FUNCTION_DEFINITION 9
#define SCE_PY_OPERATOR 10
#define SCE_PY_OPERATOR2 11
#define SCE_PY_IDENTIFIER 12
Expand Down Expand Up @@ -1020,7 +1020,7 @@
#define SCE_RUST_ATTRIBUTE 28
#define SCE_RUST_CONSTANT 29
#define SCE_RUST_LINE_CONTINUATION 30
#define SCE_RUST_FUNCTION_DEFINE 31
#define SCE_RUST_FUNCTION_DEFINITION 31
#define SCE_JSON_DEFAULT 0
#define SCE_JSON_OPERATOR 1
#define SCE_JSON_NUMBER 2
Expand Down Expand Up @@ -1078,6 +1078,7 @@
#define SCE_KOTLIN_INTERFACE 23
#define SCE_KOTLIN_ENUM 24
#define SCE_KOTLIN_FUNCTION 25
#define SCE_KOTLIN_FUNCTION_DEFINITION 26
#define SCE_JULIA_DEFAULT 0
#define SCE_JULIA_COMMENTLINE 1
#define SCE_JULIA_COMMENTBLOCK 2
Expand Down Expand Up @@ -1111,7 +1112,7 @@
#define SCE_JULIA_TYPE 30
#define SCE_JULIA_CONSTANT 31
#define SCE_JULIA_BASIC_FUNCTION 40
#define SCE_JULIA_FUNCTION_DEFINE 41
#define SCE_JULIA_FUNCTION_DEFINITION 41
#define SCE_LLVM_DEFAULT 0
#define SCE_LLVM_COMMENTLINE 1
#define SCE_LLVM_TASKMARKER 2
Expand Down Expand Up @@ -1201,7 +1202,7 @@
#define SCE_GO_INTERFACE 20
#define SCE_GO_CONSTANT 21
#define SCE_GO_FUNCTION 22
#define SCE_GO_FUNCTION_DEFINE 23
#define SCE_GO_FUNCTION_DEFINITION 23
#define SCE_GO_FORMAT_SPECIFIER 24
#define SCE_DART_DEFAULT 0
#define SCE_DART_COMMENTLINE 1
Expand Down Expand Up @@ -1234,6 +1235,7 @@
#define SCE_DART_WORD2 30
#define SCE_DART_CLASS 31
#define SCE_DART_ENUM 40
#define SCE_DART_FUNCTION_DEFINITION 41
#define SCE_SWIFT_DEFAULT 0
#define SCE_SWIFT_COMMENTLINE 1
#define SCE_SWIFT_COMMENTLINEDOC 2
Expand Down Expand Up @@ -1264,7 +1266,7 @@
#define SCE_SWIFT_STRUCT 27
#define SCE_SWIFT_PROTOCOL 28
#define SCE_SWIFT_ENUM 29
#define SCE_SWIFT_FUNCTION_DEFINE 30
#define SCE_SWIFT_FUNCTION_DEFINITION 30
#define SCE_JS_DEFAULT 0
#define SCE_JS_COMMENTLINE 1
#define SCE_JS_COMMENTLINEDOC 2
Expand Down Expand Up @@ -1292,7 +1294,7 @@
#define SCE_JSX_ATTRIBUTE 24
#define SCE_JSX_ATTRIBUTE_AT 25
#define SCE_JS_DECORATOR 26
#define SCE_JS_FUNCTION_DEFINE 27
#define SCE_JS_FUNCTION_DEFINITION 27
#define SCE_JS_FUNCTION 28
#define SCE_JS_WORD 29
#define SCE_JS_WORD2 30
Expand Down Expand Up @@ -1330,6 +1332,7 @@
#define SCE_JAVA_FUNCTION 25
#define SCE_JAVA_CONSTANT 26
#define SCE_JAVA_LABEL 27
#define SCE_JAVA_FUNCTION_DEFINITION 28
#define SCE_HAXE_DEFAULT 0
#define SCE_HAXE_COMMENTLINE 1
#define SCE_HAXE_COMMENTLINEDOC 2
Expand All @@ -1355,7 +1358,7 @@
#define SCE_HAXE_INTERFACE 24
#define SCE_HAXE_ENUM 25
#define SCE_HAXE_CONSTANT 26
#define SCE_HAXE_FUNCTION_DEFINE 27
#define SCE_HAXE_FUNCTION_DEFINITION 27
#define SCE_HAXE_FUNCTION 28
#define SCE_GROOVY_DEFAULT 0
#define SCE_GROOVY_COMMENTLINE 1
Expand Down Expand Up @@ -1395,7 +1398,8 @@
#define SCE_GROOVY_ENUM 43
#define SCE_GROOVY_CONSTANT 44
#define SCE_GROOVY_FUNCTION 45
#define SCE_GROOVY_LABEL 46
#define SCE_GROOVY_FUNCTION_DEFINITION 46
#define SCE_GROOVY_LABEL 47
#define SCE_JAM_DEFAULT 0
#define SCE_JAM_COMMENTLINE 1
#define SCE_JAM_COMMENTBLOCK 2
Expand Down Expand Up @@ -1426,6 +1430,6 @@
#define SCE_AWK_WORD 12
#define SCE_AWK_BUILTIN_VARIABLE 13
#define SCE_AWK_BUILTIN_FUNCTION 14
#define SCE_AWK_FUNCTION_DEFINE 15
#define SCE_AWK_FUNCTION_DEFINITION 15
#define SCE_AWK_FUNCTION 16
/* --Autogenerated -- end of section automatically generated from SciLexer.iface */
22 changes: 13 additions & 9 deletions scintilla/include/SciLexer.iface
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ val SCE_PY_NUMBER=5
val SCE_PY_WORD=6
val SCE_PY_WORD2=7
val SCE_PY_CLASS=8
val SCE_PY_FUNCTION_DEFINE=9
val SCE_PY_FUNCTION_DEFINITION=9
val SCE_PY_OPERATOR=10
val SCE_PY_OPERATOR2=11
val SCE_PY_IDENTIFIER=12
Expand Down Expand Up @@ -2245,7 +2245,7 @@ val SCE_RUST_VARIABLE=27
val SCE_RUST_ATTRIBUTE=28
val SCE_RUST_CONSTANT=29
val SCE_RUST_LINE_CONTINUATION=30
val SCE_RUST_FUNCTION_DEFINE=31
val SCE_RUST_FUNCTION_DEFINITION=31
# Lexical states for SCLEX_DMAP
#lex DMAP=SCLEX_DMAP SCE_DMAP_
#val SCE_DMAP_DEFAULT=0
Expand Down Expand Up @@ -2537,6 +2537,7 @@ val SCE_KOTLIN_CLASS=22
val SCE_KOTLIN_INTERFACE=23
val SCE_KOTLIN_ENUM=24
val SCE_KOTLIN_FUNCTION=25
val SCE_KOTLIN_FUNCTION_DEFINITION=26
# Lexical states for SCLEX_JULIA
lex Julia=SCLEX_JULIA SCE_JULIA_
val SCE_JULIA_DEFAULT=0
Expand Down Expand Up @@ -2572,7 +2573,7 @@ val SCE_JULIA_WORD_DEMOTED=29
val SCE_JULIA_TYPE=30
val SCE_JULIA_CONSTANT=31
val SCE_JULIA_BASIC_FUNCTION=40
val SCE_JULIA_FUNCTION_DEFINE=41
val SCE_JULIA_FUNCTION_DEFINITION=41
# Lexical states for SCLEX_LLVM
lex LLVM=SCLEX_LLVM SCE_LLVM_
val SCE_LLVM_DEFAULT=0
Expand Down Expand Up @@ -2672,7 +2673,7 @@ val SCE_GO_STRUCT=19
val SCE_GO_INTERFACE=20
val SCE_GO_CONSTANT=21
val SCE_GO_FUNCTION=22
val SCE_GO_FUNCTION_DEFINE=23
val SCE_GO_FUNCTION_DEFINITION=23
val SCE_GO_FORMAT_SPECIFIER=24
# Lexical states for SCLEX_DART
lex Dart=SCLEX_DART SCE_DART_
Expand Down Expand Up @@ -2707,6 +2708,7 @@ val SCE_DART_WORD=29
val SCE_DART_WORD2=30
val SCE_DART_CLASS=31
val SCE_DART_ENUM=40
val SCE_DART_FUNCTION_DEFINITION=41
# Lexical states for SCLEX_SWIFT
lex Swift=SCLEX_SWIFT SCE_SWIFT_
val SCE_SWIFT_DEFAULT=0
Expand Down Expand Up @@ -2739,7 +2741,7 @@ val SCE_SWIFT_CLASS=26
val SCE_SWIFT_STRUCT=27
val SCE_SWIFT_PROTOCOL=28
val SCE_SWIFT_ENUM=29
val SCE_SWIFT_FUNCTION_DEFINE=30
val SCE_SWIFT_FUNCTION_DEFINITION=30
# Lexical states for SCLEX_JAVASCRIPT
lex JavaScript=SCLEX_JAVASCRIPT SCE_JS_ SCE_JSX_
val SCE_JS_DEFAULT=0
Expand Down Expand Up @@ -2769,7 +2771,7 @@ val SCE_JSX_TAG=23
val SCE_JSX_ATTRIBUTE=24
val SCE_JSX_ATTRIBUTE_AT=25
val SCE_JS_DECORATOR=26
val SCE_JS_FUNCTION_DEFINE=27
val SCE_JS_FUNCTION_DEFINITION=27
val SCE_JS_FUNCTION=28
val SCE_JS_WORD=29
val SCE_JS_WORD2=30
Expand Down Expand Up @@ -2809,6 +2811,7 @@ val SCE_JAVA_ENUM=24
val SCE_JAVA_FUNCTION=25
val SCE_JAVA_CONSTANT=26
val SCE_JAVA_LABEL=27
val SCE_JAVA_FUNCTION_DEFINITION=28
# Lexical states for SCLEX_HAXE
lex Haxe=SCLEX_HAXE SCE_HAXE_
val SCE_HAXE_DEFAULT=0
Expand Down Expand Up @@ -2836,7 +2839,7 @@ val SCE_HAXE_CLASS=23
val SCE_HAXE_INTERFACE=24
val SCE_HAXE_ENUM=25
val SCE_HAXE_CONSTANT=26
val SCE_HAXE_FUNCTION_DEFINE=27
val SCE_HAXE_FUNCTION_DEFINITION=27
val SCE_HAXE_FUNCTION=28
# Lexical states for SCLEX_GROOVY
lex Groovy=SCLEX_GROOVY SCE_GROOVY_
Expand Down Expand Up @@ -2878,7 +2881,8 @@ val SCE_GROOVY_TRAIT=42
val SCE_GROOVY_ENUM=43
val SCE_GROOVY_CONSTANT=44
val SCE_GROOVY_FUNCTION=45
val SCE_GROOVY_LABEL=46
val SCE_GROOVY_FUNCTION_DEFINITION=46
val SCE_GROOVY_LABEL=47
# Lexical states for SCLEX_JAM
lex Jam=SCLEX_JAM SCE_JAM_
val SCE_JAM_DEFAULT=0
Expand Down Expand Up @@ -2913,5 +2917,5 @@ val SCE_AWK_VARIABLE=11
val SCE_AWK_WORD=12
val SCE_AWK_BUILTIN_VARIABLE=13
val SCE_AWK_BUILTIN_FUNCTION=14
val SCE_AWK_FUNCTION_DEFINE=15
val SCE_AWK_FUNCTION_DEFINITION=15
val SCE_AWK_FUNCTION=16
4 changes: 2 additions & 2 deletions scintilla/lexers/LexAwk.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ void ColouriseAwkDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initSty
if (StrEqual(s, "@include")) {
lineStateLineType = AwkLineStateMaskInclude;
} else if (StrEqual(s, "function")) {
kwType = SCE_AWK_FUNCTION_DEFINE;
kwType = SCE_AWK_FUNCTION_DEFINITION;
}
}
} else if (keywordLists[1]->InList(s)) {
Expand All @@ -242,7 +242,7 @@ void ColouriseAwkDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initSty
} else {
const int chNext = sc.GetLineNextChar();
if (chNext == '(') {
sc.ChangeState((kwType == SCE_AWK_FUNCTION_DEFINE) ? SCE_AWK_FUNCTION_DEFINE : SCE_AWK_FUNCTION);
sc.ChangeState((kwType == SCE_AWK_FUNCTION_DEFINITION) ? kwType : SCE_AWK_FUNCTION);
}
}

Expand Down
10 changes: 7 additions & 3 deletions scintilla/lexers/LexDart.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ void ColouriseDartDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initSt

int visibleChars = 0;
int visibleCharsBefore = 0;
int chPrevNonWhite = 0;
EscapeSequence escSeq;

StyleContext sc(startPos, lengthDoc, initStyle, styler);
Expand Down Expand Up @@ -152,7 +153,7 @@ void ColouriseDartDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initSt
} else {
const int chNext = sc.GetDocNextChar(sc.ch == '?');
if (chNext == '(') {
sc.ChangeState(SCE_DART_FUNCTION);
sc.ChangeState(IsIdentifierCharEx(chBeforeIdentifier) ? SCE_DART_FUNCTION_DEFINITION : SCE_DART_FUNCTION);
} else if ((chBeforeIdentifier == '<' && (chNext == '>' || chNext == '<'))
|| IsIdentifierStartEx(chNext)) {
// type<type>
Expand Down Expand Up @@ -337,8 +338,8 @@ void ColouriseDartDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initSt
sc.SetState(SCE_DART_SYMBOL_OPERATOR);
}
} else if (IsIdentifierStartEx(sc.ch)) {
if (sc.chPrev != '.') {
chBeforeIdentifier = sc.chPrev;
if (chPrevNonWhite != '.') {
chBeforeIdentifier = chPrevNonWhite;
}
sc.SetState(SCE_DART_IDENTIFIER);
} else if (isoperator(sc.ch)) {
Expand All @@ -358,6 +359,9 @@ void ColouriseDartDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initSt

if (!isspacechar(sc.ch)) {
visibleChars++;
if (!IsSpaceEquiv(sc.state)) {
chPrevNonWhite = sc.ch;
}
}
if (sc.atLineEnd) {
int lineState = (commentLevel << 2) | lineStateLineType;
Expand Down
2 changes: 1 addition & 1 deletion scintilla/lexers/LexGo.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ void ColouriseGoDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyl
} else if (chNext == '(') {
if (funcState != GoFunction_None) {
funcState = GoFunction_Name;
sc.ChangeState(SCE_GO_FUNCTION_DEFINE);
sc.ChangeState(SCE_GO_FUNCTION_DEFINITION);
} else {
sc.ChangeState(SCE_GO_FUNCTION);
}
Expand Down
8 changes: 6 additions & 2 deletions scintilla/lexers/LexGroovy.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,11 @@ void ColouriseGroovyDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int init
} else if (chNext == '(' || IsADigit(chNext) || chNext == '\'' || chNext == '"') {
// property value
// method parameter
sc.ChangeState(SCE_GROOVY_FUNCTION);
if (chNext == '(' && IsIdentifierCharEx(chBeforeIdentifier)) {
sc.ChangeState(SCE_GROOVY_FUNCTION_DEFINITION);
} else {
sc.ChangeState(SCE_GROOVY_FUNCTION);
}
} else if (sc.Match('[', ']') || sc.Match('.', '&')
|| (sc.ch == '<' && (sc.chNext == '>' || sc.chNext == '?'))
|| (chBeforeIdentifier == '<' && (chNext == '>' || chNext == '<'))) {
Expand Down Expand Up @@ -485,7 +489,7 @@ void ColouriseGroovyDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int init
} else if (IsNumberStartEx(sc.chPrev, sc.ch, sc.chNext)) {
sc.SetState(SCE_GROOVY_NUMBER);
} else if (IsIdentifierStartEx(sc.ch)) {
chBefore = sc.chPrev;
chBefore = chPrevNonWhite;
if (chBefore != '.') {
chBeforeIdentifier = chBefore;
}
Expand Down
2 changes: 1 addition & 1 deletion scintilla/lexers/LexHaxe.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void ColouriseHaxeDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initSt
} else if (StrEqual(s, "enum")) {
kwType = SCE_HAXE_ENUM;
} else if (StrEqual(s, "function")) {
kwType = SCE_HAXE_FUNCTION_DEFINE;
kwType = SCE_HAXE_FUNCTION_DEFINITION;
}
if (kwType != SCE_HAXE_DEFAULT) {
const int chNext = sc.GetDocNextChar();
Expand Down
10 changes: 7 additions & 3 deletions scintilla/lexers/LexJava.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ void ColouriseJavaDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initSt

int visibleChars = 0;
int visibleCharsBefore = 0;
int chPrevNonWhite = 0;
DocTagState docTagState = DocTagState::None;
EscapeSequence escSeq;

Expand Down Expand Up @@ -247,7 +248,7 @@ void ColouriseJavaDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initSt
sc.ChangeState(SCE_JAVA_CLASS);
}
} else if (chNext == '(') {
sc.ChangeState(SCE_JAVA_FUNCTION);
sc.ChangeState(IsIdentifierCharEx(chBeforeIdentifier) ? SCE_JAVA_FUNCTION_DEFINITION : SCE_JAVA_FUNCTION);
} else if (sc.Match('[', ']')
|| (sc.ch == '<' && (sc.chNext == '>' || sc.chNext == '?'))
|| (chBeforeIdentifier == '<' && (chNext == '>' || chNext == '<'))
Expand Down Expand Up @@ -452,8 +453,8 @@ void ColouriseJavaDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initSt
} else if (IsNumberStart(sc.ch, sc.chNext)) {
sc.SetState(SCE_JAVA_NUMBER);
} else if (IsIdentifierStartEx(sc.ch) || sc.Match('@', 'i')) {
if (sc.chPrev != '.') {
chBeforeIdentifier = sc.chPrev;
if (chPrevNonWhite != '.') {
chBeforeIdentifier = chPrevNonWhite;
}
sc.SetState(SCE_JAVA_IDENTIFIER);
} else if (sc.ch == '@' && IsIdentifierStartEx(sc.chNext)) {
Expand All @@ -465,6 +466,9 @@ void ColouriseJavaDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initSt

if (!isspacechar(sc.ch)) {
visibleChars++;
if (!IsSpaceEquiv(sc.state)) {
chPrevNonWhite = sc.ch;
}
}
if (sc.atLineEnd) {
styler.SetLineState(sc.currentLine, lineStateLineType);
Expand Down
2 changes: 1 addition & 1 deletion scintilla/lexers/LexJavaScript.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ void ColouriseJsDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initStyl
if (StrEqualsAny(s, "class", "extends","new", "type", "as", "is")) {
kwType = SCE_JS_CLASS;
} else if (StrEqual(s, "function")) {
kwType = SCE_JS_FUNCTION_DEFINE;
kwType = SCE_JS_FUNCTION_DEFINITION;
} else if (StrEqualsAny(s, "interface", "implements")) {
kwType = SCE_JS_INTERFACE;
} else if (StrEqual(s, "enum")) {
Expand Down
4 changes: 2 additions & 2 deletions scintilla/lexers/LexJulia.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void ColouriseJuliaDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initS
} else if (StrEqual(s, "macro")) {
kwType = SCE_JULIA_MACRO;
} else if (StrEqual(s, "function")) {
kwType = SCE_JULIA_FUNCTION_DEFINE;
kwType = SCE_JULIA_FUNCTION_DEFINITION;
} else if (StrEqualsAny(s, "abstract", "primitive")) {
kwType = SCE_JULIA_WORD;
}
Expand All @@ -161,7 +161,7 @@ void ColouriseJuliaDoc(Sci_PositionU startPos, Sci_Position lengthDoc, int initS
sc.ChangeState(SCE_JULIA_BASIC_FUNCTION);
} else if (kwType != SCE_JULIA_DEFAULT && kwType != SCE_JULIA_WORD) {
sc.ChangeState(kwType);
if (kwType == SCE_JULIA_FUNCTION_DEFINE && sc.ch == '!') {
if (kwType == SCE_JULIA_FUNCTION_DEFINITION && sc.ch == '!') {
sc.Forward();
}
} else {
Expand Down
Loading

0 comments on commit 9948156

Please sign in to comment.