Showing custom roperties Key and Values in properties file

I have a properties file named plugin.properties.

i have a pre-defined list of property keys and valid values for each key. When the user edits the plugin.properties file, the editor should show all possilbe keys and values as suggestion.

What is this feature called and how should I implement it? I don't want this to be done as a new custom editor. I am okay with exsiting properties editor.

2 comments
Comment actions Permalink

Plz let me know if any info is required on this.

0
Comment actions Permalink

For the completion part, register a completion contributor for the Properties language and add completion providers for keys and values. Here's an example

public class MyCompletionContributor extends CompletionContributor {

public MyCompletionContributor() {
extend(
CompletionType.BASIC,
PlatformPatterns.psiElement(PropertiesTokenTypes.KEY_CHARACTERS),
new MyCompletionProvider());
}
}

If you want to check validity of keys and values, I suggest to use an Annotator.

0

Please sign in to leave a comment.