use of com.intellij.coldFusion.model.psi.CfmlReferenceExpression 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;
}
use of com.intellij.coldFusion.model.psi.CfmlReferenceExpression 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());
}
use of com.intellij.coldFusion.model.psi.CfmlReferenceExpression in project intellij-plugins by JetBrains.
the class CfmlVariableSurroundDescriptor method getElementsToSurround.
@NotNull
@Override
public PsiElement[] getElementsToSurround(PsiFile file, int startOffset, int endOffset) {
final FileViewProvider viewProvider = file.getViewProvider();
PsiElement elementAt = PsiTreeUtil.findElementOfClassAtRange(file, startOffset, endOffset, CfmlReferenceExpression.class);
if (elementAt != null) {
return !(elementAt.getParent() instanceof CfmlReferenceExpression) ? new PsiElement[] { elementAt } : PsiElement.EMPTY_ARRAY;
}
for (Language language : viewProvider.getLanguages()) {
elementAt = viewProvider.findElementAt(startOffset, language);
if (elementAt != null && (!language.is(CfmlLanguage.INSTANCE) || elementAt.getNode().getElementType() == CfmlTokenTypes.STRING_TEXT) && elementAt.getNode().getText().matches("(\\S)+") && elementAt.getTextRange().getStartOffset() == startOffset && elementAt.getTextRange().getEndOffset() == endOffset) {
return new PsiElement[] { elementAt };
}
}
return PsiElement.EMPTY_ARRAY;
}
Aggregations