use of com.intellij.lang.properties.psi.impl.PropertiesFileImpl 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.impl.PropertiesFileImpl in project intellij-community by JetBrains.
the class AlphaUnsortedPropertiesFileInspection method buildVisitor.
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
return new PsiElementVisitor() {
@Override
public void visitFile(PsiFile file) {
final PropertiesFile propertiesFile = PropertiesImplUtil.getPropertiesFile(file);
if (!(propertiesFile instanceof PropertiesFileImpl)) {
return;
}
for (AlphaUnsortedPropertiesFileInspectionSuppressor filter : AlphaUnsortedPropertiesFileInspectionSuppressor.EP_NAME.getExtensions()) {
if (filter.suppressInspectionFor(propertiesFile)) {
return;
}
}
final ResourceBundle resourceBundle = propertiesFile.getResourceBundle();
final String resourceBundleBaseName = resourceBundle.getBaseName();
if (!isResourceBundleAlphaSortedExceptOneFile(resourceBundle, propertiesFile)) {
final List<PropertiesFile> allFiles = resourceBundle.getPropertiesFiles();
holder.registerProblem(file, String.format(MESSAGE_TEMPLATE_WHOLE_RESOURCE_BUNDLE, resourceBundleBaseName), ProblemHighlightType.INFO, new PropertiesSorterQuickFix(true, allFiles.toArray(new PropertiesFile[allFiles.size()])));
return;
}
if (!propertiesFile.isAlphaSorted()) {
holder.registerProblem(file, "Properties file is alphabetically unsorted", ProblemHighlightType.INFO, new PropertiesSorterQuickFix(true, propertiesFile));
}
}
};
}
Aggregations