diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatCompletionProvider.java b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatCompletionProvider.java index a5796dc3..6d83e9f8 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatCompletionProvider.java +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatCompletionProvider.java @@ -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 ); diff --git a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePropertiesSupport.java b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePropertiesSupport.java index 9566c6b4..61cff44c 100644 --- a/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePropertiesSupport.java +++ b/flatlaf-theme-editor/src/main/java/com/formdev/flatlaf/themeeditor/FlatThemePropertiesSupport.java @@ -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 getKeysForWildcard( String key ) { + if( !key.startsWith( "*." ) ) + return Collections.emptySet(); + + loadKeysAllowedForWildcard(); + + String suffix = key.substring( 1 ); + Set 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 );