mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 22:10:54 +03:00
Theme Editor: fixed mark occurrences for property references (starting with '$') and property references in function parameters
This commit is contained in:
@@ -97,6 +97,7 @@ public class FlatThemeTokenMaker
|
||||
|
||||
int currentTokenStart = start;
|
||||
int currentTokenType = Token.NULL;
|
||||
int parenthesisLevel = 0;
|
||||
|
||||
for( int i = start; i <= end; i++ ) {
|
||||
int newTokenType;
|
||||
@@ -119,21 +120,36 @@ public class FlatThemeTokenMaker
|
||||
if( currentTokenType == Token.NULL )
|
||||
currentTokenType = newTokenType;
|
||||
else if( newTokenType != currentTokenType ) {
|
||||
addTokenImpl( array, currentTokenStart, i - 1, currentTokenType, newStartOffset + currentTokenStart );
|
||||
addTokenImpl( array, currentTokenStart, i - 1, currentTokenType, newStartOffset + currentTokenStart, parenthesisLevel );
|
||||
currentTokenType = newTokenType;
|
||||
currentTokenStart = i;
|
||||
}
|
||||
|
||||
if( ch == '(' )
|
||||
parenthesisLevel++;
|
||||
else if( ch == ')' )
|
||||
parenthesisLevel--;
|
||||
}
|
||||
|
||||
if( currentTokenType != Token.NULL )
|
||||
addTokenImpl( array, currentTokenStart, end, currentTokenType, newStartOffset + currentTokenStart );
|
||||
addTokenImpl( array, currentTokenStart, end, currentTokenType, newStartOffset + currentTokenStart, parenthesisLevel );
|
||||
}
|
||||
|
||||
private void addTokenImpl( char[] array, int start, int end, int tokenType, int startOffset ) {
|
||||
if( tokenType == TOKEN_STRING ) {
|
||||
private void addTokenImpl( char[] array, int start, int end, int tokenType, int startOffset, int parenthesisLevel ) {
|
||||
if( tokenType == TOKEN_PROPERTY && array[start] == '$' ) {
|
||||
// separate '$' from property token for mark occurrences to work
|
||||
super.addToken( array, start, start, TokenTypes.OPERATOR, startOffset, false );
|
||||
start++;
|
||||
startOffset++;
|
||||
} else if( tokenType == TOKEN_STRING ) {
|
||||
// check for reserved words, functions, etc
|
||||
int type = tokenMap.get( array, start, end );
|
||||
if( type != -1 )
|
||||
tokenType = type;
|
||||
else if( parenthesisLevel > 0 ) {
|
||||
// assume property reference if in function parameters
|
||||
tokenType = TOKEN_PROPERTY;
|
||||
}
|
||||
}
|
||||
|
||||
// debugOutputToken( array, start, end, tokenType );
|
||||
|
||||
Reference in New Issue
Block a user