use of com.intellij.lang.javascript.psi.ecmal4.JSClass in project intellij-plugins by JetBrains.
the class FlashRunConfiguration method containsClass.
public static boolean containsClass(final Module module, final PsiDirectory directory, final String className) {
final String packageName = DirectoryIndex.getInstance(module.getProject()).getPackageName(directory.getVirtualFile());
if (!StringUtil.getPackageName(className).equals(packageName))
return false;
final PsiElement psiElement = ActionScriptClassResolver.findClassByQNameStatic(className, GlobalSearchScope.moduleScope(module));
return psiElement instanceof JSClass && directory.equals(psiElement.getContainingFile().getParent());
}
use of com.intellij.lang.javascript.psi.ecmal4.JSClass in project intellij-plugins by JetBrains.
the class ModuleInfoUtil method collectApplicationLocalStyle.
@Nullable
private static List<LocalStyleHolder> collectApplicationLocalStyle(final Module module, String flexSdkVersion, final ProblemsHolder problemsHolder, StringWriter stringWriter, ProjectComponentReferenceCounter projectComponentReferenceCounter, final AssetCounter assetCounter) {
GlobalSearchScope moduleWithDependenciesAndLibrariesScope = module.getModuleWithDependenciesAndLibrariesScope(false);
final List<JSClass> holders = new ArrayList<>(2);
if (flexSdkVersion.charAt(0) > '3') {
JSClass clazz = ((JSClass) ActionScriptClassResolver.findClassByQNameStatic(FlexCommonTypeNames.SPARK_APPLICATION, moduleWithDependenciesAndLibrariesScope));
// it is not legal case, but user can use patched/modified Flex SDK
if (clazz != null) {
holders.add(clazz);
}
}
JSClass mxApplicationClass = ((JSClass) ActionScriptClassResolver.findClassByQNameStatic(FlexCommonTypeNames.MX_APPLICATION, moduleWithDependenciesAndLibrariesScope));
// if null, mx.swc is not added to module dependencies
if (mxApplicationClass != null) {
holders.add(mxApplicationClass);
}
if (holders.isEmpty()) {
return null;
}
final StyleTagWriter styleTagWriter = new StyleTagWriter(new LocalCssWriter(stringWriter, problemsHolder, projectComponentReferenceCounter, assetCounter));
final List<LocalStyleHolder> result = new ArrayList<>();
final Processor<JSClass> processor = jsClass -> {
PsiFile psiFile = jsClass.getNavigationElement().getContainingFile();
if (!(psiFile instanceof XmlFile)) {
return true;
}
XmlTag rootTag = ((XmlFile) psiFile).getRootTag();
if (rootTag == null) {
return true;
}
final VirtualFile virtualFile = psiFile.getVirtualFile();
problemsHolder.setCurrentFile(virtualFile);
try {
for (final XmlTag subTag : rootTag.getSubTags()) {
if (subTag.getNamespace().equals(JavaScriptSupportLoader.MXML_URI3) && subTag.getLocalName().equals(FlexPredefinedTagNames.STYLE)) {
try {
LocalStyleHolder localStyleHolder = styleTagWriter.write(subTag, module, virtualFile);
if (localStyleHolder != null) {
result.add(localStyleHolder);
}
} catch (InvalidPropertyException e) {
problemsHolder.add(e);
}
}
}
} finally {
problemsHolder.setCurrentFile(null);
}
return true;
};
final GlobalSearchScope moduleScope = module.getModuleScope(false);
for (JSClass holder : holders) {
JSClassSearch.searchClassInheritors(holder, true, moduleScope).forEach(processor);
}
return result;
}
use of com.intellij.lang.javascript.psi.ecmal4.JSClass in project intellij-plugins by JetBrains.
the class ResolveExternalInlineStyleSourceAction method find.
public Navigatable find() {
JSClass classElement = ((JSClass) ActionScriptClassResolver.findClassByQNameStatic(parentFqn, scope));
assert classElement != null;
XmlTag rootTag = ((XmlFile) classElement.getNavigationElement().getContainingFile()).getRootTag();
assert rootTag != null && rootTag.getDescriptor() != null && rootTag.getDescriptor() instanceof ClassBackedElementDescriptor;
return find(rootTag, true);
}
use of com.intellij.lang.javascript.psi.ecmal4.JSClass in project intellij-plugins by JetBrains.
the class SocketInputHandlerImpl method goToClass.
private void goToClass() throws IOException {
final Module module = readModule();
final String className = reader.readUTF();
ApplicationManager.getApplication().invokeLater(() -> {
JSClass classElement = ((JSClass) ActionScriptClassResolver.findClassByQNameStatic(className, module.getModuleWithDependenciesAndLibrariesScope(false)));
classElement.navigate(true);
ProjectUtil.focusProjectWindow(classElement.getProject(), true);
});
}
use of com.intellij.lang.javascript.psi.ecmal4.JSClass in project intellij-plugins by JetBrains.
the class MyImplicitUsageProvider method isImplicitUsage.
@Override
public boolean isImplicitUsage(PsiElement element) {
if (!(element instanceof JSFunction)) {
return false;
}
final JSFunction method = (JSFunction) element;
final String methodName = method.getName();
if (methodName == null || !Character.isUpperCase(methodName.charAt(0)) || !(method.getParent() instanceof JSClass) || method.getParent() instanceof XmlBackedJSClassImpl) {
return false;
}
final JSClass clazz = (JSClass) method.getParent();
if (!ActionScriptClassResolver.isParentClass(clazz, "com.intellij.flex.uiDesigner.TestCase")) {
return false;
}
final JSAttributeList attributeList = method.getAttributeList();
if (attributeList == null || attributeList.getAccessType() != JSAttributeList.AccessType.PUBLIC) {
return false;
}
final VirtualFile projectBaseDir = element.getProject().getBaseDir();
if (projectBaseDir == null) {
return false;
}
File testSourcePath = new File(projectBaseDir.getPath(), RELATIVE_TEST_DATA_PATH);
if (!testSourcePath.exists()) {
testSourcePath = new File(projectBaseDir.getPath(), "flex/tools/flex-ui-designer/" + RELATIVE_TEST_DATA_PATH);
assert testSourcePath.exists();
}
final JSAttributeList classAttributeList = clazz.getAttributeList();
if (classAttributeList != null) {
final JSAttribute testAnnotation = classAttributeList.findAttributeByName("Test");
if (testAnnotation == null) {
return false;
}
return new File(testSourcePath, testAnnotation.getValueByName("dir").getSimpleValue() + File.separatorChar + methodName + ".mxml").exists();
}
return false;
}
Aggregations