Java 类com.intellij.ui.CustomProtocolHandler 实例源码

项目:intellij-ce-playground    文件:IdeaApplication.java   
@Override
public void processExternalCommandLine(String[] args, @Nullable String currentDirectory) {
  LOG.info("Request to open in " + currentDirectory + " with parameters: " + StringUtil.join(args, ","));

  if (args.length > 0) {
    String filename = args[0];
    File file = new File(currentDirectory, filename);

    if(file.exists()) {
      VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file);
      if (virtualFile != null) {
        int line = -1;
        if (args.length > 2 && CustomProtocolHandler.LINE_NUMBER_ARG_NAME.equals(args[1])) {
          try {
            line = Integer.parseInt(args[2]);
          } catch (NumberFormatException ex) {
            LOG.error("Wrong line number:" + args[2]);
          }
        }
        PlatformProjectOpenProcessor.doOpenProject(virtualFile, null, false, line, null, false);
      }
    }
    throw new IncorrectOperationException("Can't find file:" + file);
  }
}