Java 类com.intellij.openapi.application.PathMacros 实例源码

项目:intellij-ce-playground    文件:PathMacrosCollector.java   
@NotNull
public static Set<String> getMacroNames(Element root, @Nullable PathMacroFilter filter, @NotNull PathMacros pathMacros) {
  final PathMacrosCollector collector = new PathMacrosCollector();
  collector.substitute(root, true, false, filter);
  Set<String> preResult = collector.myMacroMap.keySet();
  if (preResult.isEmpty()) {
    return Collections.emptySet();
  }

  Set<String> result = new SmartHashSet<String>(preResult);
  result.removeAll(pathMacros.getSystemMacroNames());
  result.removeAll(pathMacros.getLegacyMacroNames());
  result.removeAll(PathMacrosImpl.getToolMacroNames());
  result.removeAll(pathMacros.getIgnoredMacroNames());
  return result;
}
项目:intellij-ce-playground    文件:PathMacroManagerTest.java   
private void setUpMocks(final String projectPath) {
  myModule = context.mock(Module.class);
  myPathMacros = context.mock(PathMacrosImpl.class);
  myProject = context.mock(ProjectEx.class);

  final VirtualFile projectFile = context.mock(VirtualFile.class, "projectFile");

  context.checking(new Expectations() {{
    allowing(myModule).isDisposed(); will(returnValue(false));
    allowing(myProject).isDisposed(); will(returnValue(false));

    allowing(projectFile).getPath(); will(returnValue(projectPath));

    final String moduleFilePath = projectPath + "/module/module.iml";

    allowing(myApplication).getComponent(with(equal(PathMacros.class))); will(returnValue(myPathMacros));
    allowing(myPathMacros).addMacroReplacements(with(any(ReplacePathToMacroMap.class)));

    allowing(myProject).getBaseDir(); will(returnValue(projectFile));
    allowing(myModule).getModuleFilePath(); will(returnValue(moduleFilePath));
    allowing(myModule).getProject(); will(returnValue(myProject));
  }});
}
项目:intellij-ce-playground    文件:EclipseVarsTest.java   
@Override
protected void setUp() throws Exception {
  super.setUp();
  final File testRoot = new File(PluginPathManager.getPluginHomePath("eclipse") + "/testData", getRelativeTestPath());
  assertTrue(testRoot.getAbsolutePath(), testRoot.isDirectory());

  final File currentTestRoot = new File(testRoot, getTestName(true));
  assertTrue(currentTestRoot.getAbsolutePath(), currentTestRoot.isDirectory());

  final String tempPath = getProject().getBaseDir().getPath();
  final File tempDir = new File(tempPath);
  VirtualFile vTestRoot = LocalFileSystem.getInstance().findFileByIoFile(currentTestRoot);
  copyDirContentsTo(vTestRoot, getProject().getBaseDir());

  final VirtualFile virtualTestDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(tempDir);
  assertNotNull(tempDir.getAbsolutePath(), virtualTestDir);
  virtualTestDir.refresh(false, true);

  PathMacros.getInstance().setMacro(VARIABLE, new File(tempPath, VARIABLE + "idea").getPath());
  PathMacros.getInstance().setMacro(SRCVARIABLE, new File(tempPath, SRCVARIABLE + "idea").getPath());
}
项目:tools-idea    文件:PathMacroManagerTest.java   
private void setUpMocks(final String projectPath) {
  myModule = context.mock(Module.class);
  myPathMacros = context.mock(PathMacrosImpl.class);
  myProject = context.mock(ProjectEx.class);

  final VirtualFile projectFile = context.mock(VirtualFile.class, "projectFile");

  context.checking(new Expectations() {{
    allowing(myModule).isDisposed(); will(returnValue(false));
    allowing(myProject).isDisposed(); will(returnValue(false));

    allowing(projectFile).getPath(); will(returnValue(projectPath));

    final String moduleFilePath = projectPath + "/module/module.iml";

    allowing(myApplication).getComponent(with(equal(PathMacros.class))); will(returnValue(myPathMacros));
    allowing(myPathMacros).addMacroReplacements(with(any(ReplacePathToMacroMap.class)));

    allowing(myProject).getBaseDir(); will(returnValue(projectFile));
    allowing(myModule).getModuleFilePath(); will(returnValue(moduleFilePath));
    allowing(myModule).getProject(); will(returnValue(myProject));
  }});
}
项目:tools-idea    文件:EclipseVarsTest.java   
@Override
protected void setUp() throws Exception {
  super.setUp();
  final File testRoot = new File(PluginPathManager.getPluginHomePath("eclipse") + "/testData", getRelativeTestPath());
  assertTrue(testRoot.getAbsolutePath(), testRoot.isDirectory());

  final File currentTestRoot = new File(testRoot, getTestName(true));
  assertTrue(currentTestRoot.getAbsolutePath(), currentTestRoot.isDirectory());

  final String tempPath = getProject().getBaseDir().getPath();
  final File tempDir = new File(tempPath);
  FileUtil.copyDir(currentTestRoot, tempDir);
  final VirtualFile virtualTestDir = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(tempDir);
  assertNotNull(tempDir.getAbsolutePath(), virtualTestDir);
  virtualTestDir.refresh(false, true);

  PathMacros.getInstance().setMacro(VARIABLE, new File(tempPath, VARIABLE + "idea").getPath());
  PathMacros.getInstance().setMacro(SRCVARIABLE, new File(tempPath, SRCVARIABLE + "idea").getPath());
}
项目:consulo    文件:PathMacroManagerTest.java   
private void setUpMocks(final String projectPath) {
  myModule = context.mock(Module.class);
  myPathMacros = context.mock(PathMacrosImpl.class);
  myProject = context.mock(ProjectEx.class);

  final VirtualFile projectFile = context.mock(VirtualFile.class, "projectFile");

  context.checking(new Expectations() {{
    allowing(myModule).isDisposed(); will(returnValue(false));
    allowing(myProject).isDisposed(); will(returnValue(false));

    allowing(projectFile).getPath(); will(returnValue(projectPath));

    final String moduleFilePath = projectPath + "/module/module.iml";

    allowing(myApplication).getComponent(with(equal(PathMacros.class))); will(returnValue(myPathMacros));
    allowing(myPathMacros).addMacroReplacements(with(any(ReplacePathToMacroMap.class)));

    allowing(myProject).getBaseDir(); will(returnValue(projectFile));
    allowing(myModule).getModuleDir(); will(returnValue(moduleFilePath));
    allowing(myModule).getProject(); will(returnValue(myProject));
  }});
}
项目:intellij-ce-playground    文件:PropertyFileGeneratorImpl.java   
/**
 * A constctor that extracts all neeed properties for ant build from the project.
 *
 * @param project    a project to examine
 * @param genOptions generation options
 */
public PropertyFileGeneratorImpl(Project project, GenerationOptions genOptions) {
  // path variables
  final PathMacros pathMacros = PathMacros.getInstance();
  final Set<String> macroNamesSet = pathMacros.getUserMacroNames();
  if (macroNamesSet.size() > 0) {
    final String[] macroNames = ArrayUtil.toStringArray(macroNamesSet);
    Arrays.sort(macroNames);
    for (final String macroName : macroNames) {
      addProperty(BuildProperties.getPathMacroProperty(macroName), pathMacros.getValue(macroName));
    }
  }
  // jdk homes
  if (genOptions.forceTargetJdk) {
    final Sdk[] usedJdks = BuildProperties.getUsedJdks(project);
    for (Sdk jdk : usedJdks) {
      if (jdk.getHomeDirectory() == null) {
        continue;
      }
      final File homeDir = BuildProperties.toCanonicalFile(VfsUtil.virtualToIoFile(jdk.getHomeDirectory()));
      addProperty(BuildProperties.getJdkHomeProperty(jdk.getName()), homeDir.getPath().replace(File.separatorChar, '/'));
    }
  }
  // generate idea.home property
  if (genOptions.isIdeaHomeGenerated()) {
    addProperty(BuildProperties.PROPERTY_IDEA_HOME, PathManager.getHomePath());
  }

  if (genOptions.enableFormCompiler) {
    addProperty(BuildProperties.PROPERTY_INCLUDE_JAVA_RUNTIME_FOR_INSTRUMENTATION, genOptions.forceTargetJdk? "false" : "true");
  }

  ChunkBuildExtension.generateAllProperties(this, project, genOptions);
}
项目:intellij-ce-playground    文件:GenerationOptionsImpl.java   
private static ReplacePathToMacroMap createReplacementMap() {
  final PathMacros pathMacros = PathMacros.getInstance();
  final Set<String> macroNames = pathMacros.getUserMacroNames();
  final ReplacePathToMacroMap map = new ReplacePathToMacroMap();
  for (final String macroName : macroNames) {
    map.put(GenerationUtils.normalizePath(pathMacros.getValue(macroName)),
            BuildProperties.propertyRef(BuildProperties.getPathMacroProperty(macroName)));
  }
  map.put(GenerationUtils.normalizePath(PathManager.getHomePath()), BuildProperties.propertyRef(BuildProperties.PROPERTY_IDEA_HOME));
  return map;
}
项目:intellij-ce-playground    文件:PathMacroTable.java   
private boolean hasMacroWithName(String name) {
  if (PathMacros.getInstance().getSystemMacroNames().contains(name)) {
    return true;
  }

  for (Couple<String> macro : myMacros) {
    if (name.equals(macro.getFirst())) {
      return true;
    }
  }
  return false;
}
项目:intellij-ce-playground    文件:PathMacroListEditor.java   
public void commit() throws ConfigurationException {
  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    public void run() {
      myPathMacroTable.commit();

      final Collection<String> ignored = parseIgnoredVariables();
      final PathMacros instance = PathMacros.getInstance();
      instance.setIgnoredMacroNames(ignored);
    }
  });
}
项目:intellij-ce-playground    文件:FileChooserFactoryImpl.java   
public static Map<String, String> getMacroMap() {
  final PathMacros macros = PathMacros.getInstance();
  final Set<String> allNames = macros.getAllMacroNames();
  final HashMap<String, String> map = new HashMap<String, String>();
  for (String eachMacroName : allNames) {
    map.put("$" + eachMacroName + "$", macros.getValue(eachMacroName));
  }

  return map;
}
项目:intellij-ce-playground    文件:CommonProgramParametersPanel.java   
protected JComponent createComponentWithMacroBrowse(@NotNull final TextFieldWithBrowseButton textAccessor) {
  final FixedSizeButton button = new FixedSizeButton(textAccessor);
  button.setIcon(AllIcons.RunConfigurations.Variables);
  button.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      List<String> macros = new SmartList<String>(PathMacros.getInstance().getUserMacroNames());
      if (myModuleContext != null || myHasModuleMacro) {
        macros.add(PathMacroUtil.MODULE_DIR_MACRO_NAME);
      }

      final JList list = new JBList(ArrayUtil.toStringArray(macros));
      JBPopupFactory.getInstance().createListPopupBuilder(list).setItemChoosenCallback(new Runnable() {
        @Override
        public void run() {
          final Object value = list.getSelectedValue();
          if (value instanceof String) {
            textAccessor.setText('$' + ((String)value) + '$');
          }
        }
      }).setMovable(false).setResizable(false).createPopup().showUnderneathOf(button);
    }
  });

  JPanel panel = new JPanel(new BorderLayout());
  panel.add(textAccessor, BorderLayout.CENTER);
  panel.add(button, BorderLayout.EAST);
  return panel;
}
项目:intellij-ce-playground    文件:XmlCoreEnvironment.java   
public ApplicationEnvironment(CoreApplicationEnvironment appEnvironment) {
  appEnvironment.registerFileType(HtmlFileType.INSTANCE, "html;htm;sht;shtm;shtml");
  appEnvironment.registerFileType(XHtmlFileType.INSTANCE, "xhtml");
  appEnvironment.registerFileType(DTDFileType.INSTANCE, "dtd;ent;mod;elt");

  appEnvironment.registerFileType(XmlFileType.INSTANCE, "xml;xsd;tld;xsl;jnlp;wsdl;jhm;ant;xul;xslt;rng;fxml");

  SyntaxHighlighterFactory.LANGUAGE_FACTORY.addExplicitExtension(XMLLanguage.INSTANCE, new XmlSyntaxHighlighterFactory());
  SyntaxHighlighterFactory.LANGUAGE_FACTORY.addExplicitExtension(DTDLanguage.INSTANCE, new DtdSyntaxHighlighterFactory());
  SyntaxHighlighterFactory.LANGUAGE_FACTORY.addExplicitExtension(HTMLLanguage.INSTANCE, new HtmlSyntaxHighlighterFactory());
  SyntaxHighlighterFactory.LANGUAGE_FACTORY.addExplicitExtension(XHTMLLanguage.INSTANCE, new XhtmlSyntaxHighlighterFactory());

  appEnvironment.addExplicitExtension(LanguageParserDefinitions.INSTANCE, XMLLanguage.INSTANCE, new XMLParserDefinition());
  appEnvironment.addExplicitExtension(LanguageParserDefinitions.INSTANCE, DTDLanguage.INSTANCE, new DTDParserDefinition());
  appEnvironment.addExplicitExtension(LanguageParserDefinitions.INSTANCE, HTMLLanguage.INSTANCE, new HTMLParserDefinition());
  appEnvironment.addExplicitExtension(LanguageParserDefinitions.INSTANCE, XHTMLLanguage.INSTANCE, new XHTMLParserDefinition());

  appEnvironment.addExplicitExtension(IdIndexers.INSTANCE, XmlFileType.INSTANCE, new XmlIdIndexer());
  appEnvironment.addExplicitExtension(IdIndexers.INSTANCE, DTDFileType.INSTANCE, new XmlIdIndexer());
  appEnvironment.addExplicitExtension(TodoIndexers.INSTANCE, XmlFileType.INSTANCE, new XmlTodoIndexer());
  appEnvironment.addExplicitExtension(TodoIndexers.INSTANCE, DTDFileType.INSTANCE, new XmlTodoIndexer());
  appEnvironment.addExplicitExtension(TodoIndexers.INSTANCE, XHtmlFileType.INSTANCE, new XHtmlTodoIndexer());

  appEnvironment.addExtension(MetaDataContributor.EP_NAME, new XmlApplicationComponent());
  appEnvironment.addExtension(FileBasedIndexExtension.EXTENSION_POINT_NAME, new XmlNamespaceIndex());
  appEnvironment.addExtension(FileBasedIndexExtension.EXTENSION_POINT_NAME, new SchemaTypeInheritanceIndex());
  appEnvironment.addExtension(FileBasedIndexExtension.EXTENSION_POINT_NAME, new XmlTagNamesIndex());
  appEnvironment.addExtension(StandardResourceProvider.EP_NAME, new InternalResourceProvider());

  appEnvironment.registerApplicationComponent(PathMacros.class, new PathMacrosImpl());
  appEnvironment.registerApplicationService(ExternalResourceManager.class, new ExternalResourceManagerExImpl());
  appEnvironment.registerApplicationService(XmlFoldingSettings.class, new XmlFoldingSettings());
  Language[] myLanguages = new Language[]{XMLLanguage.INSTANCE, HTMLLanguage.INSTANCE, XHTMLLanguage.INSTANCE, DTDLanguage.INSTANCE};
  for (Language myLanguage : myLanguages) {
    appEnvironment.addExplicitExtension(LanguageFolding.INSTANCE, myLanguage, new XmlFoldingBuilder());
    appEnvironment.addExplicitExtension(LanguageFindUsages.INSTANCE, myLanguage, new XmlFindUsagesProvider());
    appEnvironment.addExplicitExtension(LanguageASTFactory.INSTANCE, myLanguage, new XmlASTFactory());
  }
}
项目:intellij-ce-playground    文件:MavenEnvironmentRegistrar.java   
private static void registerPathVariable() {
  String repository = MavenUtil.resolveLocalRepository(null, null, null).getAbsolutePath();
  PathMacros macros = PathMacros.getInstance();

  for (String each : macros.getAllMacroNames()) {
    String path = macros.getValue(each);
    if (path != null && FileUtil.pathsEqual(repository, path)) {
      return;
    }
  }

  macros.setMacro(MAVEN_REPOSITORY, repository);
}
项目:intellij-ce-playground    文件:MvcPathMacros.java   
public MvcPathMacros() {
  Set<String> macroNames = PathMacros.getInstance().getUserMacroNames();
  for (String framework : ContainerUtil.ar("grails", "griffon")) {
    String name = "USER_HOME_" + framework.toUpperCase();
    if (!macroNames.contains(name)) { // OK, it may appear/disappear during the application lifetime, but we ignore that for now. Restart will help anyway
      PathMacros.getInstance().addLegacyMacro(name, StringUtil.trimEnd(getSdkWorkDirParent(framework), "/"));
    }
  }
}
项目:tools-idea    文件:PropertyFileGeneratorImpl.java   
/**
 * A constctor that extracts all neeed properties for ant build from the project.
 *
 * @param project    a project to examine
 * @param genOptions generation options
 */
public PropertyFileGeneratorImpl(Project project, GenerationOptions genOptions) {
  // path variables
  final PathMacros pathMacros = PathMacros.getInstance();
  final Set<String> macroNamesSet = pathMacros.getUserMacroNames();
  if (macroNamesSet.size() > 0) {
    final String[] macroNames = ArrayUtil.toStringArray(macroNamesSet);
    Arrays.sort(macroNames);
    for (final String macroName : macroNames) {
      addProperty(BuildProperties.getPathMacroProperty(macroName), pathMacros.getValue(macroName));
    }
  }
  // jdk homes
  if (genOptions.forceTargetJdk) {
    final Sdk[] usedJdks = BuildProperties.getUsedJdks(project);
    for (Sdk jdk : usedJdks) {
      if (jdk.getHomeDirectory() == null) {
        continue;
      }
      final File homeDir = BuildProperties.toCanonicalFile(VfsUtil.virtualToIoFile(jdk.getHomeDirectory()));
      addProperty(BuildProperties.getJdkHomeProperty(jdk.getName()), homeDir.getPath().replace(File.separatorChar, '/'));
    }
  }
  // generate idea.home property
  if (genOptions.isIdeaHomeGenerated()) {
    addProperty(BuildProperties.PROPERTY_IDEA_HOME, PathManager.getHomePath());
  }

  if (genOptions.enableFormCompiler) {
    addProperty(BuildProperties.PROPERTY_INCLUDE_JAVA_RUNTIME_FOR_INSTRUMENTATION, genOptions.forceTargetJdk? "false" : "true");
  }

  ChunkBuildExtension.generateAllProperties(this, project, genOptions);
}
项目:tools-idea    文件:GenerationOptionsImpl.java   
private static ReplacePathToMacroMap createReplacementMap() {
  final PathMacros pathMacros = PathMacros.getInstance();
  final Set<String> macroNames = pathMacros.getUserMacroNames();
  final ReplacePathToMacroMap map = new ReplacePathToMacroMap();
  for (final String macroName : macroNames) {
    map.put(GenerationUtils.normalizePath(pathMacros.getValue(macroName)),
            BuildProperties.propertyRef(BuildProperties.getPathMacroProperty(macroName)));
  }
  map.put(GenerationUtils.normalizePath(PathManager.getHomePath()), BuildProperties.propertyRef(BuildProperties.PROPERTY_IDEA_HOME));
  return map;
}
项目:tools-idea    文件:PathMacrosCollector.java   
public static Set<String> getMacroNames(Element root, @Nullable PathMacroFilter filter, @NotNull final PathMacros pathMacros) {
  final PathMacrosCollector collector = new PathMacrosCollector();
  collector.substitute(root, true, false, filter);
  final HashSet<String> result = new HashSet<String>(collector.myMacroMap.keySet());
  result.removeAll(pathMacros.getSystemMacroNames());
  result.removeAll(pathMacros.getLegacyMacroNames());
  result.removeAll(PathMacrosImpl.getToolMacroNames());
  result.removeAll(pathMacros.getIgnoredMacroNames());
  return result;
}
项目:tools-idea    文件:CoreModule.java   
public CoreModule(@NotNull Disposable parentDisposable, @NotNull Project project, String moduleFilePath) {
  super(project.getPicoContainer(), parentDisposable);
  myLifetime = parentDisposable;
  myProject = project;
  myPath = moduleFilePath;

  Extensions.instantiateArea(ExtensionAreas.IDEA_MODULE, this, null);
  CoreApplicationEnvironment.registerExtensionPoint(Extensions.getArea(this), ModuleExtension.EP_NAME, ModuleExtension.class);
  Disposer.register(parentDisposable, new Disposable() {
    @Override
    public void dispose() {
      Extensions.disposeArea(CoreModule.this);
    }
  });
  initModuleExtensions();

  final ModuleRootManagerImpl moduleRootManager =
    new ModuleRootManagerImpl(this,
                              DirectoryIndex.getInstance(project),
                              ProjectRootManagerImpl.getInstanceImpl(project),
                              VirtualFilePointerManager.getInstance()) {
      @Override
      public void loadState(ModuleRootManagerState object) {
        loadState(object, false);
      }
    };
  Disposer.register(parentDisposable, new Disposable() {
    @Override
    public void dispose() {
      moduleRootManager.disposeComponent();
    }
  });
  getPicoContainer().registerComponentInstance(ModuleRootManager.class, moduleRootManager);
  getPicoContainer().registerComponentInstance(PathMacroManager.class, new ModulePathMacroManager(PathMacros.getInstance(), this));
  myModuleScopeProvider = createModuleScopeProvider();
}
项目:tools-idea    文件:PathMacroTable.java   
private boolean hasMacroWithName(String name) {
  if (PathMacros.getInstance().getSystemMacroNames().contains(name)) {
    return true;
  }

  for (Pair<String, String> macro : myMacros) {
    if (name.equals(macro.getFirst())) {
      return true;
    }
  }
  return false;
}
项目:tools-idea    文件:PathMacroListEditor.java   
public void commit() throws ConfigurationException {
  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    public void run() {
      myPathMacroTable.commit();

      final Collection<String> ignored = parseIgnoredVariables();
      final PathMacros instance = PathMacros.getInstance();
      instance.setIgnoredMacroNames(ignored);
    }
  });
}
项目:tools-idea    文件:ProjectMacrosUtil.java   
public static boolean checkNonIgnoredMacros(final Project project, final Set<String> usedMacros){
  final PathMacros pathMacros = PathMacros.getInstance();
  for (Iterator<String> iterator = usedMacros.iterator(); iterator.hasNext();) {
    if (pathMacros.isIgnoredMacroName(iterator.next())) {
      iterator.remove();
    }
  }
  return checkMacros(project, usedMacros);
}
项目:tools-idea    文件:ProjectMacrosUtil.java   
public static boolean checkMacros(final Project project, final Set<String> usedMacros) {
  final Set<String> defined = getDefinedMacros();
  usedMacros.removeAll(defined);

  // try to lookup values in System properties
  @NonNls final String pathMacroSystemPrefix = "path.macro.";
  for (Iterator it = usedMacros.iterator(); it.hasNext();) {
    final String macro = (String)it.next();
    final String value = System.getProperty(pathMacroSystemPrefix + macro, null);
    if (value != null) {
      ApplicationManager.getApplication().runWriteAction(new Runnable() {
        public void run() {
          PathMacros.getInstance().setMacro(macro, value);
        }
      });
      it.remove();
    }
  }

  if (usedMacros.isEmpty()) {
    return true; // all macros in configuration files are defined
  }

  // there are undefined macros, need to define them before loading components
  final boolean[] result = new boolean[1];

  final Runnable r = new Runnable() {
    public void run() {
      result[0] = showMacrosConfigurationDialog(project, usedMacros);
    }
  };

  WaitForProgressToShow.runOrInvokeAndWaitAboveProgress(r, ModalityState.NON_MODAL);
  return result[0];
}
项目:tools-idea    文件:ProjectMacrosUtil.java   
public static Set<String> getDefinedMacros() {
  final PathMacros pathMacros = PathMacros.getInstance();

  Set<String> definedMacros = new HashSet<String>(pathMacros.getUserMacroNames());
  definedMacros.addAll(pathMacros.getSystemMacroNames());
  definedMacros = Collections.unmodifiableSet(definedMacros);
  return definedMacros;
}
项目:tools-idea    文件:FileChooserFactoryImpl.java   
public static Map<String, String> getMacroMap() {
  final PathMacros macros = PathMacros.getInstance();
  final Set<String> allNames = macros.getAllMacroNames();
  final HashMap<String, String> map = new HashMap<String, String>();
  for (String eachMacroName : allNames) {
    map.put("$" + eachMacroName + "$", macros.getValue(eachMacroName));
  }

  return map;
}
项目:tools-idea    文件:MavenEnvironmentRegistrar.java   
private void registerPathVariable() {
  File repository = MavenUtil.resolveLocalRepository(null, null, null);
  PathMacros macros = PathMacros.getInstance();

  for (String each : macros.getAllMacroNames()) {
    String path = macros.getValue(each);
    if (path == null) continue;
    if (new File(path).equals(repository)) return;
  }
  macros.setMacro(MAVEN_REPOSITORY, repository.getPath());
}
项目:tools-idea    文件:MvcPathMacros.java   
public MvcPathMacros() {
  Set<String> macroNames = PathMacros.getInstance().getUserMacroNames();
  for (String framework : ContainerUtil.ar("grails", "griffon")) {
    String name = "USER_HOME_" + framework.toUpperCase();
    if (!macroNames.contains(name)) { // OK, it may appear/disappear during the application lifetime, but we ignore that for now. Restart will help anyway
      PathMacros.getInstance().addLegacyMacro(name, StringUtil.trimEnd(getSdkWorkDirParent(framework), "/"));
    }
  }
}
项目:consulo    文件:PathMacroTable.java   
private boolean hasMacroWithName(String name) {
  if (PathMacros.getInstance().getSystemMacroNames().contains(name)) {
    return true;
  }

  for (Pair<String, String> macro : myMacros) {
    if (name.equals(macro.getFirst())) {
      return true;
    }
  }
  return false;
}
项目:consulo    文件:PathMacroListEditor.java   
public void commit() throws ConfigurationException {
  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    public void run() {
      myPathMacroTable.commit();

      final Collection<String> ignored = parseIgnoredVariables();
      final PathMacros instance = PathMacros.getInstance();
      instance.setIgnoredMacroNames(ignored);
    }
  });
}
项目:consulo    文件:ProjectMacrosUtil.java   
public static boolean checkNonIgnoredMacros(final Project project, final Set<String> usedMacros){
  final PathMacros pathMacros = PathMacros.getInstance();
  for (Iterator<String> iterator = usedMacros.iterator(); iterator.hasNext();) {
    if (pathMacros.isIgnoredMacroName(iterator.next())) {
      iterator.remove();
    }
  }
  return checkMacros(project, usedMacros);
}
项目:consulo    文件:ProjectMacrosUtil.java   
public static boolean checkMacros(final Project project, final Set<String> usedMacros) {
  final Set<String> defined = getDefinedMacros();
  usedMacros.removeAll(defined);

  // try to lookup values in System properties
  @NonNls final String pathMacroSystemPrefix = "path.macro.";
  for (Iterator it = usedMacros.iterator(); it.hasNext();) {
    final String macro = (String)it.next();
    final String value = System.getProperty(pathMacroSystemPrefix + macro, null);
    if (value != null) {
      ApplicationManager.getApplication().runWriteAction(new Runnable() {
        public void run() {
          PathMacros.getInstance().setMacro(macro, value);
        }
      });
      it.remove();
    }
  }

  if (usedMacros.isEmpty()) {
    return true; // all macros in configuration files are defined
  }

  // there are undefined macros, need to define them before loading components
  final boolean[] result = new boolean[1];

  final Runnable r = new Runnable() {
    public void run() {
      result[0] = showMacrosConfigurationDialog(project, usedMacros);
    }
  };

  WaitForProgressToShow.runOrInvokeAndWaitAboveProgress(r, ModalityState.NON_MODAL);
  return result[0];
}
项目:consulo    文件:ProjectMacrosUtil.java   
public static Set<String> getDefinedMacros() {
  final PathMacros pathMacros = PathMacros.getInstance();

  Set<String> definedMacros = new HashSet<String>(pathMacros.getUserMacroNames());
  definedMacros.addAll(pathMacros.getSystemMacroNames());
  definedMacros = Collections.unmodifiableSet(definedMacros);
  return definedMacros;
}
项目:consulo    文件:PathMacrosCollectorImpl.java   
@Nonnull
public static Set<String> getMacroNames(Element root, @Nullable PathMacroFilter filter, @Nonnull final PathMacros pathMacros) {
  final PathMacrosCollectorImpl collector = new PathMacrosCollectorImpl();
  collector.substitute(root, true, false, filter);
  final HashSet<String> result = new HashSet<String>(collector.myMacroMap.keySet());
  result.removeAll(pathMacros.getSystemMacroNames());
  result.removeAll(pathMacros.getLegacyMacroNames());
  for (Macro macro : MacroManager.getInstance().getMacros()) {
    result.remove(macro.getName());
  }
  result.removeAll(MacroManager.getInstance().getMacros());
  result.removeAll(pathMacros.getIgnoredMacroNames());
  return result;
}
项目:consulo    文件:MacroComboBoxModel.java   
private List<String> createMacros() {
  List<String> list = new SmartList<>();
  for (String name : PathMacros.getInstance().getUserMacroNames()) {
    list.add("$" + name + "$");
  }
  if (withModuleDir) {
    list.add("$" + PathMacroUtil.MODULE_DIR_MACRO_NAME + "$");
    list.add(ProgramParametersConfigurator.MODULE_WORKING_DIR);
  }
  return list;
}
项目:consulo    文件:FileChooserFactoryImpl.java   
public static Map<String, String> getMacroMap() {
  final PathMacros macros = PathMacros.getInstance();
  final Set<String> allNames = macros.getAllMacroNames();
  final Map<String, String> map = new THashMap<>(allNames.size());
  for (String eachMacroName : allNames) {
    map.put("$" + eachMacroName + "$", macros.getValue(eachMacroName));
  }

  return map;
}
项目:intellij-ce-playground    文件:PathMacrosCollector.java   
@NotNull
public static Set<String> getMacroNames(@NotNull final Element e) {
  return getMacroNames(e, new CompositePathMacroFilter(Extensions.getExtensions(MACRO_FILTER_EXTENSION_POINT_NAME)),
                       PathMacros.getInstance());
}
项目:intellij-ce-playground    文件:ProjectPathMacroManager.java   
public ProjectPathMacroManager(PathMacros pathMacros, Project project) {
  super(pathMacros);
  myProject = project;
}
项目:intellij-ce-playground    文件:BasePathMacroManager.java   
public BasePathMacroManager(@Nullable PathMacros pathMacros) {
  myPathMacros = (PathMacrosImpl)pathMacros;
}
项目:intellij-ce-playground    文件:ModulePathMacroManager.java   
public ModulePathMacroManager(PathMacros pathMacros, Module module) {
  super(pathMacros);
  myModule = module;
}