use of com.intellij.lang.javascript.psi.ecmal4.XmlBackedJSClass in project intellij-plugins by JetBrains.
the class ActionScriptCreateConstructorFix method createIfApplicable.
@Nullable
public static ActionScriptCreateConstructorFix createIfApplicable(final JSCallExpression node) {
final JSClass clazz;
final JSReferenceExpression reference;
if (node instanceof JSNewExpression) {
JSExpression methodExpression = node.getMethodExpression();
if (!(methodExpression instanceof JSReferenceExpression)) {
return null;
}
PsiElement resolved = ((JSReferenceExpression) methodExpression).resolve();
if (!(resolved instanceof JSClass) || resolved instanceof XmlBackedJSClass || ((JSClass) resolved).isInterface()) {
return null;
}
clazz = (JSClass) resolved;
reference = (JSReferenceExpression) methodExpression;
} else {
JSExpression methodExpression = node.getMethodExpression();
if (!(methodExpression instanceof JSSuperExpression)) {
return null;
}
JSClass containingClass = JSResolveUtil.getClassOfContext(node);
if (containingClass == null) {
return null;
}
clazz = containingClass.getSuperClasses()[0];
if (clazz.isInterface()) {
return null;
}
reference = (JSReferenceExpression) clazz.findNameIdentifier().getPsi();
}
return new ActionScriptCreateConstructorFix(clazz, reference, node);
}
use of com.intellij.lang.javascript.psi.ecmal4.XmlBackedJSClass in project intellij-plugins by JetBrains.
the class FlashUmlElementManager method findInDataContext.
public PsiElement findInDataContext(DataContext context) {
PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(context);
if (isAcceptableAsNode(element)) {
return element;
}
// if caret stands on a member or whitespace, show diagram for the enclosing class
final Editor editor = LangDataKeys.EDITOR.getData(context);
if (editor != null) {
final PsiFile file = CommonDataKeys.PSI_FILE.getData(context);
if (file != null) {
PsiElement elementAtOffset = file.findElementAt(editor.getCaretModel().getOffset());
final PsiNamedElement enclosing = PsiTreeUtil.getParentOfType(elementAtOffset, JSClass.class, JSFile.class, XmlFile.class);
if (enclosing instanceof JSClass) {
element = enclosing;
} else if (enclosing instanceof JSFile) {
final XmlBackedJSClass clazz = JSResolveUtil.getXmlBackedClass((JSFile) enclosing);
if (clazz != null) {
return clazz;
}
JSElement qualified = JSPsiImplUtils.findQualifiedElement((JSFile) enclosing);
if (qualified instanceof JSClass) {
return qualified;
}
}
if (enclosing instanceof XmlFile && JavaScriptSupportLoader.isFlexMxmFile((PsiFile) enclosing)) {
return XmlBackedJSClassFactory.getXmlBackedClass((XmlFile) enclosing);
}
}
}
// handle PsiPackage (invoked when 'View as packages' mode is selected)
Project project = CommonDataKeys.PROJECT.getData(context);
if (project != null) {
VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(context);
if (file != null) {
PsiDirectory directory = PsiManager.getInstance(project).findDirectory(file);
if (directory != null && isAcceptableAsNode(directory)) {
return directory;
}
}
}
return element;
}
use of com.intellij.lang.javascript.psi.ecmal4.XmlBackedJSClass in project intellij-plugins by JetBrains.
the class MxmlJSClassProvider method getChildInlineComponents.
public static Collection<XmlBackedJSClass> getChildInlineComponents(XmlTag rootTag, final boolean recursive) {
final XmlTag[] directChildren = ourChildComponentsTagsCache.get(CHILD_INLINE_COMPONENTS_TAGS_KEY, rootTag, null).getValue();
Collection<XmlTag> allChildren;
if (recursive) {
allChildren = new ArrayList<>();
collectComponentsTagRecursively(directChildren, allChildren);
} else {
allChildren = Arrays.asList(directChildren);
}
Collection<XmlBackedJSClass> result = new ArrayList<>(allChildren.size());
for (XmlTag tag : allChildren) {
result.add(XmlBackedJSClassFactory.getInstance().getXmlBackedClass(tag));
}
return result;
}
use of com.intellij.lang.javascript.psi.ecmal4.XmlBackedJSClass in project intellij-plugins by JetBrains.
the class XmlBackedClassLineMarkerProvider method collectSlowLineMarkers.
public void collectSlowLineMarkers(@NotNull List<PsiElement> elements, @NotNull Collection<LineMarkerInfo> result) {
for (PsiElement element : elements) {
ProgressManager.checkCanceled();
if (element instanceof XmlTag && element.getParent() instanceof XmlDocument && element.getContainingFile() != null && JavaScriptSupportLoader.isFlexMxmFile(element.getContainingFile())) {
final XmlBackedJSClass clazz = XmlBackedJSClassFactory.getInstance().getXmlBackedClass((XmlTag) element);
Query<JSClass> classQuery = JSClassSearch.searchClassInheritors(clazz, true);
XmlToken nameElement = XmlTagUtil.getStartTagNameElement((XmlTag) element);
if (classQuery.findFirst() != null && nameElement != null) {
result.add(new LineMarkerInfo<>(clazz, nameElement.getTextRange(), AllIcons.Gutter.OverridenMethod, Pass.LINE_MARKERS, JavaScriptLineMarkerProvider.ourClassInheritorsTooltipProvider, JavaScriptLineMarkerProvider.ourClassInheritorsNavHandler, GutterIconRenderer.Alignment.RIGHT));
}
}
}
}
Aggregations