Example usage for com.intellij.openapi.application ApplicationStarter EP_NAME

List of usage examples for com.intellij.openapi.application ApplicationStarter EP_NAME

Introduction

In this page you can find the example usage for com.intellij.openapi.application ApplicationStarter EP_NAME.

Prototype

ExtensionPointName EP_NAME

To view the source code for com.intellij.openapi.application ApplicationStarter EP_NAME.

Click Source Link

Usage

From source file:com.intellij.ide.CommandLineProcessor.java

License:Apache License

@Nullable
public static Project processExternalCommandLine(List<String> args, @Nullable String currentDirectory) {
    if (args.size() > 0) {
        LOG.info("External command line:");
        for (String arg : args) {
            LOG.info(arg);/*from www  .j  a v a 2s  .  c o m*/
        }
    }
    LOG.info("-----");

    if (args.size() > 0) {
        String command = args.get(0);
        for (ApplicationStarter starter : Extensions.getExtensions(ApplicationStarter.EP_NAME)) {
            if (starter instanceof ApplicationStarterEx && command.equals(starter.getCommandName())) {
                LOG.info("Processing command with " + starter);
                ((ApplicationStarterEx) starter).processExternalCommandLine(ArrayUtil.toStringArray(args),
                        currentDirectory);
                return null;
            }
        }
    }

    Project lastOpenedProject = null;
    int line = -1;
    for (int i = 0, argsSize = args.size(); i < argsSize; i++) {
        String arg = args.get(i);
        if (arg.equals(StartupUtil.NO_SPLASH)) {
            continue;
        }
        if (arg.equals("-l") || arg.equals("--line")) {
            //noinspection AssignmentToForLoopParameter
            i++;
            if (i == args.size()) {
                break;
            }
            try {
                line = Integer.parseInt(args.get(i));
            } catch (NumberFormatException e) {
                line = -1;
            }
        } else {
            if (StringUtil.isQuotedString(arg)) {
                arg = StringUtil.stripQuotesAroundValue(arg);
            }
            if (currentDirectory != null && !new File(arg).isAbsolute()) {
                arg = new File(currentDirectory, arg).getAbsolutePath();
            }
            if (line != -1) {
                final VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByPath(arg);
                if (virtualFile != null) {
                    lastOpenedProject = doOpenFile(virtualFile, line);
                } else {
                    Messages.showErrorDialog("Cannot find file '" + arg + "'", "Cannot find file");
                }
            } else {
                lastOpenedProject = doOpenFileOrProject(arg);
            }
        }
    }
    return lastOpenedProject;
}

From source file:com.intellij.idea.IdeaApplication.java

License:Apache License

@NotNull
public ApplicationStarter getStarter() {
    if (myArgs.length > 0) {
        PluginManagerCore.getPlugins();/* w  w  w . j  a v a2s .  com*/

        final ApplicationStarter[] starters = ApplicationStarter.EP_NAME.getExtensions();
        String key = myArgs[0];
        for (ApplicationStarter o : starters) {
            if (Comparing.equal(o.getCommandName(), key))
                return o;
        }
    }

    return new IdeStarter();
}