Search in sources :

Example 1 with CfmlTagImpl

use of com.intellij.coldFusion.model.psi.impl.CfmlTagImpl in project intellij-plugins by JetBrains.

the class CfmlPredefinedVariablesCompletion method getNameForCfmlTag.

@Nullable
private static String getNameForCfmlTag(@NotNull CompletionParameters pars) {
    PsiElement elem = pars.getPosition().getParent().getFirstChild();
    if (elem instanceof CfmlReferenceExpression) {
        PsiElement resElem = ((CfmlReferenceExpression) elem).resolve();
        if (resElem != null) {
            PsiElement parent = resElem.getParent();
            if (!(parent instanceof CfmlTagImpl)) {
                return null;
            }
            String name = ((CfmlTagImpl) parent).getTagName();
            return name.startsWith("cf") ? name.substring(2) : name;
        }
    }
    return null;
}
Also used : CfmlReferenceExpression(com.intellij.coldFusion.model.psi.CfmlReferenceExpression) CfmlTagImpl(com.intellij.coldFusion.model.psi.impl.CfmlTagImpl) PsiElement(com.intellij.psi.PsiElement) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with CfmlTagImpl

use of com.intellij.coldFusion.model.psi.impl.CfmlTagImpl in project intellij-plugins by JetBrains.

the class CfmlUtil method isPredefinedTagVariables.

public static boolean isPredefinedTagVariables(CfmlReferenceExpression cfmlRef, Project project) {
    String predefVarText = cfmlRef.getLastChild() != null ? cfmlRef.getLastChild().getText() : null;
    //try to find tag type by name//
    PsiElement referenceName = cfmlRef.getFirstChild();
    if (!(referenceName instanceof CfmlReferenceExpression) || predefVarText == null) {
        return false;
    }
    referenceName = ((CfmlReferenceExpression) referenceName).resolve();
    referenceName = referenceName != null ? referenceName.getParent() : null;
    if (!(referenceName instanceof CfmlTagImpl)) {
        return false;
    }
    String tagName = ((CfmlTagImpl) referenceName).getTagName();
    String tagNameWithoutCf = tagName.startsWith("cf") ? tagName.substring(2) : tagName;
    return CfmlLangInfo.getInstance(anyProject(project)).getPredefinedVariables().keySet().contains(tagNameWithoutCf.toLowerCase() + "." + predefVarText.toLowerCase());
}
Also used : CfmlReferenceExpression(com.intellij.coldFusion.model.psi.CfmlReferenceExpression) CfmlTagImpl(com.intellij.coldFusion.model.psi.impl.CfmlTagImpl) PsiElement(com.intellij.psi.PsiElement)

Aggregations

CfmlReferenceExpression (com.intellij.coldFusion.model.psi.CfmlReferenceExpression)2 CfmlTagImpl (com.intellij.coldFusion.model.psi.impl.CfmlTagImpl)2 PsiElement (com.intellij.psi.PsiElement)2 Nullable (org.jetbrains.annotations.Nullable)1