mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-07 22:40:53 +03:00
Theme Editor: fixed missing keys (e.g. Button.foreground) in reference auto-completion, which are defined as wildcards or have some prefix
This commit is contained in:
@@ -361,8 +361,20 @@ class FlatCompletionProvider
|
||||
|
||||
completions.clear();
|
||||
for( String key : keys ) {
|
||||
if( key.startsWith( "*." ) || key.startsWith( "[" ) )
|
||||
if( key.startsWith( "[" ) ) {
|
||||
// remove prefix
|
||||
int closeIndex = key.indexOf( ']' );
|
||||
if( closeIndex < 0 )
|
||||
continue;
|
||||
key = key.substring( closeIndex + 1 );
|
||||
}
|
||||
|
||||
if( key.startsWith( "*." ) ) {
|
||||
// resolve wildcard
|
||||
for( String k : FlatThemePropertiesSupport.getKeysForWildcard( key ) )
|
||||
completions.add( new BasicCompletion( this, "$".concat( k ) ) );
|
||||
continue;
|
||||
}
|
||||
|
||||
if( !key.startsWith( "@" ) )
|
||||
key = "$".concat( key );
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.awt.Color;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
@@ -236,6 +237,21 @@ class FlatThemePropertiesSupport
|
||||
allKeysCache = null;
|
||||
}
|
||||
|
||||
static Set<String> getKeysForWildcard( String key ) {
|
||||
if( !key.startsWith( "*." ) )
|
||||
return Collections.emptySet();
|
||||
|
||||
loadKeysAllowedForWildcard();
|
||||
|
||||
String suffix = key.substring( 1 );
|
||||
Set<String> result = new HashSet<>();
|
||||
for( String k : wildcardKeys ) {
|
||||
if( k.endsWith( suffix ) )
|
||||
result.add( k );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static boolean isKeyAllowedForWildcard( String key ) {
|
||||
loadKeysAllowedForWildcard();
|
||||
return wildcardKeys.contains( key );
|
||||
|
||||
Reference in New Issue
Block a user