use of com.intellij.psi.PsiNamedElement in project intellij-swagger by zalando.
the class OperationSecurityCompletion method getSecurityDefinitions.
private List<ArrayField> getSecurityDefinitions() {
final PsiFile containingFile = completionHelper.getPsiFile().getContainingFile();
final List<? extends PsiNamedElement> securityDefinitions = new PathFinder().findChildrenByPathFrom("$.securityDefinitions", containingFile);
return securityDefinitions.stream().map(PsiNamedElement::getName).map(ArrayField::new).collect(Collectors.toList());
}
use of com.intellij.psi.PsiNamedElement in project intellij-swagger by zalando.
the class PathFinder method isInsidePath.
private boolean isInsidePath(final PsiElement psiElement, PathExpression pathExpression) {
if (psiElement == null) {
return false;
}
final PsiNamedElement nextNamedParent = getNextNamedParent(psiElement);
final String unescapedTargetKeyName = unescapedName(pathExpression.last());
if (pathExpression.isAnyKey()) {
return isInsidePath(getNextNamedParent(nextNamedParent.getParent()), pathExpression.beforeLast());
}
if (pathExpression.isAnyKeys()) {
return isInsidePath(goUpToElementWithParentName(psiElement, pathExpression.secondLast()), pathExpression.beforeLast());
}
if (unescapedTargetKeyName.equals(ROOT_PATH)) {
return nextNamedParent instanceof PsiFile;
}
return unescapedTargetKeyName.equals(nextNamedParent.getName()) && (pathExpression.hasOnePath() || isInsidePath(nextNamedParent.getParent(), pathExpression.beforeLast()));
}
use of com.intellij.psi.PsiNamedElement in project android by JetBrains.
the class ResourceDirectoryNode method collectChildren.
public void collectChildren() {
for (AbstractTreeNode child : myBaseNode.getChildren()) {
Object value = child.getValue();
if (value instanceof PsiNamedElement) {
String name = ((PsiNamedElement) value).getName();
if (!myChildMap.containsKey(name)) {
myChildMap.put(name, child);
myChildren.add(child);
}
} else {
myChildren.add(child);
}
}
}
use of com.intellij.psi.PsiNamedElement in project intellij-community by JetBrains.
the class JavaTestFinder method findClassesForTest.
@NotNull
public Collection<PsiElement> findClassesForTest(@NotNull PsiElement element) {
PsiClass klass = findSourceElement(element);
if (klass == null)
return Collections.emptySet();
GlobalSearchScope scope = getSearchScope(element, true);
PsiShortNamesCache cache = PsiShortNamesCache.getInstance(element.getProject());
List<Pair<? extends PsiNamedElement, Integer>> classesWithWeights = new ArrayList<>();
for (Pair<String, Integer> eachNameWithWeight : TestFinderHelper.collectPossibleClassNamesWithWeights(klass.getName())) {
for (PsiClass eachClass : cache.getClassesByName(eachNameWithWeight.first, scope)) {
if (isTestSubjectClass(eachClass)) {
classesWithWeights.add(Pair.create(eachClass, eachNameWithWeight.second));
}
}
}
return TestFinderHelper.getSortedElements(classesWithWeights, false);
}
use of com.intellij.psi.PsiNamedElement in project intellij-community by JetBrains.
the class CachesBasedRefSearcher method processQuery.
@Override
public void processQuery(@NotNull ReferencesSearch.SearchParameters p, @NotNull Processor<PsiReference> consumer) {
final PsiElement refElement = p.getElementToSearch();
boolean caseSensitive = refElement.getLanguage().isCaseSensitive();
String text = null;
if (refElement instanceof PsiFileSystemItem && !(refElement instanceof SyntheticFileSystemItem)) {
final VirtualFile vFile = ((PsiFileSystemItem) refElement).getVirtualFile();
if (vFile != null) {
text = vFile.getNameWithoutExtension();
}
// We must not look for file references with the file language's case-sensitivity,
// since case-sensitivity of the references themselves depends either on file system
// or on the rules of the language of reference
caseSensitive = false;
} else if (refElement instanceof PsiNamedElement) {
text = ((PsiNamedElement) refElement).getName();
if (refElement instanceof PsiMetaOwner) {
final PsiMetaData metaData = ((PsiMetaOwner) refElement).getMetaData();
if (metaData != null)
text = metaData.getName();
}
}
if (text == null && refElement instanceof PsiMetaOwner) {
final PsiMetaData metaData = ((PsiMetaOwner) refElement).getMetaData();
if (metaData != null)
text = metaData.getName();
}
if (StringUtil.isNotEmpty(text)) {
final SearchScope searchScope = p.getEffectiveSearchScope();
p.getOptimizer().searchWord(text, searchScope, caseSensitive, refElement);
}
}
Aggregations