public CompilerUIConfigurable(@NotNull final Project project) { myProject = project; myPatternLegendLabel.setText(XmlStringUtil.wrapInHtml( "Use <b>;</b> to separate patterns and <b>!</b> to negate a pattern. " + "Accepted wildcards: <b>?</b> — exactly one symbol; <b>*</b> — zero or more symbols; " + "<b>/</b> — path separator; <b>/**/</b> — any number of directories; " + "<i><dir_name></i>:<i><pattern></i> — restrict to source roots with the specified name" )); myPatternLegendLabel.setForeground(new JBColor(Gray._50, Gray._130)); tweakControls(project); myVMOptionsField.getDocument().addDocumentListener(new DocumentAdapter() { protected void textChanged(DocumentEvent e) { mySharedVMOptionsField.setEnabled(e.getDocument().getLength() == 0); myHeapSizeField.setEnabled(ContainerUtil.find(ParametersListUtil.parse(myVMOptionsField.getText()), new Condition<String>() { @Override public boolean value(String s) { return StringUtil.startsWithIgnoreCase(s, "-Xmx"); } }) == null); } }); }
@NotNull @Override public List<String> getAdditionalParameters() { if (myCommandLineOptions == null) { if (myUseCustomProfile && myUserDataDirectoryPath != null) { return Collections.singletonList(USER_DATA_DIR_ARG + FileUtilRt.toSystemDependentName(myUserDataDirectoryPath)); } else { return Collections.emptyList(); } } List<String> cliOptions = ParametersListUtil.parse(myCommandLineOptions); if (myUseCustomProfile && myUserDataDirectoryPath != null) { cliOptions.add(USER_DATA_DIR_ARG + FileUtilRt.toSystemDependentName(myUserDataDirectoryPath)); } return cliOptions; }
@NotNull private static Map<String, String> getMavenOptsProperties() { Map<String, String> res = ourPropertiesFromMvnOpts; if (res == null) { String mavenOpts = System.getenv("MAVEN_OPTS"); if (mavenOpts != null) { res = new HashMap<String, String>(); final String[] split = ParametersListUtil.parseToArray(mavenOpts); for (String parameter : split) { final Matcher matcher = PROPERTY_PATTERN.matcher(parameter); if (matcher.matches()) { res.put(matcher.group(1), matcher.group(2)); } } } else { res = Collections.emptyMap(); } ourPropertiesFromMvnOpts = res; } return res; }
protected void setData(final MavenRunnerParameters data) { data.setWorkingDirPath(workingDirComponent.getComponent().getText()); data.setGoals(ParametersListUtil.parse(goalsComponent.getComponent().getText())); data.setResolveToWorkspace(myResolveToWorkspaceCheckBox.isSelected()); Map<String, Boolean> profilesMap = new LinkedHashMap<String, Boolean>(); List<String> profiles = ParametersListUtil.parse(profilesComponent.getComponent().getText()); for (String profile : profiles) { Boolean isEnabled = true; if (profile.startsWith("-") || profile.startsWith("!")) { profile = profile.substring(1); if (profile.isEmpty()) continue; isEnabled = false; } profilesMap.put(profile, isEnabled); } data.setProfilesMap(profilesMap); }
private void createUIComponents() { myProtectedBranchesButton = new TextFieldWithBrowseButton.NoPathCompletion(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Messages.showTextAreaDialog(myProtectedBranchesButton.getTextField(), "Protected Branches", "Git.Force.Push.Protected.Branches", ParametersListUtil.COLON_LINE_PARSER, ParametersListUtil.COLON_LINE_JOINER); } }); myProtectedBranchesButton.setButtonIcon(AllIcons.Actions.ShowViewer); myUpdateMethodComboBox = new ComboBox(new EnumComboBoxModel<UpdateMethod>(UpdateMethod.class)); myUpdateMethodComboBox.setRenderer(new ListCellRendererWrapper<UpdateMethod>() { @Override public void customize(JList list, UpdateMethod value, int index, boolean selected, boolean hasFocus) { setText(StringUtil.capitalize(StringUtil.toLowerCase(value.name().replace('_', ' ')))); } }); }
@NotNull private static List<String> calculateCommand(@NotNull final String interpreterPath, @NotNull final TheRRunConfiguration runConfiguration) { final List<String> command = new ArrayList<String>(); command.add(FileUtil.toSystemDependentName(interpreterPath)); command.addAll(TheRInterpreterConstants.DEFAULT_PARAMETERS); final String scriptArgs = runConfiguration.getScriptArgs(); if (!StringUtil.isEmptyOrSpaces(scriptArgs)) { command.add(TheRInterpreterConstants.ARGS_PARAMETER); command.addAll(ParametersListUtil.parse(scriptArgs)); } return command; }
@Nonnull private static Process execute(@Nonnull String exePath, @Nonnull String parametersTemplate, @Nonnull Map<String, String> patterns) throws ExecutionException { List<String> parameters = ParametersListUtil.parse(parametersTemplate, true); List<String> from = new ArrayList<>(); List<String> to = new ArrayList<>(); for (Map.Entry<String, String> entry : patterns.entrySet()) { from.add(entry.getKey()); to.add(entry.getValue()); } List<String> args = new ArrayList<>(); for (String parameter : parameters) { String arg = StringUtil.replace(parameter, from, to); if (!StringUtil.isEmptyOrSpaces(arg)) args.add(arg); } GeneralCommandLine commandLine = new GeneralCommandLine(); commandLine.setExePath(exePath); commandLine.addParameters(args); return commandLine.createProcess(); }
@Nonnull @Override public List<String> getAdditionalParameters() { if (myCommandLineOptions == null) { if (myUseCustomProfile && myUserDataDirectoryPath != null) { return Collections.singletonList(USER_DATA_DIR_ARG + FileUtilRt.toSystemDependentName(myUserDataDirectoryPath)); } else { return Collections.emptyList(); } } List<String> cliOptions = ParametersListUtil.parse(myCommandLineOptions); if (myUseCustomProfile && myUserDataDirectoryPath != null) { cliOptions.add(USER_DATA_DIR_ARG + FileUtilRt.toSystemDependentName(myUserDataDirectoryPath)); } return cliOptions; }
private static void checkTokenizer(String paramString, String... expected) { ParametersList params = new ParametersList(); params.addParametersString(paramString); assertEquals(asList(expected), params.getList()); List<String> lines = ParametersListUtil.parse(paramString, true); assertEquals(paramString, StringUtil.join(lines, " ")); }
@NotNull private static MultiMap<String, String> getBrokenPluginVersions() { if (ourBrokenPluginVersions == null) { ourBrokenPluginVersions = MultiMap.createSet(); if (System.getProperty("idea.ignore.disabled.plugins") == null && !isUnitTestMode()) { BufferedReader br = new BufferedReader(new InputStreamReader(PluginManagerCore.class.getResourceAsStream("/brokenPlugins.txt"))); try { String s; while ((s = br.readLine()) != null) { s = s.trim(); if (s.startsWith("//")) continue; List<String> tokens = ParametersListUtil.parse(s); if (tokens.isEmpty()) continue; if (tokens.size() == 1) { throw new RuntimeException("brokenPlugins.txt is broken. The line contains plugin name, but does not contains version: " + s); } String pluginId = tokens.get(0); List<String> versions = tokens.subList(1, tokens.size()); ourBrokenPluginVersions.putValues(pluginId, versions); } } catch (IOException e) { throw new RuntimeException("Failed to read /brokenPlugins.txt", e); } finally { StreamUtil.closeStream(br); } } } return ourBrokenPluginVersions; }
/** * Load settings into the configuration panel * * @param settings the settings to load */ public void load(@NotNull GitVcsSettings settings, @NotNull GitSharedSettings sharedSettings) { myGitField.setText(settings.getAppSettings().getPathToGit()); mySSHExecutableComboBox.setSelectedItem(settings.isIdeaSsh() ? IDEA_SSH : NATIVE_SSH); myAutoUpdateIfPushRejected.setSelected(settings.autoUpdateIfPushRejected()); mySyncControl.setSelected(settings.getSyncSetting() == DvcsSyncSettings.Value.SYNC); myAutoCommitOnCherryPick.setSelected(settings.isAutoCommitOnCherryPick()); myWarnAboutCrlf.setSelected(settings.warnAboutCrlf()); myWarnAboutDetachedHead.setSelected(settings.warnAboutDetachedHead()); myEnableForcePush.setSelected(settings.isForcePushAllowed()); myUpdateMethodComboBox.setSelectedItem(settings.getUpdateType()); myProtectedBranchesButton.setText(ParametersListUtil.COLON_LINE_JOINER.fun(sharedSettings.getForcePushProhibitedPatterns())); }
private static List<String> createCommandLine(CompileContext context, ModuleChunk chunk, List<File> srcFiles, String mainOutputDir, @Nullable ProcessorConfigProfile profile, GreclipseSettings settings) { final List<String> args = new ArrayList<String>(); args.add("-cp"); args.add(getClasspathString(chunk)); JavaBuilder.addCompilationOptions(args, context, chunk, profile); args.add("-d"); args.add(mainOutputDir); //todo AjCompilerSettings exact duplicate, JavaBuilder.loadCommonJavacOptions inexact duplicate List<String> params = ParametersListUtil.parse(settings.cmdLineParams); for (Iterator<String> iterator = params.iterator(); iterator.hasNext(); ) { String option = iterator.next(); if ("-target".equals(option)) { iterator.next(); continue; } else if (option.isEmpty() || "-g".equals(option) || "-verbose".equals(option)) { continue; } args.add(option); } if (settings.debugInfo) { args.add("-g"); } for (File file : srcFiles) { args.add(file.getPath()); } return args; }
/** Appends '--script_path' to blaze flags, then runs 'bash -c blaze build ... && run_script' */ private static List<String> getBashCommandsToRunScript(BlazeCommand.Builder blazeCommand) { File scriptFile = createTempOutputFile(); blazeCommand.addBlazeFlags("--script_path=" + scriptFile.getPath()); String blaze = ParametersListUtil.join(blazeCommand.build().toList()); return ImmutableList.of("/bin/bash", "-c", blaze + " && " + scriptFile.getPath()); }
private static String getScriptParams(BlazeCommandRunConfigurationCommonState state) { List<String> params = Lists.newArrayList(state.getExeFlagsState().getExpandedFlags()); String filterFlag = state.getTestFilterFlag(); if (filterFlag != null) { params.add(filterFlag.substring((BlazeFlags.TEST_FILTER + "=").length())); } return ParametersListUtil.join(params); }
@NotNull @Override public NotNullPairFunction<DotNetConfigurationWithCoverage, GeneralCommandLine, GeneralCommandLine> getModifierForCommandLine() { return new NotNullPairFunction<DotNetConfigurationWithCoverage, GeneralCommandLine, GeneralCommandLine>() { @NotNull @Override public GeneralCommandLine fun(DotNetConfigurationWithCoverage t, GeneralCommandLine v) { CoverageEnabledConfiguration coverageEnabledConfiguration = DotNetCoverageEnabledConfiguration.get(t); File openCoverConsoleExecutable = getOpenCoverConsoleExecutable(); GeneralCommandLine newCommandLine = new GeneralCommandLine(); newCommandLine.setExePath(openCoverConsoleExecutable.getPath()); newCommandLine.addParameter("-register:user"); newCommandLine.addParameter("-target:" + v.getExePath()); newCommandLine.addParameter("-filter:+[*]*"); newCommandLine.addParameter("-output:" + coverageEnabledConfiguration.getCoverageFilePath()); String parametersAsString = ParametersListUtil.join(v.getParametersList().getParameters()); if(!StringUtil.isEmpty(parametersAsString)) { newCommandLine.addParameter("-targetargs:" + parametersAsString + ""); } return newCommandLine; } }; }
@Override public boolean executeTask(DataContext dataContext, RunConfiguration runConfiguration, ExecutionEnvironment executionEnvironment, MuleBeforeRunTask muleBeforeRunTask) { final Semaphore targetDone = new Semaphore(); final List<Boolean> results = new ArrayList<>(); final Project project = executionEnvironment.getProject(); MuleConfiguration muleConfiguration = (MuleConfiguration) runConfiguration; Module[] modules = muleConfiguration.getModules(); for (Module nextModule : modules) { //final MavenProject mavenProject = getMavenProject(runConfiguration, project); final MavenProject mavenProject = getMavenProject(nextModule); try { ApplicationManager.getApplication().invokeAndWait(new Runnable() { public void run() { if (!project.isDisposed() && mavenProject != null) { FileDocumentManager.getInstance().saveAllDocuments(); final MavenExplicitProfiles explicitProfiles = MavenProjectsManager.getInstance(project).getExplicitProfiles(); final MavenRunner mavenRunner = MavenRunner.getInstance(project); targetDone.down(); (new Task.Backgroundable(project, TasksBundle.message("maven.tasks.executing"), true) { public void run(@NotNull ProgressIndicator indicator) { try { MavenRunnerParameters params = new MavenRunnerParameters(true, mavenProject.getDirectory(), ParametersListUtil.parse("package"), explicitProfiles.getEnabledProfiles(), explicitProfiles.getDisabledProfiles()); boolean result = mavenRunner.runBatch(Collections.singletonList(params), null, null, TasksBundle.message("maven.tasks.executing"), indicator); results.add(result); } finally { targetDone.up(); } } public boolean shouldStartInBackground() { return MavenRunner.getInstance(project).getSettings().isRunMavenInBackground(); } public void processSentToBackground() { MavenRunner.getInstance(project).getSettings().setRunMavenInBackground(true); } }).queue(); } } }, ModalityState.NON_MODAL); } catch (Exception exeception) { return false; } targetDone.waitFor(); } boolean endResult = true; for (Boolean nextResult : results) { endResult = endResult && nextResult; } return endResult; }
private void createUIComponents() { myResourcePatternsField = new RawCommandLineEditor(ParametersListUtil.COLON_LINE_PARSER, ParametersListUtil.COLON_LINE_JOINER); myResourcePatternsField.setDialogCaption("Resource patterns"); }
public static void showTextAreaDialog(final JTextField textField, final @Nls(capitalization = Nls.Capitalization.Title) String title, @NonNls final String dimensionServiceKey) { showTextAreaDialog(textField, title, dimensionServiceKey, ParametersListUtil.DEFAULT_LINE_PARSER, ParametersListUtil.DEFAULT_LINE_JOINER); }
/** * @see ParametersListUtil#join(java.util.List) */ @NotNull public static String join(@NotNull final List<String> parameters) { return ParametersListUtil.join(parameters); }
/** * @see ParametersListUtil#join(java.util.List) */ @NotNull public static String join(final String... parameters) { return ParametersListUtil.join(parameters); }
/** * @see ParametersListUtil#parseToArray(String) */ @NotNull public static String[] parse(@NotNull final String string) { return ParametersListUtil.parseToArray(string); }
public RawCommandLineEditor() { this(ParametersListUtil.DEFAULT_LINE_PARSER, ParametersListUtil.DEFAULT_LINE_JOINER); }
private static List<String> parseCmdParameters(@Nullable String cmdArgsLine) { return cmdArgsLine != null ? ParametersListUtil.parse(cmdArgsLine) : ContainerUtil.<String>newArrayList(); }
private static void appendJarClasspathParams(SimpleJavaParameters javaParameters, GeneralCommandLine commandLine, ParametersList vmParametersList, Class commandLineWrapper) { try { final Manifest manifest = new Manifest(); manifest.getMainAttributes().putValue("Created-By", ApplicationNamesInfo.getInstance().getFullProductName()); final boolean writeDynamicVMOptions = javaParameters.isDynamicVMOptions() && useDynamicVMOptions(); if (writeDynamicVMOptions) { List<String> dParams = new ArrayList<String>(); for (String param : vmParametersList.getList()) { if (param.startsWith("-D")) { dParams.add(param); } } manifest.getMainAttributes().putValue("VM-Options", ParametersListUtil.join(dParams)); final ArrayList<String> restParams = new ArrayList<String>(vmParametersList.getList()); restParams.removeAll(dParams); commandLine.addParameters(restParams); } else { commandLine.addParameters(vmParametersList.getList()); } final boolean notEscape = vmParametersList.hasParameter(PROPERTY_DO_NOT_ESCAPE_CLASSPATH_URL); final List<String> classPathList = javaParameters.getClassPath().getPathList(); final String jarFile = CommandLineWrapperUtil.createClasspathJarFile(manifest, classPathList, notEscape).getAbsolutePath(); commandLine.addParameter("-classpath"); if (writeDynamicVMOptions) { commandLine.addParameter(PathUtil.getJarPathForClass(commandLineWrapper) + File.pathSeparator + jarFile); appendEncoding(javaParameters, commandLine, vmParametersList); commandLine.addParameter(commandLineWrapper.getName()); commandLine.addParameter(jarFile); } else { commandLine.addParameters(jarFile); appendEncoding(javaParameters, commandLine, vmParametersList); } } catch (IOException e) { LOG.error(e); } }
@NotNull public static Map<AndroidCompilerMessageKind, List<String>> launchProguard(@NotNull IAndroidTarget target, int sdkToolsRevision, @NotNull String sdkOsPath, @NotNull String javaExecutablePath, @NotNull String proguardVmOptions, @NotNull String[] proguardConfigFileOsPaths, @NotNull String inputJarOsPath, @NotNull String[] externalJarOsPaths, @NotNull String[] providedJarOsPaths, @NotNull String outputJarFileOsPath, @Nullable String logDirOutputOsPath) throws IOException { final List<String> commands = new ArrayList<String>(); commands.add(javaExecutablePath); if (proguardVmOptions.length() > 0) { commands.addAll(ParametersListUtil.parse(proguardVmOptions)); } commands.add("-jar"); final String proguardHome = getProguardHomeDirOsPath(sdkOsPath); final String proguardJarOsPath = proguardHome + File.separator + "lib" + File.separator + "proguard.jar"; commands.add(proguardJarOsPath); if (isIncludingInProguardSupported(sdkToolsRevision)) { for (String proguardConfigFileOsPath : proguardConfigFileOsPaths) { commands.add("-include"); commands.add(quotePath(proguardConfigFileOsPath)); } } else { commands.add("@" + quotePath(proguardConfigFileOsPaths[0])); } commands.add("-injars"); StringBuilder builder = new StringBuilder(quotePath(inputJarOsPath)); for (String jarFile : externalJarOsPaths) { builder.append(File.pathSeparatorChar); builder.append(quotePath(jarFile)); } commands.add(builder.toString()); commands.add("-outjars"); commands.add(quotePath(outputJarFileOsPath)); commands.add("-libraryjars"); builder = new StringBuilder(quotePath(target.getPath(IAndroidTarget.ANDROID_JAR))); List<IAndroidTarget.OptionalLibrary> libraries = target.getAdditionalLibraries(); for (IAndroidTarget.OptionalLibrary lib : libraries) { builder.append(File.pathSeparatorChar); builder.append(quotePath(lib.getJar().getAbsolutePath())); } for (String path : providedJarOsPaths) { builder.append(File.pathSeparatorChar); builder.append(quotePath(path)); } commands.add(builder.toString()); if (logDirOutputOsPath != null) { commands.add("-dump"); commands.add(quotePath(new File(logDirOutputOsPath, "dump.txt").getAbsolutePath())); commands.add("-printseeds"); commands.add(quotePath(new File(logDirOutputOsPath, "seeds.txt").getAbsolutePath())); commands.add("-printusage"); commands.add(quotePath(new File(logDirOutputOsPath, "usage.txt").getAbsolutePath())); commands.add("-printmapping"); commands.add(quotePath(new File(logDirOutputOsPath, "mapping.txt").getAbsolutePath())); } LOG.info(command2string(commands)); final Map<String, String> home = System.getenv().containsKey(PROGUARD_HOME_ENV_VARIABLE) ? Collections.<String, String>emptyMap() : Collections.singletonMap(PROGUARD_HOME_ENV_VARIABLE, proguardHome); return AndroidExecutionUtil.doExecute(ArrayUtil.toStringArray(commands), home); }
public ExternalEnhancerProcessHandler(Process process, List<String> commandLine, CompileContext context) { super(process, ParametersListUtil.join(commandLine), null); myContext = context; }
public boolean executeTask(final DataContext context, RunConfiguration configuration, ExecutionEnvironment env, final MavenBeforeRunTask task) { final Semaphore targetDone = new Semaphore(); final boolean[] result = new boolean[]{true}; try { ApplicationManager.getApplication().invokeAndWait(new Runnable() { public void run() { final Project project = CommonDataKeys.PROJECT.getData(context); final MavenProject mavenProject = getMavenProject(task); if (project == null || project.isDisposed() || mavenProject == null) return; FileDocumentManager.getInstance().saveAllDocuments(); final MavenExplicitProfiles explicitProfiles = MavenProjectsManager.getInstance(project).getExplicitProfiles(); final MavenRunner mavenRunner = MavenRunner.getInstance(project); targetDone.down(); new Task.Backgroundable(project, TasksBundle.message("maven.tasks.executing"), true) { public void run(@NotNull ProgressIndicator indicator) { try { MavenRunnerParameters params = new MavenRunnerParameters( true, mavenProject.getDirectory(), ParametersListUtil.parse(task.getGoal()), explicitProfiles.getEnabledProfiles(), explicitProfiles.getDisabledProfiles()); result[0] = mavenRunner.runBatch(Collections.singletonList(params), null, null, TasksBundle.message("maven.tasks.executing"), indicator); } finally { targetDone.up(); } } @Override public boolean shouldStartInBackground() { return MavenRunner.getInstance(project).getSettings().isRunMavenInBackground(); } @Override public void processSentToBackground() { MavenRunner.getInstance(project).getSettings().setRunMavenInBackground(true); } }.queue(); } }, ModalityState.NON_MODAL); } catch (Exception e) { MavenLog.LOG.error(e); return false; } targetDone.waitFor(); return result[0]; }
@NotNull private List<String> getProtectedBranchesPatterns() { return ParametersListUtil.COLON_LINE_PARSER.fun(myProtectedBranchesButton.getText()); }
@NotNull public static String getExecutablePath(@Nullable String tunnelSetting) { // TODO: Add additional platform specific checks return StringUtil.notNullize(ContainerUtil.getFirstItem(ParametersListUtil.parse(getSshTunnelValue(tunnelSetting)))).trim(); }
@Override public void applyEditorTo(RunConfigurationState genericState) { RunConfigurationFlagsState state = (RunConfigurationFlagsState) genericState; state.setRawFlags(ParametersListUtil.parse(Strings.nullToEmpty(flagsField.getText()))); }
/** * Copy from {@link ExternalSystemExecuteTaskTask#parseCmdParameters} because it is private. */ public static List<String> parseCmdParameters(Optional<String> cmdArgsLine) { return cmdArgsLine.map(ParametersListUtil::parse).orElse(ContainerUtil.newArrayList()); }
public static void showTextAreaDialog(final JTextField textField, final String title, @NonNls final String dimensionServiceKey) { showTextAreaDialog(textField, title, dimensionServiceKey, ParametersListUtil.DEFAULT_LINE_PARSER, ParametersListUtil.DEFAULT_LINE_JOINER); }