use of com.intellij.lang.javascript.psi.JSNamedElement in project intellij-plugins by JetBrains.
the class FlexGotoImplementationsTest method check.
private static void check(String expected, PsiElement[] implementations) {
List<String> strings = new ArrayList<>(implementations.length);
for (PsiElement element : implementations) {
assertTrue("unexpected result item: " + element, element instanceof JSNamedElement);
strings.add(((JSNamedElement) element).getName());
}
Collections.sort(strings);
assertEquals(expected, StringUtil.join(strings, ","));
}
use of com.intellij.lang.javascript.psi.JSNamedElement in project intellij-plugins by JetBrains.
the class FlexXmlBackedMembersIndex method getItemsByName.
public static Collection<NavigationItem> getItemsByName(final String name, Project project) {
Collection<VirtualFile> files = FileBasedIndex.getInstance().getContainingFiles(NAME, name, GlobalSearchScope.projectScope(project));
final Collection<NavigationItem> result = new ArrayList<>();
for (VirtualFile vFile : files) {
PsiFile file = PsiManager.getInstance(project).findFile(vFile);
if (!(file instanceof XmlFile)) {
continue;
}
process((XmlFile) file, element -> {
if (name.equals(getName(element))) {
if (element instanceof JSNamedElement) {
result.add((JSNamedElement) element);
} else {
XmlAttribute id = ((XmlTag) element).getAttribute("id");
if (id != null) {
XmlAttributeValue valueElement = id.getValueElement();
PsiElement[] children;
if (valueElement != null && (children = valueElement.getChildren()).length == 3) {
result.add(new TagNavigationItem(children[1], name));
}
}
}
}
}, true);
}
return result;
}
use of com.intellij.lang.javascript.psi.JSNamedElement in project intellij-plugins by JetBrains.
the class FlexIconProvider method getIcon.
@Override
public Icon getIcon(@NotNull PsiElement element, int flags) {
int transformedFlags = ElementBase.transformFlags(element, flags);
Icon icon = null;
if (element instanceof XmlFile) {
if (JavaScriptSupportLoader.isFlexMxmFile((PsiFile) element)) {
final JSClass jsClass = XmlBackedJSClassFactory.getXmlBackedClass((XmlFile) element);
if (jsClass != null) {
icon = jsClass.getIcon(flags);
}
}
} else if (element instanceof JSFileImpl) {
final JSNamedElement mainDeclaredElement = ActionScriptResolveUtil.findMainDeclaredElement((JSFileImpl) element);
if (mainDeclaredElement != null) {
icon = mainDeclaredElement.getIcon(transformedFlags);
}
}
if (icon != null) {
final PsiFile psiFile = element.getContainingFile();
final VirtualFile vFile = psiFile == null ? null : psiFile.getVirtualFile();
CompilerManager compilerManager = CompilerManager.getInstance(element.getProject());
if (vFile != null && compilerManager != null && compilerManager.isExcludedFromCompilation(vFile)) {
icon = new LayeredIcon(icon, PlatformIcons.EXCLUDED_FROM_COMPILE_ICON);
}
}
return icon;
}
use of com.intellij.lang.javascript.psi.JSNamedElement in project intellij-plugins by JetBrains.
the class ActionScriptImportHandler method resolveTypeNameInTheSamePackage.
private static JSNamedElement resolveTypeNameInTheSamePackage(@NotNull final String str, final PsiElement context) {
JSNamedElement fileLocalElement = JSResolveUtil.findFileLocalElement(str, context);
if (fileLocalElement != null)
return fileLocalElement;
final String packageQualifierText = JSResolveUtil.findPackageStatementQualifier(context);
PsiElement byQName;
if (packageQualifierText != null) {
byQName = JSClassResolver.findClassFromNamespace(packageQualifierText + "." + str, context);
if (byQName instanceof JSQualifiedNamedElement) {
return (JSQualifiedNamedElement) byQName;
}
}
byQName = JSDialectSpecificHandlersFactory.forElement(context).getClassResolver().findClassByQName(str, context);
if (byQName instanceof JSQualifiedNamedElement && JSResolveUtil.acceptableSymbol((JSQualifiedNamedElement) byQName, JSResolveUtil.GlobalSymbolsAcceptanceState.WHATEVER, false, context)) {
return (JSQualifiedNamedElement) byQName;
}
return null;
}
Aggregations