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);
}
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);
}
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);
}
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);
}
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);
}
});
}
Aggregations