Search in sources :

Example 11 with PathFinder

use of org.zalando.intellij.swagger.traversal.path.PathFinder in project intellij-swagger by zalando.

the class SecurityScopeNameValueCompletion method getSecurityDefinitionByName.

private List<Value> getSecurityDefinitionByName(final String securityDefinitionName) {
    final PsiFile containingFile = completionHelper.getPsiFile().getContainingFile();
    final List<? extends PsiNamedElement> securityDefinitions = new PathFinder().findChildrenByPathFrom("$.securityDefinitions", containingFile);
    return securityDefinitions.stream().filter(e -> securityDefinitionName.equals(completionHelper.getKeyNameOfObject(e).orElse(null))).map(completionHelper::getSecurityScopesIfOAuth2).flatMap(Collection::stream).map(StringValue::new).collect(Collectors.toList());
}
Also used : Collection(java.util.Collection) PsiFile(com.intellij.psi.PsiFile) PathFinder(org.zalando.intellij.swagger.traversal.path.PathFinder)

Aggregations

PsiFile (com.intellij.psi.PsiFile)11 PathFinder (org.zalando.intellij.swagger.traversal.path.PathFinder)11 Nullable (org.jetbrains.annotations.Nullable)5 PsiNamedElement (com.intellij.psi.PsiNamedElement)2 Collection (java.util.Collection)1