use of com.intellij.lang.javascript.psi.ecmal4.JSClass in project intellij-plugins by JetBrains.
the class CreateFlexUnitTestDialog method createUIComponents.
private void createUIComponents() {
final Module module = ModuleUtil.findModuleForPsiElement(myContextClass);
assert module != null;
myPackageCombo = JSReferenceEditor.forPackageName(StringUtil.getPackageName(myContextClass.getQualifiedName()), module.getProject(), null, getTestClassPackageScope(module), RefactoringBundle.message("choose.destination.package"));
final Condition<JSClass> filter = jsClass -> {
final JSAttributeList attributeList = jsClass.getAttributeList();
return !jsClass.isInterface() && attributeList != null && !attributeList.hasModifier(JSAttributeList.ModifierType.FINAL);
};
mySuperClassField = JSReferenceEditor.forClassName("", module.getProject(), null, getSuperClassScope(module), null, filter, JSBundle.message("choose.super.class.title"));
final List<JSMemberInfo> memberInfos = new ArrayList<>();
JSMemberInfo.extractClassMembers(myContextClass, memberInfos, new MemberInfoBase.Filter<JSAttributeListOwner>() {
public boolean includeMember(final JSAttributeListOwner member) {
final JSAttributeList attributeList = member.getAttributeList();
return member instanceof JSFunction && ((JSFunction) member).getKind() != JSFunction.FunctionKind.CONSTRUCTOR && attributeList != null && attributeList.getAccessType() == JSAttributeList.AccessType.PUBLIC;
}
});
myMemberSelectionPanel = new JSMemberSelectionPanel("Generate test methods for:", memberInfos, null);
}
use of com.intellij.lang.javascript.psi.ecmal4.JSClass in project intellij-plugins by JetBrains.
the class NodeClassInfo method getNodeClassInfo.
static NodeClassInfo getNodeClassInfo(@NotNull final JSClass jsClass) {
final JSAttributeList classAttributes = jsClass.getAttributeList();
final boolean dynamic = classAttributes != null && classAttributes.hasModifier(JSAttributeList.ModifierType.DYNAMIC);
final Map<String, Icon> ownStaticFields = new THashMap<>();
final Map<String, Icon> ownStaticProperties = new THashMap<>();
final Map<String, Icon> ownFields = new THashMap<>();
final Map<String, Icon> ownProperties = new THashMap<>();
final Map<String, Icon> inheritedStaticFields = new THashMap<>();
final Map<String, Icon> inheritedStaticProperties = new THashMap<>();
final Map<String, Icon> inheritedFields = new THashMap<>();
final Map<String, Icon> inheritedProperties = new THashMap<>();
fillMapsForClass(jsClass, ownStaticFields, ownStaticProperties, ownFields, ownProperties);
fillMapsForSupersRecursively(jsClass, new THashSet<>(), inheritedStaticFields, inheritedStaticProperties, inheritedFields, inheritedProperties);
return new NodeClassInfo(normalizeIfVector(jsClass.getQualifiedName()), dynamic, ownStaticFields, ownStaticProperties, ownFields, ownProperties, inheritedStaticFields, inheritedStaticProperties, inheritedFields, inheritedProperties);
}
use of com.intellij.lang.javascript.psi.ecmal4.JSClass in project intellij-plugins by JetBrains.
the class NodeClassInfo method fillMapsForClass.
private static void fillMapsForClass(final JSClass jsClass, final Map<String, Icon> staticFields, final Map<String, Icon> staticProperties, final Map<String, Icon> fields, final Map<String, Icon> properties) {
for (final JSField variable : jsClass.getFields()) {
final JSAttributeList varAttributes = variable.getAttributeList();
if (varAttributes != null && varAttributes.hasModifier(JSAttributeList.ModifierType.STATIC)) {
staticFields.put(variable.getName(), variable.getIcon(Iconable.ICON_FLAG_VISIBILITY));
} else {
fields.put(variable.getName(), variable.getIcon(Iconable.ICON_FLAG_VISIBILITY));
}
}
for (final JSFunction function : jsClass.getFunctions()) {
if (function.getKind() == JSFunction.FunctionKind.GETTER && function.getName() != null) {
final JSAttributeList functionAttributes = function.getAttributeList();
if (functionAttributes != null && functionAttributes.hasModifier(JSAttributeList.ModifierType.STATIC)) {
staticProperties.put(function.getName(), function.getIcon(Iconable.ICON_FLAG_VISIBILITY));
} else {
properties.put(function.getName(), function.getIcon(Iconable.ICON_FLAG_VISIBILITY));
}
}
}
if (jsClass instanceof MxmlJSClass) {
final PsiFile file = jsClass.getContainingFile();
final XmlFile xmlFile = file instanceof XmlFile ? (XmlFile) file : null;
final XmlTag rootTag = xmlFile == null ? null : xmlFile.getRootTag();
if (rootTag != null) {
processSubtagsRecursively(rootTag, tag -> {
final String id = tag.getAttributeValue("id");
if (id != null) {
fields.put(id, tag.getIcon(Iconable.ICON_FLAG_VISIBILITY));
}
return !MxmlJSClass.isTagThatAllowsAnyXmlContent(tag);
});
}
}
}
use of com.intellij.lang.javascript.psi.ecmal4.JSClass in project intellij-plugins by JetBrains.
the class FlexValue method findJSClass.
@Nullable
private static JSClass findJSClass(final Project project, @Nullable final Module module, final String typeFromFlexValueResult) {
String type = getType(typeFromFlexValueResult);
if (type != null) {
if (isGenericVector(type)) {
type = VECTOR;
}
final JavaScriptIndex jsIndex = JavaScriptIndex.getInstance(project);
PsiElement jsClass = ActionScriptClassResolver.findClassByQName(type, jsIndex, module);
if (!(jsClass instanceof JSClass) && type.endsWith("$")) {
// fdb adds '$' to class name in case of static context
jsClass = ActionScriptClassResolver.findClassByQName(type.substring(0, type.length() - 1), jsIndex, module);
}
if (!(jsClass instanceof JSClass) && module != null) {
// probably this class came from dynamically loaded module that is not in moduleWithDependenciesAndLibrariesScope(module)
final GlobalSearchScope scope = ProjectScope.getAllScope(project);
jsClass = ActionScriptClassResolver.findClassByQNameStatic(type, scope);
if (!(jsClass instanceof JSClass) && type.endsWith("$")) {
jsClass = ActionScriptClassResolver.findClassByQNameStatic(type.substring(0, type.length() - 1), scope);
}
}
return jsClass instanceof JSClass ? (JSClass) jsClass : null;
}
return null;
}
use of com.intellij.lang.javascript.psi.ecmal4.JSClass in project intellij-plugins by JetBrains.
the class FlashRunnerParameters method doCheck.
private void doCheck(final Pair<Module, FlexBuildConfiguration> moduleAndBC) throws RuntimeConfigurationError {
final FlexBuildConfiguration bc = moduleAndBC.second;
final Sdk sdk = bc.getSdk();
if (sdk == null) {
throw new RuntimeConfigurationError(FlexCommonBundle.message("sdk.not.set.for.bc.0.of.module.1", bc.getName(), moduleAndBC.first.getName()));
}
if (myOverrideMainClass) {
if (myOverriddenMainClass.isEmpty()) {
throw new RuntimeConfigurationError(FlexBundle.message("main.class.not.set"));
}
PsiElement clazz = ActionScriptClassResolver.findClassByQNameStatic(myOverriddenMainClass, moduleAndBC.first.getModuleScope(true));
if (!(clazz instanceof JSClass)) {
throw new RuntimeConfigurationError(FlexBundle.message("main.class.not.found", myOverriddenMainClass, bc.getName()));
}
if (myOverriddenOutputFileName.isEmpty()) {
throw new RuntimeConfigurationError(FlexBundle.message("output.file.name.not.specified"));
}
if (!myOverriddenOutputFileName.toLowerCase().endsWith(".swf")) {
throw new RuntimeConfigurationError(FlexBundle.message("output.file.must.have.swf.extension"));
}
} else {
if (bc.getOutputType() != OutputType.Application) {
throw new RuntimeConfigurationError(FlexBundle.message("bc.does.not.produce.app", getBCName(), getModuleName()));
}
}
switch(bc.getTargetPlatform()) {
case Web:
if (myLaunchUrl) {
if (myUrl.isEmpty())
throw new RuntimeConfigurationError(FlexBundle.message("flex.run.config.url.not.set"));
try {
if (BrowserUtil.getURL(myUrl) == null)
throw new RuntimeConfigurationError(FlexBundle.message("flex.run.config.incorrect.url"));
} catch (MalformedURLException e) {
throw new RuntimeConfigurationError(FlexBundle.message("flex.run.config.incorrect.url"));
}
//if (myLauncherParameters.getLauncherType() == LauncherParameters.LauncherType.Player) {
// throw new RuntimeConfigurationError(FlexBundle.message("flex.run.config.url.can.not.be.run.with.flash.player"));
//}
}
if (myLauncherParameters.getLauncherType() == LauncherParameters.LauncherType.Player) {
if (StringUtil.isEmptyOrSpaces(myLauncherParameters.getPlayerPath())) {
throw new RuntimeConfigurationError(FlexBundle.message("path.to.flash.player.not.set"));
}
if (!new File(myLauncherParameters.getPlayerPath()).exists()) {
throw new RuntimeConfigurationError(FlexBundle.message("flash.player.not.found", myLauncherParameters.getPresentableText()));
}
}
checkDebuggerSdk();
break;
case Desktop:
checkAdlAndAirRuntime(sdk);
if (bc.getOutputType() == OutputType.Application) {
checkCustomDescriptor(bc.getAirDesktopPackagingOptions(), getBCName(), getModuleName());
}
break;
case Mobile:
switch(myMobileRunTarget) {
case Emulator:
checkAdlAndAirRuntime(sdk);
if (bc.getOutputType() == OutputType.Application) {
switch(myAppDescriptorForEmulator) {
case Android:
checkCustomDescriptor(bc.getAndroidPackagingOptions(), getBCName(), getModuleName());
break;
case IOS:
checkCustomDescriptor(bc.getIosPackagingOptions(), getBCName(), getModuleName());
break;
}
}
break;
case AndroidDevice:
if (bc.getOutputType() == OutputType.Application) {
checkCustomDescriptor(bc.getAndroidPackagingOptions(), getBCName(), getModuleName());
}
break;
case iOSSimulator:
if (bc.getOutputType() == OutputType.Application) {
checkCustomDescriptor(bc.getIosPackagingOptions(), getBCName(), getModuleName());
}
if (!SystemInfo.isMac) {
throw new RuntimeConfigurationError(FlexBundle.message("ios.simulator.on.mac.only.warning"));
}
if (myIOSSimulatorSdkPath.isEmpty()) {
throw new RuntimeConfigurationError(FlexBundle.message("ios.simulator.sdk.not.set"));
} else if (!new File(FileUtil.toSystemDependentName(myIOSSimulatorSdkPath)).isDirectory()) {
throw new RuntimeConfigurationError(FlexBundle.message("ios.simulator.sdk.not.found", FileUtil.toSystemDependentName(myIOSSimulatorSdkPath)));
}
break;
case iOSDevice:
if (bc.getOutputType() == OutputType.Application) {
checkCustomDescriptor(bc.getIosPackagingOptions(), getBCName(), getModuleName());
}
break;
}
break;
}
}
Aggregations