Get Key and value from a properties file

I am having the below code for CompletionProvider for giving suggestions in a properties file.

 

protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) {
PsiElement element = completionParameters.getPosition();

if (PropertyValueImpl.class.isInstance(element)) {
System.out.println("Value : " + truncateIdeaDummyIdentifier(element));
} else if (PropertyKeyImpl.class.isInstance(element)) {
System.out.println("Key : " + truncateIdeaDummyIdentifier(element));
}
}

I am able to get a match when user tries for completion in a key. I get the PropertyKeyImpl.class match. But I could never match or get the value element for a property.

How should I verify if the element is a key or a value in a property file?

 

0
3 comments

Is your contributor called at all inside property value?

0
Avatar
Permanently deleted user

No. I am getting the hit for value matches.. But I get a hit for keys.

 

When I enter a text and presee "CONTROL + SPACE", i get the key value printed as expected. But after I enter "=" symbol and try it does not show the value.

0

Try adding order="first" to your completion contributor declaration in plugin.xml

0

Please sign in to leave a comment.