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:
Karl Tauber
2021-08-27 22:32:59 +02:00
parent cd20f4086b
commit a6d318a197
2 changed files with 29 additions and 1 deletions

View File

@@ -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 );

View File

@@ -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 );