Search in sources :

Example 6 with PathFinder

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

the class LocalReference method resolve.

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

Example 7 with PathFinder

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

the class DefinitionsNotInRootReference method resolve.

@Nullable
@Override
public PsiElement resolve() {
    final PsiFile referencedFile = getReferencedFile();
    if (referencedFile == null) {
        return null;
    }
    final String referencedType = ReferenceValueExtractor.extractType(originalRefValue);
    String referencedValue = ReferenceValueExtractor.extractValue(originalRefValue);
    referencedValue = referencedValue.replace(".", "\\.");
    final String pathExpression = String.format("$.%s.%s", referencedType, 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)

Example 8 with PathFinder

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

the class ComponentFileReference method resolve.

@Nullable
@Override
public PsiElement resolve() {
    final PsiFile referencedFile = getReferencedFile();
    if (referencedFile == null) {
        return null;
    }
    final String referencedValue = ReferenceValueExtractor.extractValue(originalRefValue);
    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)

Example 9 with PathFinder

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

the class LocalReference method resolve.

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

Example 10 with PathFinder

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

the class RootSecurityCompletion method fill.

@Override
public void fill() {
    getSecurityDefinitions().forEach(field -> {
        final PsiFile containingFile = completionHelper.getPsiFile().getContainingFile();
        final List<? extends PsiNamedElement> security = new PathFinder().findChildrenByPathFrom("$.security", containingFile);
        final List<String> existingNames = extractNames(security);
        if (!existingNames.contains(field.getName())) {
            addUnique(field);
        }
    });
}
Also used : 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