use of com.intellij.lang.properties.psi.impl.PropertyImpl 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;
}
use of com.intellij.lang.properties.psi.impl.PropertyImpl 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.PropertyImpl in project azure-tools-for-java by Microsoft.
the class SpringPropertiesLineMarkerProvider method getLineMarkerInfo.
@Override
@Nullable
public LineMarkerInfo<PsiElement> getLineMarkerInfo(@Nonnull PsiElement element) {
if (!(element instanceof PropertyImpl)) {
return null;
}
final String propKey = ((PropertyImpl) element).getKey();
final String propVal = ((PropertyImpl) element).getValue();
final Module module = ModuleUtil.findModuleForFile(element.getContainingFile().getVirtualFile(), element.getProject());
if (Objects.isNull(module)) {
return null;
}
final ImmutablePair<String, String> keyProp = new ImmutablePair<>(propKey, propVal);
final List<Connection<?, ?>> connections = element.getProject().getService(ConnectionManager.class).getConnectionsByConsumerId(module.getName());
for (final Connection<?, ?> connection : connections) {
final List<Pair<String, String>> properties = SpringSupported.getProperties(connection);
if (!properties.isEmpty() && properties.get(0).equals(keyProp)) {
final Resource<?> r = connection.getResource();
return new LineMarkerInfo<>(element, element.getTextRange(), AzureIcons.getIcon("/icons/connector/connect.svg"), element2 -> String.format("%s (%s)", r.getName(), r.getDefinition().getTitle()), new SpringDatasourceNavigationHandler(r), GutterIconRenderer.Alignment.LEFT, () -> "");
}
}
return null;
}
use of com.intellij.lang.properties.psi.impl.PropertyImpl in project intellij-community by JetBrains.
the class PropertiesAnnotator method annotate.
public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
if (!(element instanceof IProperty))
return;
final Property property = (Property) element;
PropertiesFile propertiesFile = property.getPropertiesFile();
Collection<IProperty> others = propertiesFile.findPropertiesByKey(property.getUnescapedKey());
ASTNode keyNode = ((PropertyImpl) property).getKeyNode();
if (others.size() != 1) {
Annotation annotation = holder.createErrorAnnotation(keyNode, PropertiesBundle.message("duplicate.property.key.error.message"));
annotation.registerFix(PropertiesQuickFixFactory.getInstance().createRemovePropertyFix(property));
}
highlightTokens(property, keyNode, holder, new PropertiesHighlighter());
ASTNode valueNode = ((PropertyImpl) property).getValueNode();
if (valueNode != null) {
highlightTokens(property, valueNode, holder, new PropertiesValueHighlighter());
}
}
use of com.intellij.lang.properties.psi.impl.PropertyImpl in project intellij-community by JetBrains.
the class TrailingSpacesInPropertyInspection method checkFile.
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull final InspectionManager manager, final boolean isOnTheFly) {
if (!(file instanceof PropertiesFile))
return null;
final List<IProperty> properties = ((PropertiesFile) file).getProperties();
final List<ProblemDescriptor> descriptors = new SmartList<>();
for (IProperty property : properties) {
ProgressManager.checkCanceled();
final PropertyImpl propertyImpl = (PropertyImpl) property;
for (ASTNode node : ContainerUtil.ar(propertyImpl.getKeyNode(), propertyImpl.getValueNode())) {
if (node != null) {
PsiElement key = node.getPsi();
TextRange textRange = getTrailingSpaces(key, myIgnoreVisibleSpaces);
if (textRange != null) {
descriptors.add(manager.createProblemDescriptor(key, textRange, "Trailing spaces", ProblemHighlightType.GENERIC_ERROR_OR_WARNING, true, new RemoveTrailingSpacesFix(myIgnoreVisibleSpaces)));
}
}
}
}
return descriptors.toArray(new ProblemDescriptor[descriptors.size()]);
}
Aggregations