use of com.intellij.openapi.util.Trinity in project intellij-community by JetBrains.
the class GrClosureSignatureUtil method getSignatureApplicabilities.
private static List<Trinity<GrClosureSignature, ArgInfo<PsiType>[], ApplicabilityResult>> getSignatureApplicabilities(@NotNull GrSignature signature, @NotNull final PsiType[] args, @NotNull final PsiElement context) {
final List<Trinity<GrClosureSignature, ArgInfo<PsiType>[], ApplicabilityResult>> results = new ArrayList<>();
signature.accept(new GrRecursiveSignatureVisitor() {
@Override
public void visitClosureSignature(GrClosureSignature signature) {
ArgInfo<PsiType>[] map = mapArgTypesToParameters(signature, args, context, false);
if (map != null) {
results.add(new Trinity<>(signature, map, isSignatureApplicableInner(map, signature)));
return;
}
// check for the case foo([1, 2, 3]) if foo(int, int, int)
if (args.length == 1 && PsiUtil.isInMethodCallContext(context)) {
final GrClosureParameter[] parameters = signature.getParameters();
if (parameters.length == 1 && parameters[0].getType() instanceof PsiArrayType) {
return;
}
PsiType arg = args[0];
if (arg instanceof GrTupleType) {
PsiType[] _args = ((GrTupleType) arg).getComponentTypes();
map = mapArgTypesToParameters(signature, _args, context, false);
if (map != null) {
results.add(new Trinity<>(signature, map, isSignatureApplicableInner(map, signature)));
}
}
}
}
});
return results;
}
use of com.intellij.openapi.util.Trinity in project intellij-community by JetBrains.
the class MavenProjectModelModifier method addDependency.
private Promise<Void> addDependency(@NotNull Collection<Module> fromModules, @NotNull final MavenId mavenId, @Nullable String minVersion, @Nullable String maxVersion, @NotNull final DependencyScope scope) {
final List<Trinity<MavenDomProjectModel, MavenId, String>> models = new ArrayList<>(fromModules.size());
List<XmlFile> files = new ArrayList<>(fromModules.size());
List<MavenProject> projectToUpdate = new ArrayList<>(fromModules.size());
final String mavenScope = getMavenScope(scope);
for (Module from : fromModules) {
if (!myProjectsManager.isMavenizedModule(from))
return null;
MavenProject fromProject = myProjectsManager.findProject(from);
if (fromProject == null)
return null;
final MavenDomProjectModel model = MavenDomUtil.getMavenDomProjectModel(myProject, fromProject.getFile());
if (model == null)
return null;
String scopeToSet = null;
String version = null;
if (mavenId.getGroupId() != null && mavenId.getArtifactId() != null) {
MavenDomDependency managedDependency = MavenDependencyCompletionUtil.findManagedDependency(model, myProject, mavenId.getGroupId(), mavenId.getArtifactId());
if (managedDependency != null) {
String managedScope = StringUtil.nullize(managedDependency.getScope().getStringValue(), true);
scopeToSet = (managedScope == null && MavenConstants.SCOPE_COMPILE.equals(mavenScope)) || StringUtil.equals(managedScope, mavenScope) ? null : mavenScope;
}
if (managedDependency == null || StringUtil.isEmpty(managedDependency.getVersion().getStringValue())) {
version = selectVersion(mavenId, minVersion, maxVersion);
}
}
models.add(Trinity.create(model, new MavenId(mavenId.getGroupId(), mavenId.getArtifactId(), version), scopeToSet));
files.add(DomUtil.getFile(model));
projectToUpdate.add(fromProject);
}
new WriteCommandAction(myProject, "Add Maven Dependency", PsiUtilCore.toPsiFileArray(files)) {
@Override
protected void run(@NotNull Result result) throws Throwable {
for (Trinity<MavenDomProjectModel, MavenId, String> trinity : models) {
final MavenDomProjectModel model = trinity.first;
MavenDomDependency dependency = MavenDomUtil.createDomDependency(model, null, trinity.second);
String mavenScope = trinity.third;
if (mavenScope != null) {
dependency.getScope().setStringValue(mavenScope);
}
Document document = PsiDocumentManager.getInstance(myProject).getDocument(DomUtil.getFile(model));
if (document != null) {
FileDocumentManager.getInstance().saveDocument(document);
}
}
}
}.execute();
return myProjectsManager.forceUpdateProjects(projectToUpdate);
}
use of com.intellij.openapi.util.Trinity in project intellij-plugins by JetBrains.
the class KeystorePasswordDialog method createPasswordFields.
private Collection<Trinity<AirSigningOptions, JPasswordField, JPasswordField>> createPasswordFields(final Collection<AirSigningOptions> signingOptionsWithUnknownPasswords) {
final Collection<Trinity<AirSigningOptions, JPasswordField, JPasswordField>> result = new ArrayList<>();
final JPanel panel = new JPanel(new GridBagLayout());
myMainPanel.add(panel, BorderLayout.CENTER);
int row = 0;
for (AirSigningOptions signingOptions : signingOptionsWithUnknownPasswords) {
if (row > 0) {
panel.add(new JSeparator(SwingConstants.HORIZONTAL), new GridBagConstraints(0, row, 2, 1, 0., 0., GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, JBUI.insets(5, 0), 0, 0));
row++;
}
panel.add(new JLabel("Keystore file:"), new GridBagConstraints(0, row, 1, 1, 0., 0., GridBagConstraints.WEST, GridBagConstraints.NONE, JBUI.insets(2, 0), 0, 0));
panel.add(new JLabel(FileUtil.toSystemDependentName(signingOptions.getKeystorePath())), new GridBagConstraints(1, row, 1, 1, 0., 0., GridBagConstraints.WEST, GridBagConstraints.NONE, JBUI.insets(2, 0), 0, 0));
row++;
panel.add(new JLabel("Keystore password:"), new GridBagConstraints(0, row, 1, 1, 0., 0., GridBagConstraints.WEST, GridBagConstraints.NONE, JBUI.insets(2, 0), 0, 0));
final JPasswordField keystorePasswordField = new JPasswordField();
panel.add(keystorePasswordField, new GridBagConstraints(1, row, 1, 1, 0., 0., GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, JBUI.insets(2, 0), 0, 0));
if (row == 1) {
myPreferredFocusedComponent = keystorePasswordField;
}
row++;
if (signingOptions.getKeyAlias().isEmpty()) {
result.add(Trinity.create(signingOptions, keystorePasswordField, (JPasswordField) null));
} else {
panel.add(new JLabel("Key alias:"), new GridBagConstraints(0, row, 1, 1, 0., 0., GridBagConstraints.WEST, GridBagConstraints.NONE, JBUI.insets(2, 0), 0, 0));
panel.add(new JLabel(signingOptions.getKeyAlias()), new GridBagConstraints(1, row, 1, 1, 0., 0., GridBagConstraints.WEST, GridBagConstraints.NONE, JBUI.insets(2, 0), 0, 0));
row++;
panel.add(new JLabel("Key password:"), new GridBagConstraints(0, row, 1, 1, 0., 0., GridBagConstraints.WEST, GridBagConstraints.NONE, JBUI.insets(2, 0), 0, 0));
final JPasswordField keyPasswordField = new JPasswordField();
panel.add(keyPasswordField, new GridBagConstraints(1, row, 1, 1, 0., 0., GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, JBUI.insets(2, 0), 0, 0));
row++;
result.add(Trinity.create(signingOptions, keystorePasswordField, keyPasswordField));
}
}
return result;
}
use of com.intellij.openapi.util.Trinity in project intellij-plugins by JetBrains.
the class ValidateFlashConfigurationsPrecompileTask method getProblems.
static Collection<Trinity<Module, FlexBuildConfiguration, FlashProjectStructureProblem>> getProblems(final CompileScope scope, final Collection<Pair<Module, FlexBuildConfiguration>> modulesAndBCsToCompile) {
final Collection<Trinity<Module, FlexBuildConfiguration, FlashProjectStructureProblem>> problems = new ArrayList<>();
for (final Pair<Module, FlexBuildConfiguration> moduleAndBC : modulesAndBCsToCompile) {
final Module module = moduleAndBC.first;
final FlexBuildConfiguration bc = moduleAndBC.second;
final Consumer<FlashProjectStructureProblem> errorConsumer = problem -> problems.add(Trinity.create(module, bc, problem));
checkConfiguration(module, bc, false, errorConsumer);
final RunConfiguration runConfig = CompileStepBeforeRun.getRunConfiguration(scope);
if (bc.getNature().isApp() && runConfig instanceof FlashRunConfiguration) {
final FlashRunnerParameters params = ((FlashRunConfiguration) runConfig).getRunnerParameters();
if (module.getName().equals(params.getModuleName()) && bc.getName().equals(params.getBCName())) {
if (bc.getNature().isDesktopPlatform()) {
FlashRunnerParameters.checkAirVersionIfCustomDescriptor(module, bc.getSdk(), bc.getAirDesktopPackagingOptions(), errorConsumer, false, "does not matter");
} else if (bc.getNature().isMobilePlatform()) {
switch(params.getMobileRunTarget()) {
case Emulator:
switch(params.getAppDescriptorForEmulator()) {
case Android:
FlashRunnerParameters.checkAirVersionIfCustomDescriptor(module, bc.getSdk(), bc.getAndroidPackagingOptions(), errorConsumer, false, "does not matter");
break;
case IOS:
FlashRunnerParameters.checkAirVersionIfCustomDescriptor(module, bc.getSdk(), bc.getIosPackagingOptions(), errorConsumer, false, "does not matter");
break;
}
break;
case AndroidDevice:
checkPackagingOptions(module, bc.getSdk(), bc.getAndroidPackagingOptions(), false, PathUtil.getParentPath(bc.getActualOutputFilePath()), errorConsumer);
break;
case iOSSimulator:
checkPackagingOptions(module, bc.getSdk(), bc.getIosPackagingOptions(), true, PathUtil.getParentPath(bc.getActualOutputFilePath()), errorConsumer);
break;
case iOSDevice:
checkPackagingOptions(module, bc.getSdk(), bc.getIosPackagingOptions(), false, PathUtil.getParentPath(bc.getActualOutputFilePath()), errorConsumer);
break;
}
}
}
}
}
checkSimilarOutputFiles(modulesAndBCsToCompile, trinity -> problems.add(trinity));
return problems;
}
Aggregations