use of com.intellij.lang.properties.psi.codeStyle.PropertiesCodeStyleSettings in project intellij-community by JetBrains.
the class WrongPropertyKeyValueDelimiterInspection method buildVisitor.
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
if (!(holder.getFile() instanceof PropertiesFileImpl)) {
return PsiElementVisitor.EMPTY_VISITOR;
}
final PropertiesCodeStyleSettings codeStyleSettings = PropertiesCodeStyleSettings.getInstance(holder.getProject());
final char codeStyleKeyValueDelimiter = codeStyleSettings.getDelimiter();
return new PsiElementVisitor() {
@Override
public void visitElement(PsiElement element) {
if (element instanceof PropertyImpl) {
final char delimiter = ((PropertyImpl) element).getKeyValueDelimiter();
if (delimiter != codeStyleKeyValueDelimiter) {
holder.registerProblem(element, PropertiesBundle.message("wrong.property.key.value.delimiter.inspection.display.name"), new ReplaceKeyValueDelimiterQuickFix(element));
}
}
}
};
}
use of com.intellij.lang.properties.psi.codeStyle.PropertiesCodeStyleSettings in project intellij-community by JetBrains.
the class PropertiesFileTest method testNonDefaultKeyValueDelimiter.
public void testNonDefaultKeyValueDelimiter() {
final PropertiesCodeStyleSettings codeStyleSettings = PropertiesCodeStyleSettings.getInstance(getProject());
codeStyleSettings.KEY_VALUE_DELIMITER_CODE = 1;
final PropertyImpl property = (PropertyImpl) PropertiesElementFactory.createProperty(getProject(), "xxx", "yyy", null);
final char delimiter = property.getKeyValueDelimiter();
assertEquals(':', delimiter);
assertEquals("xxx:yyy", property.getPsiElement().getText());
codeStyleSettings.KEY_VALUE_DELIMITER_CODE = 0;
}
Aggregations