Java Code Examples for com.jetbrains.php.lang.psi.elements.StringLiteralExpression

The following examples show how to use com.jetbrains.php.lang.psi.elements.StringLiteralExpression. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Nullable
@Override
public PsiElement[] getGotoDeclarationTargets(@Nullable PsiElement sourceElement, int offset, Editor editor) {
    if (sourceElement == null) {
        return new PsiElement[0];
    }

    Collection<PsiElement> psiElements = new HashSet<>();

    PsiElement parent = sourceElement.getParent();
    if (parent instanceof StringLiteralExpression && PhpElementsUtil.getParameterListArrayValuePattern().accepts(sourceElement)) {
        psiElements.addAll(collectArrayKeyParameterTargets(parent));
    }

    return psiElements.toArray(new PsiElement[0]);
}
 
Example 2
private Collection<PsiElement> collectArrayKeyParameterTargets(PsiElement psiElement) {
    Collection<PsiElement> psiElements = new HashSet<>();

    ArrayCreationExpression parentOfType = PsiTreeUtil.getParentOfType(psiElement, ArrayCreationExpression.class);

    if (parentOfType != null) {
        String contents = ((StringLiteralExpression) psiElement).getContents();

        psiElements.addAll(GenericsUtil.getTypesForParameter(parentOfType).stream()
            .filter(parameterArrayType -> parameterArrayType.getKey().equalsIgnoreCase(contents))
            .map(ParameterArrayType::getContext).collect(Collectors.toSet())
        );
    }

    return psiElements;
}
 
Example 3
Source Project: idea-php-laravel-plugin   Source File: BladeTemplateUtil.java    License: MIT License 6 votes vote down vote up
private void visitFunctionReference(FunctionReference functionReference) {

            if(!"view".equals(functionReference.getName())) {
                return;
            }

            PsiElement[] parameters = functionReference.getParameters();

            if(parameters.length < 1 || !(parameters[0] instanceof StringLiteralExpression)) {
                return;
            }

            String contents = ((StringLiteralExpression) parameters[0]).getContents();
            if(StringUtils.isBlank(contents)) {
                return;
            }

            views.add(Pair.create(contents, parameters[0]));
        }
 
Example 4
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement psiElement) {
    if(!Symfony2ProjectComponent.isEnabled(psiElement.getProject())) {
        return false;
    }

    PsiElement parent = psiElement.getParent();
    if(!(parent instanceof StringLiteralExpression)) {
        return false;
    }

    String contents = ((StringLiteralExpression) parent).getContents();
    if(StringUtils.isBlank(contents)) {
        return false;
    }

    return null != new MethodMatcher.StringParameterMatcher(parent, 1)
        .withSignature(FormUtil.PHP_FORM_BUILDER_SIGNATURES)
        .match();
}
 
Example 5
@Nullable
@Override
public PsiReference[] getPropertyReferences(AnnotationPropertyParameter annotationPropertyParameter, PhpAnnotationReferenceProviderParameter referencesByElementParameter) {

    if(annotationPropertyParameter.getType() != AnnotationPropertyParameter.Type.PROPERTY_VALUE) {
        return null;
    }

    String propertyName = annotationPropertyParameter.getPropertyName();
    if(propertyName == null || !propertyName.equals("repositoryClass")) {
        return null;
    }

    String presentableFQN = annotationPropertyParameter.getPhpClass().getPresentableFQN();
    if(!PhpLangUtil.equalsClassNames("Doctrine\\ORM\\Mapping\\Entity", presentableFQN)) {
        return null;
    }

    return new PsiReference[] {
        new DoctrineRepositoryReference((StringLiteralExpression) annotationPropertyParameter.getElement())
    };

}
 
Example 6
private String[] collectMetaArgumentsSets(PsiElement position) {
    Collection<String> argumentsSets = new ArrayList<>();

    PhpNamespace root = PsiTreeUtil.getParentOfType(position, PhpNamespace.class);
    if (root == null || !"PHPSTORM_META".equals(root.getName())) {
        return new String[0];
    }

    Collection<ParameterList> arguments = PsiTreeUtil.findChildrenOfType(root, ParameterList.class);
    for (ParameterList args : arguments) {
        PsiElement parent = args.getParent();
        if (!(parent instanceof FunctionReference) || !"registerArgumentsSet".equals(((FunctionReference)parent).getName())) {
            continue;
        }

        StringLiteralExpression arg0 = PsiTreeUtil.findChildOfType(args, StringLiteralExpression.class);
        if (arg0 == null) {
            continue;
        }

        argumentsSets.add(arg0.getContents());
    }

    return argumentsSets.toArray(new String[0]);
}
 
Example 7
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement psiElement) {
    if(!Symfony2ProjectComponent.isEnabled(psiElement.getProject())) {
        return false;
    }

    PsiElement parent = psiElement.getParent();
    if(!(parent instanceof StringLiteralExpression)) {
        return false;
    }

    String contents = ((StringLiteralExpression) parent).getContents();
    if(StringUtils.isBlank(contents)) {
        return false;
    }

    return null != new MethodMatcher.StringParameterMatcher(parent, 0)
        .withSignature(SymfonyPhpReferenceContributor.REPOSITORY_SIGNATURES)
        .withSignature("Doctrine\\Persistence\\ObjectManager", "find")
        .withSignature("Doctrine\\Common\\Persistence\\ObjectManager", "find") // @TODO: missing somewhere
        .match();
}
 
Example 8
@Nullable
@Override
public PsiReference[] getPropertyReferences(AnnotationPropertyParameter annotationPropertyParameter, PhpAnnotationReferenceProviderParameter phpAnnotationReferenceProviderParameter) {

    if(!Symfony2ProjectComponent.isEnabled(annotationPropertyParameter.getProject()) || !(annotationPropertyParameter.getElement() instanceof StringLiteralExpression) || !PhpElementsUtil.isEqualClassName(annotationPropertyParameter.getPhpClass(),
        "\\Doctrine\\ORM\\Mapping\\ManyToOne",
        "\\Doctrine\\ORM\\Mapping\\ManyToMany",
        "\\Doctrine\\ORM\\Mapping\\OneToOne",
        "\\Doctrine\\ORM\\Mapping\\OneToMany")
        )
    {
        return new PsiReference[0];
    }

    // @Foo(targetEntity="Foo\Class")
    if(annotationPropertyParameter.getType() == AnnotationPropertyParameter.Type.PROPERTY_VALUE && "targetEntity".equals(annotationPropertyParameter.getPropertyName())) {
        return new PsiReference[]{ new EntityReference((StringLiteralExpression) annotationPropertyParameter.getElement(), true) };
    }

    return new PsiReference[0];
}
 
Example 9
@Nullable
@Override
public PsiReference[] getPropertyReferences(AnnotationPropertyParameter annotationPropertyParameter, PhpAnnotationReferenceProviderParameter referencesByElementParameter) {

    if(annotationPropertyParameter.getType() != AnnotationPropertyParameter.Type.PROPERTY_VALUE) {
        return null;
    }

    String propertyName = annotationPropertyParameter.getPropertyName();
    if(propertyName == null || !propertyName.equals("type")) {
        return null;
    }

    String presentableFQN = annotationPropertyParameter.getPhpClass().getPresentableFQN();
    if(!presentableFQN.startsWith("\\")) {
        presentableFQN = "\\" + presentableFQN;
    }

    if(!presentableFQN.equals("\\Doctrine\\ORM\\Mapping\\Column")) {
        return null;
    }

    return new PsiReference[] {
        new DoctrineColumnTypeReference((StringLiteralExpression) annotationPropertyParameter.getElement())
    };
}
 
Example 10
@Nullable
@Override
public PsiElement[] getGotoDeclarationTargets(PsiElement psiElement, int i, Editor editor) {

    if(!DrupalProjectComponent.isEnabled(psiElement)) {
        return new PsiElement[0];
    }

    List<PsiElement> psiElementList = new ArrayList<>();

    PsiElement context = psiElement.getContext();
    if(context instanceof StringLiteralExpression && DrupalPattern.isAfterArrayKey(psiElement, "route_name")) {
        PsiElement routeTarget = RouteHelper.getRouteNameTarget(psiElement.getProject(), ((StringLiteralExpression) context).getContents());
        if(routeTarget != null) {
            psiElementList.add(routeTarget);
        }
    }

    return psiElementList.toArray(new PsiElement[psiElementList.size()]);
}
 
Example 11
Source Project: idea-php-shopware-plugin   Source File: PhpGoToHandler.java    License: MIT License 6 votes vote down vote up
private void attachNamespaceValueNavigation(@NotNull PsiElement psiElement, @NotNull List<PsiElement> psiElements) {
    PsiElement parent = psiElement.getParent();
    if(!(parent instanceof StringLiteralExpression)) {
        return;
    }

    String contents = ((StringLiteralExpression) parent).getContents();
    if(StringUtils.isBlank(contents)) {
        return;
    }

    String namespace = ConfigUtil.getNamespaceFromConfigValueParameter((StringLiteralExpression) parent);
    if (namespace == null) {
        return;
    }

    ConfigUtil.visitNamespaceConfigurations(psiElement.getProject(), namespace, pair -> {
        if(contents.equalsIgnoreCase(pair.getFirst())) {
            psiElements.add(pair.getSecond());
        }
    });
}
 
Example 12
@Override
public void register(GotoCompletionRegistrarParameter registrar) {
    registrar.register(PlatformPatterns.psiElement().withParent(StringLiteralExpression.class).withLanguage(PhpLanguage.INSTANCE), psiElement -> {

        if(!DrupalProjectComponent.isEnabled(psiElement)) {
            return null;
        }

        PsiElement parent = psiElement.getParent();
        if(parent == null) {
            return null;
        }

        MethodMatcher.MethodMatchParameter methodMatchParameter = MethodMatcher.getMatchedSignatureWithDepth(parent, CONFIG);
        if(methodMatchParameter == null) {
            return null;
        }

        return new FormReferenceCompletionProvider(parent);

    });
}
 
Example 13
/**
 * Called to apply the fix.
 *
 * @param project    {@link Project}
 * @param descriptor problem reported by the tool which provided this quick fix action
 */
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
    PsiElement psiElement = descriptor.getPsiElement();
    if (psiElement instanceof StringLiteralExpression) {
        StringLiteralExpression stringElement = (StringLiteralExpression) psiElement;
        String contents = stringElement.getContents();

        String fileName = TranslationUtil.extractResourceFilenameFromTranslationString(contents);
        String key = TranslationUtil.extractTranslationKeyTranslationString(contents);
        if (fileName != null) {
            PsiElement[] elementsForKey = ResourcePathIndex.findElementsForKey(project, fileName);
            if (elementsForKey.length > 0) {
                // TranslationUtil.add();
            }
        }
    }
}
 
Example 14
@Override
public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement psiElement) throws IncorrectOperationException {
    PsiElement parent = psiElement.getParent();
    if(!(parent instanceof StringLiteralExpression)) {
        return;
    }

    try {
        PhpClass phpClass = EntityHelper.resolveShortcutName(project, ((StringLiteralExpression) parent).getContents());
        if(phpClass == null) {
            throw new Exception("Can not resolve model class");
        }
        PhpElementsUtil.replaceElementWithClassConstant(phpClass, parent);
    } catch (Exception e) {
        HintManager.getInstance().showErrorHint(editor, e.getMessage());
    }
}
 
Example 15
@NotNull
private static HashMap<Integer, RelativeRange> getRelativeSpecificationRanges(HashMap<Integer, PhpPackFormatSpecificationParser.PackSpecification> specifications, List<StringLiteralExpression> targets) {
    Map<TextRange, StringLiteralExpression> rangesInsideResultingFormatString = getRangesWithExpressionInsideResultingFormatString(targets);
    HashMap<Integer, RelativeRange> result = new HashMap<>();

    for (Map.Entry<Integer, PhpPackFormatSpecificationParser.PackSpecification> entry : specifications.entrySet()) {
        PhpPackFormatSpecificationParser.PackSpecification specification = entry.getValue();
        for (Map.Entry<TextRange, StringLiteralExpression> e : rangesInsideResultingFormatString.entrySet()) {
            TextRange expressionRangeInsideFormatString = e.getKey();
            TextRange specificationRangeInsideFormatString = expressionRangeInsideFormatString.intersection(specification.getRangeInElement());
            if (specificationRangeInsideFormatString != null && !specificationRangeInsideFormatString.isEmpty()) {
                result.put(entry.getKey(), new RelativeRange(e.getValue(), specificationRangeInsideFormatString.shiftLeft(expressionRangeInsideFormatString.getStartOffset())));
            }
        }
    }

    return result;
}
 
Example 16
Source Project: idea-php-typo3-plugin   Source File: InvalidQuantityInspection.java    License: MIT License 6 votes vote down vote up
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder problemsHolder, boolean b) {
    if (!TYPO3CMSProjectSettings.isEnabled(problemsHolder.getProject())) {
        return new PhpElementVisitor() {
        };
    }

    return new PhpElementVisitor() {
        @Override
        public void visitPhpElement(PhpPsiElement element) {

            boolean isArrayStringValue = PhpElementsUtil.isStringArrayValue().accepts(element);
            if (!isArrayStringValue || !insideTCAColumnDefinition(element)) {
                return;
            }

            String arrayIndex = extractArrayIndexFromValue(element);
            if (arrayIndex != null && Arrays.asList(TCAUtil.TCA_NUMERIC_CONFIG_KEYS).contains(arrayIndex)) {
                if (element instanceof StringLiteralExpression) {
                    problemsHolder.registerProblem(element, "Config key only accepts integer values");
                }
            }
        }
    };
}
 
Example 17
Source Project: idea-php-toolbox   Source File: PhpFunctionRegistrarMatcher.java    License: MIT License 6 votes vote down vote up
@Override
public boolean matches(@NotNull LanguageMatcherParameter parameter) {

    PsiElement parent = parameter.getElement().getParent();
    if(!(parent instanceof StringLiteralExpression)) {
        return false;
    }

    Collection<JsonSignature> signatures = ContainerUtil.filter(
        parameter.getRegistrar().getSignatures(),
        ContainerConditions.DEFAULT_TYPE_FILTER
    );

    if(signatures.size() == 0) {
        return false;
    }

    return PhpMatcherUtil.matchesArraySignature(parent, signatures);
}
 
Example 18
Source Project: idea-php-symfony2-plugin   Source File: AssistantReferenceUtil.java    License: MIT License 6 votes vote down vote up
@NotNull
public static PsiReference[] getPsiReference(MethodParameterSetting methodParameterSetting, StringLiteralExpression psiElement, List<MethodParameterSetting> configsMethodScope, MethodReference method) {

    // custom references
    if(methodParameterSetting.hasAssistantPsiReferenceContributor()) {
        return methodParameterSetting.getAssistantPsiReferenceContributor().getPsiReferences(psiElement);
    }

    // build provider parameter
    AssistantReferenceProvider.AssistantReferenceProviderParameter assistantReferenceProviderParameter = new AssistantReferenceProvider.AssistantReferenceProviderParameter(
        psiElement,
        methodParameterSetting,
        configsMethodScope,
        method
    );

    String ReferenceProvider = methodParameterSetting.getReferenceProviderName();
    for(AssistantReferenceProvider referenceProvider: DefaultReferenceProvider.DEFAULT_PROVIDERS) {
        if(referenceProvider.getAlias().equals(ReferenceProvider)) {
            return new PsiReference[] { referenceProvider.getPsiReference(assistantReferenceProviderParameter) };
        }
    }

    return new PsiReference[0];
}
 
Example 19
@Nullable
@Override
public PsiReference[] getPropertyReferences(AnnotationPropertyParameter annotationPropertyParameter, PhpAnnotationReferenceProviderParameter phpAnnotationReferenceProviderParameter) {
    Project project = annotationPropertyParameter.getProject();
    if(!Symfony2ProjectComponent.isEnabled(project) || !(annotationPropertyParameter.getElement() instanceof StringLiteralExpression) || !PhpElementsUtil.isEqualClassName(annotationPropertyParameter.getPhpClass(), IS_GRANTED_CLASS)) {
        return new PsiReference[0];
    }

    if(annotationPropertyParameter.getType() != AnnotationPropertyParameter.Type.DEFAULT) {
        return new PsiReference[0];
    }

    return new PsiReference[] {
        new VoterReference(((StringLiteralExpression) annotationPropertyParameter.getElement()))
    };
}
 
Example 20
private void attachPropertyGoto(StringLiteralExpression psiElement, List<PsiElement> targets) {

        MethodMatcher.MethodMatchParameter methodMatchParameter = MatcherUtil.matchPropertyField(psiElement);
        if(methodMatchParameter == null) {
            return;
        }

        QueryBuilderMethodReferenceParser qb = QueryBuilderCompletionContributor.getQueryBuilderParser(methodMatchParameter.getMethodReference());
        if(qb == null) {
            return;
        }

        QueryBuilderScopeContext collect = qb.collect();
        String propertyContent = psiElement.getContents();

        for(Map.Entry<String, QueryBuilderPropertyAlias> entry: collect.getPropertyAliasMap().entrySet()) {
            if(entry.getKey().equals(propertyContent)) {
                targets.addAll(entry.getValue().getPsiTargets());
            }
        }


    }
 
Example 21
@Nullable
@Override
public PsiReference[] getPropertyReferences(AnnotationPropertyParameter parameter, PhpAnnotationReferenceProviderParameter referencesByElementParameter) {
    if(!supports(parameter)) {
        return new PsiReference[0];
    }

    PsiElement element = parameter.getElement();
    if(!(element instanceof StringLiteralExpression) || StringUtils.isBlank(((StringLiteralExpression) element).getContents())) {
        return new PsiReference[0];
    }

    return new PsiReference[] {
        new PhpClassReference((StringLiteralExpression) element)
    };
}
 
Example 22
Source Project: Thinkphp5-Plugin   Source File: Symfony2InterfacesUtil.java    License: MIT License 5 votes vote down vote up
@Deprecated
@Nullable
public static String getFirstArgumentStringValue(MethodReference e) {
    String stringValue = null;

    PsiElement[] parameters = e.getParameters();
    if (parameters.length > 0 && parameters[0] instanceof StringLiteralExpression) {
        stringValue = ((StringLiteralExpression) parameters[0]).getContents();
    }

    return stringValue;
}
 
Example 23
@NotNull
@Override
public PsiElementVisitor buildRealVisitor(@NotNull ProblemsHolder problemsHolder, boolean b) {
    return new PhpElementVisitor() {
        @Override
        public void visitPhpElement(PhpPsiElement element) {

            boolean isArrayStringValue = PhpElementsUtil.isStringArrayValue().accepts(element);
            if (!isArrayStringValue || !insideTCAColumnDefinition(element)) {
                return;
            }


            String arrayIndex = extractArrayIndexFromValue(element);
            if (arrayIndex != null && arrayIndex.equals("type")) {
                if (element instanceof StringLiteralExpression) {
                    String tableName = ((StringLiteralExpression) element).getContents();
                    boolean isValidRenderType = TCAUtil.getAvailableColumnTypes(element.getProject()).contains(tableName);

                    if (!isValidRenderType) {
                        problemsHolder.registerProblem(element, "Missing column type definition");
                    }
                }
            }
        }
    };
}
 
Example 24
@NotNull
@Override
public Collection<PsiElement> getPsiTargets(StringLiteralExpression element) {
    String contents = element.getContents();
    if(StringUtils.isBlank(contents)) {
        return Collections.emptyList();
    }

    return RoutingUtil.getRoutesAsTargets(element.getProject(), contents);
}
 
Example 25
@NotNull
    @Override
    public ThreeState shouldSkipAutopopup(@NotNull PsiElement contextElement, @NotNull PsiFile psiFile, int offset) {

        if (!(psiFile instanceof PhpFile)) {
            return ThreeState.UNSURE;
        }

        PsiElement context = contextElement.getContext();
        if (!(context instanceof StringLiteralExpression)) {
            return ThreeState.UNSURE;
        }

//        // $test == "";
//        if(context.getParent() instanceof BinaryExpression) {
//            return ThreeState.NO;
//        }

        // $object->method("");
        PsiElement stringContext = context.getContext();
        if (stringContext instanceof ParameterList) {
            return ThreeState.NO;
        }

//        // $object->method(... array('foo'); array('bar' => 'foo') ...);
//        ArrayCreationExpression arrayCreationExpression = PhpElementsUtil.getCompletableArrayCreationElement(context);
//        if(arrayCreationExpression != null && arrayCreationExpression.getContext() instanceof ParameterList) {
//            return ThreeState.NO;
//        }

//        // $array['value']
//        if(PlatformPatterns.psiElement().withSuperParent(2, ArrayIndex.class).accepts(contextElement)) {
//            return ThreeState.NO;
//        }

        return ThreeState.UNSURE;
    }
 
Example 26
Source Project: idea-php-typo3-plugin   Source File: ContextReference.java    License: MIT License 5 votes vote down vote up
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
    if (myElement instanceof StringLiteralExpression) {
        String aspectFQN = TYPO3Utility.getFQNByAspectName(((StringLiteralExpression) myElement).getContents());
        if (aspectFQN == null) {
            return ResolveResult.EMPTY_ARRAY;
        }

        return PsiElementResolveResult.createResults(PhpIndex.getInstance(myElement.getProject()).getClassesByFQN(aspectFQN));
    }

    return ResolveResult.EMPTY_ARRAY;
}
 
Example 27
@Override
public void invoke(@NotNull Project project, @NotNull PsiFile psiFile, @NotNull PsiElement psiElement, @NotNull PsiElement psiElement1) {
    if(!(getStartElement() instanceof StringLiteralExpression)) {
        return;
    }

    try {
        FormUtil.replaceFormStringAliasWithClassConstant((StringLiteralExpression) getStartElement());
    } catch (Exception ignored) {
    }
}
 
Example 28
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) {
    PsiElement psiElement = parameters.getOriginalPosition();
    if(psiElement == null) {
        return;
    }

    PsiElement phpDocString = psiElement.getContext();
    if(!(phpDocString instanceof StringLiteralExpression)) {
        return;
    }

    PsiElement propertyName = PhpElementsUtil.getPrevSiblingOfPatternMatch(phpDocString, PlatformPatterns.psiElement(PhpDocTokenTypes.DOC_IDENTIFIER));
    if(propertyName == null) {
        return;
    }

    PhpDocTag phpDocTag = PsiTreeUtil.getParentOfType(parameters.getOriginalPosition(), PhpDocTag.class);
    PhpClass phpClass = AnnotationUtil.getAnnotationReference(phpDocTag);
    if(phpClass == null) {
        return;
    }

    AnnotationPropertyParameter annotationPropertyParameter = new AnnotationPropertyParameter(parameters.getOriginalPosition(), phpClass, propertyName.getText(), AnnotationPropertyParameter.Type.PROPERTY_VALUE);
    providerWalker(parameters, context, result, annotationPropertyParameter);

}
 
Example 29
Source Project: idea-php-shopware-plugin   Source File: ThemeUtil.java    License: MIT License 5 votes vote down vote up
public static void collectThemeJsFieldReferences(@NotNull StringLiteralExpression element, @NotNull ThemeAssetVisitor visitor) {

        PsiElement arrayValue = element.getParent();
        if(arrayValue.getNode().getElementType() != PhpElementTypes.ARRAY_VALUE) {
            return;
        }

        PsiElement arrayCreation = arrayValue.getParent();
        if(!(arrayCreation instanceof ArrayCreationExpression)) {
            return;
        }

        PsiElement classField = arrayCreation.getParent();
        if(!(classField instanceof Field)) {
            return;
        }

        if(!"javascript".equals(((Field) classField).getName())) {
            return;
        }


        PhpClass phpClass = PsiTreeUtil.getParentOfType(classField, PhpClass.class);
        if(phpClass == null || !PhpElementsUtil.isInstanceOf(phpClass, "\\Shopware\\Components\\Theme")) {
            return;
        }

        visitThemeAssetsFile(phpClass, visitor);
    }
 
Example 30
Source Project: idea-php-typo3-plugin   Source File: PathResourceAnnotator.java    License: MIT License 5 votes vote down vote up
@Override
public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
    if (!(element instanceof StringLiteralExpression) && !(element instanceof YAMLQuotedText)) {
        return;
    }

    String content = getContents(element);
    if (!content.startsWith("EXT:") || element.getProject().getBasePath() == null) {
        return;
    }

    String resourceName = content.substring(4);
    if (resourceName.contains(":")) {
        // resource name points to a sub-resource such as a translation string, not here.
        return;
    }

    if (ResourcePathIndex.projectContainsResourceFile(element.getProject(), content)) {
        // exact match found
        return;
    }

    if (ResourcePathIndex.projectContainsResourceDirectory(element.getProject(), content)) {
        return;
    }

    createErrorMessage(element, holder, resourceName);
}