Search in sources :

Example 1 with PathFinder

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

the class ComponentRefValueCompletion method getSchemaKeys.

private List<Value> getSchemaKeys() {
    final PsiFile psiFile = completionHelper.getPsiFile();
    final String pathExpression = String.format("$.components.%s", refType);
    return new PathFinder().findChildrenByPathFrom(pathExpression, psiFile).stream().map(e -> String.format("#/components/%s/%s", refType, e.getName())).map(StringValue::new).collect(Collectors.toList());
}
Also used : PsiFile(com.intellij.psi.PsiFile) PathFinder(org.zalando.intellij.swagger.traversal.path.PathFinder)

Example 2 with PathFinder

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

the class RootSecurityCompletion 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());
}
Also used : PsiNamedElement(com.intellij.psi.PsiNamedElement) PsiFile(com.intellij.psi.PsiFile) PathFinder(org.zalando.intellij.swagger.traversal.path.PathFinder)

Example 3 with PathFinder

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

the class LocalRefValueCompletion method getDefinitionKeys.

private List<Value> getDefinitionKeys() {
    final PsiFile psiFile = completionHelper.getPsiFile();
    final String pathExpression = String.format("$.%s", refType);
    return new PathFinder().findChildrenByPathFrom(pathExpression, psiFile).stream().map(e -> String.format("#/%s/%s", refType, e.getName())).map(StringValue::new).collect(Collectors.toList());
}
Also used : PsiFile(com.intellij.psi.PsiFile) PathFinder(org.zalando.intellij.swagger.traversal.path.PathFinder)

Example 4 with PathFinder

use of org.zalando.intellij.swagger.traversal.path.PathFinder 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());
}
Also used : PsiNamedElement(com.intellij.psi.PsiNamedElement) PsiFile(com.intellij.psi.PsiFile) PathFinder(org.zalando.intellij.swagger.traversal.path.PathFinder)

Example 5 with PathFinder

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

the class DefinitionsInRootReference method resolve.

@Nullable
@Override
public PsiElement resolve() {
    final PsiFile referencedFile = getReferencedFile();
    if (referencedFile == null) {
        return null;
    }
    String referencedValue = ReferenceValueExtractor.extractValue(originalRefValue);
    referencedValue = referencedValue.replace(".", "\\.");
    final String pathExpression = String.format("$.%s", referencedValue);
    return new PathFinder().findByPathFrom(pathExpression, referencedFile).orElse(null);
}
Also used : PsiFile(com.intellij.psi.PsiFile) PathFinder(org.zalando.intellij.swagger.traversal.path.PathFinder) Nullable(org.jetbrains.annotations.Nullable)

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