use of com.intellij.flex.model.bc.LinkageType in project intellij-plugins by JetBrains.
the class BuildConfigurationProjectStructureElement method checkIfBCOutputUsedAs3rdPartyLib.
private void checkIfBCOutputUsedAs3rdPartyLib(final ProjectStructureProblemsHolder problemsHolder, final FlexBCConfigurator configurator, final DependencyEntry entry, final VirtualFile[] classesRoots) {
for (VirtualFile libFile : classesRoots) {
final VirtualFile realFile = FlexCompilerHandler.getRealFile(libFile);
if (realFile != null && !realFile.isDirectory() && "swc".equalsIgnoreCase(realFile.getExtension())) {
final List<ModifiableFlexBuildConfiguration> bcs = configurator.getBCsByOutputPath(realFile.getPath());
if (bcs != null && !bcs.isEmpty()) {
final ModifiableFlexBuildConfiguration otherLibBC = bcs.get(0);
final FlexProjectConfigurationEditor editor = configurator.getConfigEditor();
assert editor != null;
final Module otherLibModule = editor.getModule(otherLibBC);
final String message = FlexBundle.message("own.lib.used.as.3rd.party", realFile.getName(), otherLibBC.getName(), otherLibModule.getName());
final Object location = entry instanceof ModuleLibraryEntry ? DependenciesConfigurable.Location.TableEntry.forModuleLibrary(((ModuleLibraryEntry) entry).getLibraryId()) : DependenciesConfigurable.Location.TableEntry.forSharedLibrary(((SharedLibraryEntry) entry).getLibraryLevel(), ((SharedLibraryEntry) entry).getLibraryName());
final PlaceInProjectStructure placeInPS = new PlaceInBuildConfiguration(this, DependenciesConfigurable.TAB_NAME, location);
final String quickFixName = FlexBundle.message("instead.setup.dependency.on.bc", otherLibBC.getName(), otherLibModule.getName());
final ConfigurationErrorQuickFix quickFix = new ConfigurationErrorQuickFix(quickFixName) {
public void performFix() {
final FlexBCConfigurable configurable = configurator.getBCConfigurable(myBc);
final DependenciesConfigurable dependenciesConfigurable = configurable.getDependenciesConfigurable();
final FlexBCConfigurable otherLibConfigurable = configurator.getBCConfigurable(otherLibBC);
final LinkageType linkageType = entry.getDependencyType().getLinkageType();
dependenciesConfigurable.addBCDependency(otherLibConfigurable, linkageType);
if (entry instanceof ModuleLibraryEntry) {
dependenciesConfigurable.removeDependency(((ModuleLibraryEntry) entry).getLibraryId());
} else {
dependenciesConfigurable.removeDependency(((SharedLibraryEntry) entry).getLibraryLevel(), ((SharedLibraryEntry) entry).getLibraryName());
}
final Place place = configurator.getPlaceFor(myModule, myBc.getName());
place.putPath(CompositeConfigurable.TAB_NAME, DependenciesConfigurable.TAB_NAME);
place.putPath(FlexBCConfigurable.LOCATION_ON_TAB, DependenciesConfigurable.Location.TableEntry.forBc(otherLibConfigurable));
ProjectStructureConfigurable.getInstance(myModule.getProject()).navigateTo(place, true);
}
};
final String errorId = entry instanceof ModuleLibraryEntry ? ((ModuleLibraryEntry) entry).getLibraryId() : ((SharedLibraryEntry) entry).getLibraryName();
problemsHolder.registerProblem(message, null, ProjectStructureProblemType.warning(errorId), placeInPS, quickFix);
}
}
}
}
use of com.intellij.flex.model.bc.LinkageType in project intellij-plugins by JetBrains.
the class DependenciesConfigurable method updateSdkEntries.
private void updateSdkEntries(DefaultMutableTreeNode sdkNode, Sdk sdk) {
sdkNode.removeAllChildren();
ComponentSet componentSet = (ComponentSet) myComponentSetCombo.getSelectedItem();
String targetPlayer = (String) myTargetPlayerCombo.getSelectedItem();
for (String url : sdk.getRootProvider().getUrls(OrderRootType.CLASSES)) {
final String swcPath = VirtualFileManager.extractPath(StringUtil.trimEnd(url, JarFileSystem.JAR_SEPARATOR));
LinkageType linkageType = FlexCommonUtils.getSdkEntryLinkageType(sdk.getHomePath(), swcPath, myNature, targetPlayer, componentSet);
if (linkageType == null) {
// this swc is not applicable
continue;
}
if (linkageType == LinkageType.Default) {
linkageType = (LinkageType) myFrameworkLinkageCombo.getSelectedItem();
if (linkageType == LinkageType.Default) {
linkageType = FlexCommonUtils.getDefaultFrameworkLinkage(sdk.getVersionString(), myNature);
}
}
SdkEntryItem item = new SdkEntryItem(FileUtil.toSystemDependentName(swcPath), linkageType);
sdkNode.add(new DefaultMutableTreeNode(item, false));
}
}
use of com.intellij.flex.model.bc.LinkageType in project intellij-plugins by JetBrains.
the class FlexScopeTest method testTransitiveDependency.
public void testTransitiveDependency() throws Exception {
final Module module2 = FlexTestUtils.createModule(myProject, "module2", getVirtualFile(getBasePath() + "m2"));
final Module module3 = FlexTestUtils.createModule(myProject, "module3", getVirtualFile(getBasePath() + "m3"));
FlexTestUtils.modifyConfigs(myProject, editor -> {
final ModifiableFlexBuildConfiguration bc1 = editor.getConfigurations(myModule)[0];
final ModifiableFlexBuildConfiguration bc2 = editor.getConfigurations(module2)[0];
bc2.setOutputType(OutputType.Library);
final ModifiableFlexBuildConfiguration bc3 = editor.getConfigurations(module3)[0];
bc3.setOutputType(OutputType.Library);
final ModifiableFlexBuildConfiguration bc3a = editor.createConfiguration(module3);
bc3a.setOutputType(OutputType.Library);
bc3a.setName("bc3a");
bc1.getDependencies().getModifiableEntries().add(editor.createBcEntry(bc1.getDependencies(), bc2, null));
bc2.getDependencies().getModifiableEntries().add(editor.createBcEntry(bc2.getDependencies(), bc3, null));
bc2.getDependencies().getModifiableEntries().add(editor.createBcEntry(bc2.getDependencies(), bc3a, null));
});
FlexTestUtils.addFlexLibrary(false, module2, "Flex Lib", true, FlexTestUtils.getTestDataPath("flexlib/"), "flexlib.swc", null, null);
doHighlightingTest("_1");
class Test implements ThrowableRunnable<Exception> {
private final LinkageType myLinkageType1;
private final LinkageType myLinkageType2;
private final String mySuffix;
Test(LinkageType linkageType1, LinkageType linkageType2, String suffix) {
myLinkageType1 = linkageType1;
myLinkageType2 = linkageType2;
mySuffix = suffix;
}
public void run() throws Exception {
FlexTestUtils.modifyConfigs(myProject, editor -> {
final ModifiableFlexBuildConfiguration bc = editor.getConfigurations(module2)[0];
final ModifiableDependencyEntry e1 = bc.getDependencies().getModifiableEntries().get(0);
e1.getDependencyType().setLinkageType(myLinkageType1);
final ModifiableDependencyEntry e2 = bc.getDependencies().getModifiableEntries().get(1);
e2.getDependencyType().setLinkageType(myLinkageType2);
});
doHighlightingTest(mySuffix);
}
}
new Test(LinkageType.Default, LinkageType.Default, "_1").run();
new Test(LinkageType.External, LinkageType.Default, "_1").run();
new Test(LinkageType.Include, LinkageType.Default, "_2").run();
new Test(LinkageType.LoadInRuntime, LinkageType.Default, "_1").run();
new Test(LinkageType.Merged, LinkageType.Default, "_1").run();
new Test(LinkageType.RSL, LinkageType.Default, "_1").run();
new Test(LinkageType.RSL, LinkageType.Include, "_2").run();
new Test(LinkageType.Include, LinkageType.Include, "_2").run();
FlexTestUtils.modifyConfigs(myProject, editor -> {
final ModifiableFlexBuildConfiguration bc2 = editor.getConfigurations(module2)[0];
final ModifiableDependencyEntry entry = bc2.getDependencies().getModifiableEntries().get(2);
assert entry instanceof ModifiableModuleLibraryEntry;
entry.getDependencyType().setLinkageType(LinkageType.Include);
});
new Test(LinkageType.Include, LinkageType.Include, "_3").run();
}
use of com.intellij.flex.model.bc.LinkageType in project intellij-plugins by JetBrains.
the class FlexOrderEnumerationHandler method processModuleWithBuildConfiguration.
// configuration is null for root module (one for which scope is being computed)
private static void processModuleWithBuildConfiguration(@NotNull Module module, @Nullable FlexBuildConfiguration bc, Map<Module, ModuleData> modules2activeConfigurations, Set<FlexBuildConfiguration> processedConfigurations, boolean productionDependency) {
if (ModuleType.get(module) != FlexModuleType.getInstance()) {
return;
}
final boolean isRootModule = bc == null;
if (isRootModule) {
bc = getActiveConfiguration(module);
}
if (bc == null || !processedConfigurations.add(bc)) {
return;
}
ModuleData moduleData = modules2activeConfigurations.get(module);
if (moduleData == null) {
modules2activeConfigurations.put(module, moduleData = new ModuleData());
}
moduleData.addBc(bc, productionDependency);
for (DependencyEntry entry : bc.getDependencies().getEntries()) {
if (!(entry instanceof BuildConfigurationEntry)) {
continue;
}
final LinkageType linkageType = entry.getDependencyType().getLinkageType();
if (linkageType == LinkageType.LoadInRuntime) {
continue;
}
FlexBuildConfiguration dependencyBc = ((BuildConfigurationEntry) entry).findBuildConfiguration();
if (dependencyBc == null || !FlexCommonUtils.checkDependencyType(bc.getOutputType(), dependencyBc.getOutputType(), linkageType)) {
continue;
}
if (!isRootModule && !BCUtils.isTransitiveDependency(linkageType)) {
continue;
}
Module dependencyModule = ((BuildConfigurationEntry) entry).findModule();
if (dependencyModule == null || dependencyModule == module) {
continue;
}
processModuleWithBuildConfiguration(dependencyModule, dependencyBc, modules2activeConfigurations, processedConfigurations, entry.getDependencyType().getLinkageType() != LinkageType.Test);
}
}
use of com.intellij.flex.model.bc.LinkageType in project intellij-plugins by JetBrains.
the class FlexCompilationUtils method performPostCompileActions.
public static void performPostCompileActions(final Module module, @NotNull final FlexBuildConfiguration bc, final List<String> compileInfoMessages) throws FlexCompilerException {
// could be created by external build
FlexCompilationManager.refreshAndFindFileInWriteAction(bc.getActualOutputFilePath());
final Sdk sdk = bc.getSdk();
assert sdk != null;
LinkageType linkage = bc.getDependencies().getFrameworkLinkage();
if (linkage == LinkageType.Default) {
linkage = FlexCommonUtils.getDefaultFrameworkLinkage(sdk.getVersionString(), bc.getNature());
}
if (linkage == LinkageType.RSL) {
handleFrameworkRsls(bc, compileInfoMessages);
}
if (bc.getOutputType() != OutputType.Application || BCUtils.isRLMTemporaryBC(bc) || BCUtils.isRuntimeStyleSheetBC(bc))
return;
switch(bc.getTargetPlatform()) {
case Web:
if (bc.isUseHtmlWrapper()) {
handleHtmlWrapper(module, bc);
}
break;
case Desktop:
handleAirDescriptor(module, bc, bc.getAirDesktopPackagingOptions());
break;
case Mobile:
if (bc.getAndroidPackagingOptions().isEnabled()) {
handleAirDescriptor(module, bc, bc.getAndroidPackagingOptions());
}
if (bc.getIosPackagingOptions().isEnabled()) {
handleAirDescriptor(module, bc, bc.getIosPackagingOptions());
}
break;
}
}
Aggregations