use of com.intellij.lang.properties.psi.Property in project intellij-community by JetBrains.
the class PropertiesFileStructureViewElement method getChildrenBase.
@NotNull
public Collection<StructureViewTreeElement> getChildrenBase() {
List<? extends IProperty> properties = getElement().getProperties();
Collection<StructureViewTreeElement> elements = new ArrayList<>(properties.size());
for (IProperty property : properties) {
elements.add(new PropertiesStructureViewElement((Property) property));
}
return elements;
}
use of com.intellij.lang.properties.psi.Property in project intellij-community by JetBrains.
the class DuplicatePropertyInspection method prepareDuplicateValuesByFile.
private static void prepareDuplicateValuesByFile(final Map<String, Set<PsiFile>> valueToFiles, final InspectionManager manager, final List<ProblemDescriptor> problemDescriptors, final PsiFile psiFile, final ProgressIndicator progress) {
for (final String value : valueToFiles.keySet()) {
if (progress != null) {
progress.setText2(InspectionsBundle.message("duplicate.property.value.progress.indicator.text", value));
progress.checkCanceled();
}
if (value.length() == 0)
continue;
StringSearcher searcher = new StringSearcher(value, true, true);
final StringBuffer message = new StringBuffer();
final int[] duplicatesCount = { 0 };
Set<PsiFile> psiFilesWithDuplicates = valueToFiles.get(value);
for (final PsiFile file : psiFilesWithDuplicates) {
CharSequence text = file.getViewProvider().getContents();
LowLevelSearchUtil.processTextOccurrences(text, 0, text.length(), searcher, progress, offset -> {
PsiElement element = file.findElementAt(offset);
if (element != null && element.getParent() instanceof Property) {
final Property property = (Property) element.getParent();
if (Comparing.equal(property.getValue(), value) && element.getStartOffsetInParent() != 0) {
if (duplicatesCount[0] == 0) {
message.append(InspectionsBundle.message("duplicate.property.value.problem.descriptor", property.getValue()));
}
surroundWithHref(message, element, true);
duplicatesCount[0]++;
}
}
return true;
});
}
if (duplicatesCount[0] > 1) {
problemDescriptors.add(manager.createProblemDescriptor(psiFile, message.toString(), false, null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING));
}
}
}
use of com.intellij.lang.properties.psi.Property in project intellij-community by JetBrains.
the class FormReferencesSearcher method execute.
@Override
public boolean execute(@NotNull final ReferencesSearch.SearchParameters p, @NotNull final Processor<PsiReference> consumer) {
SearchScope userScope = p.getScopeDeterminedByUser();
if (!scopeCanContainForms(userScope))
return true;
final PsiElement refElement = p.getElementToSearch();
final PsiFile psiFile = ApplicationManager.getApplication().runReadAction(new Computable<PsiFile>() {
@Override
public PsiFile compute() {
if (!refElement.isValid())
return null;
return refElement.getContainingFile();
}
});
if (psiFile == null)
return true;
final VirtualFile virtualFile = psiFile.getVirtualFile();
if (virtualFile == null)
return true;
final GlobalSearchScope[] scope = new GlobalSearchScope[1];
Project project = ApplicationManager.getApplication().runReadAction(new Computable<Project>() {
@Override
public Project compute() {
Project project = psiFile.getProject();
Module module = ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(virtualFile);
if (module != null) {
scope[0] = GlobalSearchScope.moduleWithDependenciesScope(module);
}
return project;
}
});
if (scope[0] == null) {
return true;
}
final LocalSearchScope filterScope = userScope instanceof LocalSearchScope ? (LocalSearchScope) userScope : null;
PsiManager psiManager = PsiManager.getInstance(project);
if (refElement instanceof PsiPackage) {
//no need to do anything
//if (!UIFormUtil.processReferencesInUIForms(consumer, (PsiPackage)refElement, scope)) return false;
} else if (refElement instanceof PsiClass) {
if (!processReferencesInUIForms(consumer, psiManager, (PsiClass) refElement, scope[0], filterScope))
return false;
} else if (refElement instanceof PsiEnumConstant) {
if (!processEnumReferencesInUIForms(consumer, psiManager, (PsiEnumConstant) refElement, scope[0], filterScope))
return false;
} else if (refElement instanceof PsiField) {
if (!processReferencesInUIForms(consumer, psiManager, (PsiField) refElement, scope[0], filterScope))
return false;
} else if (refElement instanceof IProperty) {
if (!processReferencesInUIForms(consumer, psiManager, (Property) refElement, scope[0], filterScope))
return false;
} else if (refElement instanceof PropertiesFile) {
if (!processReferencesInUIForms(consumer, psiManager, (PropertiesFile) refElement, scope[0], filterScope))
return false;
}
return true;
}
Aggregations