Java 类com.intellij.openapi.components.ExpandMacroToPathMap 实例源码

项目:intellij-ce-playground    文件:FileEditorManagerTestCase.java   
protected void openFiles(@NotNull String femSerialisedText) throws IOException, JDOMException, InterruptedException, ExecutionException {
  Document document = JDOMUtil.loadDocument(femSerialisedText);
  Element rootElement = document.getRootElement();
  ExpandMacroToPathMap map = new ExpandMacroToPathMap();
  map.addMacroExpand(PathMacroUtil.PROJECT_DIR_MACRO_NAME, getTestDataPath());
  map.substitute(rootElement, true, true);

  myManager.readExternal(rootElement);

  Future<?> future = ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
    @Override
    public void run() {
      myManager.getMainSplitters().openFiles();
    }
  });
  while (true) {
    try {
      future.get(100, TimeUnit.MILLISECONDS);
      return;
    }
    catch (TimeoutException e) {
      UIUtil.dispatchAllInvocationEvents();
    }
  }
}
项目:intellij-ce-playground    文件:ConversionContextImpl.java   
private File[] findModuleFiles(final Element root) {
  final Element modulesManager = JDomSerializationUtil.findComponent(root, ModuleManagerImpl.COMPONENT_NAME);
  if (modulesManager == null) return new File[0];

  final Element modules = modulesManager.getChild(ModuleManagerImpl.ELEMENT_MODULES);
  if (modules == null) return new File[0];

  final ExpandMacroToPathMap macros = createExpandMacroMap();

  List<File> files = new ArrayList<File>();
  for (Element module : JDOMUtil.getChildren(modules, ModuleManagerImpl.ELEMENT_MODULE)) {
    String filePath = module.getAttributeValue(ModuleManagerImpl.ATTRIBUTE_FILEPATH);
    filePath = macros.substitute(filePath, true);
    files.add(new File(FileUtil.toSystemDependentName(filePath)));
  }
  return files.toArray(new File[files.size()]);
}
项目:intellij-ce-playground    文件:ConversionContextImpl.java   
@NotNull
public List<File> getClassRoots(Element libraryElement, @Nullable ModuleSettingsImpl moduleSettings) {
  List<File> files = new ArrayList<File>();
  //todo[nik] support jar directories
  final Element classesChild = libraryElement.getChild("CLASSES");
  if (classesChild != null) {
    final List<Element> roots = JDOMUtil.getChildren(classesChild, "root");
    final ExpandMacroToPathMap pathMap = createExpandMacroMap(moduleSettings);
    for (Element root : roots) {
      final String url = root.getAttributeValue("url");
      final String path = VfsUtilCore.urlToPath(url);
      files.add(new File(PathUtil.getLocalPath(pathMap.substitute(path, true))));
    }
  }
  return files;
}
项目:intellij-ce-playground    文件:JpsEclipseClasspathReader.java   
@Override
protected void addModuleLibrary(JpsModule rootModel,
                                Element element,
                                boolean exported,
                                String libName,
                                String url,
                                String srcUrl,
                                String nativeRoot, 
                                ExpandMacroToPathMap macroMap) {
  final JpsLibrary jpsLibrary = rootModel.addModuleLibrary(libName, JpsJavaLibraryType.INSTANCE);
  final JpsDependenciesList dependenciesList = rootModel.getDependenciesList();
  final JpsLibraryDependency dependency = dependenciesList.addLibraryDependency(jpsLibrary);
  url = StringUtil.trimStart(url, "file://");
  final String linked = expandLinkedResourcesPath(url, macroMap);
  if (linked != null) {
    url = pathToUrl(linked);
  }
  else {
    url = expandEclipsePath2Url(rootModel, url);
  }
  LOG.debug("loading " + rootModel.getName() + ": adding module library " + libName + ": " + url);
  jpsLibrary.addRoot(url, JpsOrderRootType.COMPILED);

  setLibraryEntryExported(dependency, exported);
}
项目:intellij-ce-playground    文件:EclipseClasspathReader.java   
@Override
protected void addModuleLibrary(ModifiableRootModel rootModel,
                                Element element,
                                boolean exported,
                                String libName,
                                String url,
                                String srcUrl, 
                                String nativeRoot, 
                                ExpandMacroToPathMap macroMap) {
  final Library library = rootModel.getModuleLibraryTable().getModifiableModel().createLibrary(libName);
  final Library.ModifiableModel modifiableModel = library.getModifiableModel();
  modifiableModel.addRoot(url, OrderRootType.CLASSES);
  if (srcUrl != null) {
    modifiableModel.addRoot(srcUrl, OrderRootType.SOURCES);
  }

  if (nativeRoot != null) {
    modifiableModel.addRoot(nativeRoot, NativeLibraryOrderRootType.getInstance());
  }

  EJavadocUtil.appendJavadocRoots(element, rootModel, myCurrentRoots, modifiableModel);
  modifiableModel.commit();

  setLibraryEntryExported(rootModel, exported, library);
}
项目:tools-idea    文件:Convertor34Test.java   
private static PerformAction createPerformActionForLibraryTable() {
  return new PerformAction() {
    @Override
    public void performAction(VirtualFile rootDir, VirtualFile rootAfter) throws Exception {
      final VirtualFile libFile = rootDir.findChild("library.table.xml");
      assertNotNull(rootDir.getPath(), libFile);

      final ExpandMacroToPathMap macros = new ExpandMacroToPathMap();
      macros.addMacroExpand("DIR", rootDir.getPath());

      final Document oldTable = JDOMUtil.loadDocument(VfsUtilCore.loadText(libFile));
      macros.substitute(oldTable.getRootElement(), true);
      Convertor34.convertLibraryTable34(oldTable.getRootElement(), libFile.getPath());
      ApplicationManager.getApplication().runWriteAction(new Runnable() {
        @Override
        public void run() {
          LocalFileSystem.getInstance().refresh(false);
        }
      });
      final Document newTable = loadDocument(rootDir, "applicationLibraries.xml");
      final Document goldenNewTable = loadDocument(rootAfter, "applicationLibraries.xml");
      macros.substitute(goldenNewTable.getRootElement(), true);
      assertElementsEqual(goldenNewTable.getRootElement(), newTable.getRootElement());
    }
  };
}
项目:tools-idea    文件:PathMacrosImpl.java   
public void addMacroExpands(ExpandMacroToPathMap result) {
  for (final String name : getUserMacroNames()) {
    final String value = getValue(name);
    if (value != null && !value.trim().isEmpty()) result.addMacroExpand(name, value);
  }

  myLock.readLock().lock();
  try {
    for (Map.Entry<String, String> entry : myLegacyMacros.entrySet()) {
      result.addMacroExpand(entry.getKey(), entry.getValue());
    }
  }
  finally {
    myLock.readLock().unlock();
  }
}
项目:tools-idea    文件:FileEditorManagerTest.java   
private void openFiles(String s) throws IOException, JDOMException, InterruptedException, ExecutionException {
  Document document = JDOMUtil.loadDocument(s);
  Element rootElement = document.getRootElement();
  ExpandMacroToPathMap map = new ExpandMacroToPathMap();
  map.addMacroExpand(PathMacroUtil.PROJECT_DIR_MACRO_NAME, getTestDataPath());
  map.substitute(rootElement, true, true);

  myManager.readExternal(rootElement);

  Future<?> future = ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
    @Override
    public void run() {
      myManager.getMainSplitters().openFiles();
    }
  });
  future.get();
}
项目:tools-idea    文件:ConversionContextImpl.java   
private File[] findModuleFiles(final Element root) {
  final Element modulesManager = JDomSerializationUtil.findComponent(root, ModuleManagerImpl.COMPONENT_NAME);
  if (modulesManager == null) return new File[0];

  final Element modules = modulesManager.getChild(ModuleManagerImpl.ELEMENT_MODULES);
  if (modules == null) return new File[0];

  final ExpandMacroToPathMap macros = createExpandMacroMap();

  List<File> files = new ArrayList<File>();
  for (Element module : JDOMUtil.getChildren(modules, ModuleManagerImpl.ELEMENT_MODULE)) {
    String filePath = module.getAttributeValue(ModuleManagerImpl.ATTRIBUTE_FILEPATH);
    filePath = macros.substitute(filePath, true);
    files.add(new File(FileUtil.toSystemDependentName(filePath)));
  }
  return files.toArray(new File[files.size()]);
}
项目:tools-idea    文件:ConversionContextImpl.java   
@NotNull
public List<File> getClassRoots(Element libraryElement, @Nullable ModuleSettingsImpl moduleSettings) {
  List<File> files = new ArrayList<File>();
  //todo[nik] support jar directories
  final Element classesChild = libraryElement.getChild("CLASSES");
  if (classesChild != null) {
    final List<Element> roots = JDOMUtil.getChildren(classesChild, "root");
    final ExpandMacroToPathMap pathMap = createExpandMacroMap(moduleSettings);
    for (Element root : roots) {
      final String url = root.getAttributeValue("url");
      final String path = VfsUtilCore.urlToPath(url);
      files.add(new File(PathUtil.getLocalPath(pathMap.substitute(path, true))));
    }
  }
  return files;
}
项目:tools-idea    文件:JpsEclipseClasspathReader.java   
@Override
protected void addModuleLibrary(JpsModule rootModel,
                                Element element,
                                boolean exported,
                                String libName,
                                String url,
                                String srcUrl,
                                ExpandMacroToPathMap macroMap) {
  final JpsLibrary jpsLibrary = rootModel.addModuleLibrary(libName, JpsJavaLibraryType.INSTANCE);
  final JpsDependenciesList dependenciesList = rootModel.getDependenciesList();
  final JpsLibraryDependency dependency = dependenciesList.addLibraryDependency(jpsLibrary);
  url = StringUtil.trimStart(url, "file://");
  final String linked = expandLinkedResourcesPath(url, macroMap);
  if (linked != null) {
    url = pathToUrl(linked);
  }
  else {
    url = expandEclipsePath2Url(rootModel, url);
  }
  LOG.debug("loading " + rootModel.getName() + ": adding module library " + libName + ": " + url);
  jpsLibrary.addRoot(url, JpsOrderRootType.COMPILED);

  setLibraryEntryExported(dependency, exported);
}
项目:tools-idea    文件:AbstractEclipseClasspathReader.java   
@Nullable
protected String expandLinkedResourcesPath(final ExpandMacroToPathMap macroMap,
                                           final Set<String> usedVariables,
                                           final String path) {
  final EclipseProjectFinder.LinkedResource linkedResource = EclipseProjectFinder.findLinkedResource(myRootPath, path);
  if (linkedResource != null) {
    if (linkedResource.containsPathVariable()) {
      usedVariables.add(linkedResource.getVariableName());
    }
    if (linkedResource.containsPathVariable()) {
      final String toPathVariableFormat =
        getVariableRelatedPath(linkedResource.getVariableName(), linkedResource.getRelativeToVariablePath());
      return macroMap.substitute(toPathVariableFormat, SystemInfo.isFileSystemCaseSensitive);
    }
    return linkedResource.getLocation();
  }
  return null;
}
项目:tools-idea    文件:EclipseClasspathReader.java   
@Override
protected void addModuleLibrary(ModifiableRootModel rootModel,
                                Element element,
                                boolean exported,
                                String libName,
                                String url,
                                String srcUrl, ExpandMacroToPathMap macroMap) {
  final Library library = rootModel.getModuleLibraryTable().getModifiableModel().createLibrary(libName);
  final Library.ModifiableModel modifiableModel = library.getModifiableModel();
  modifiableModel.addRoot(url, OrderRootType.CLASSES);
  if (srcUrl != null) {
    modifiableModel.addRoot(srcUrl, OrderRootType.SOURCES);
  }
  EJavadocUtil.appendJavadocRoots(element, rootModel, myCurrentRoots, modifiableModel);
  modifiableModel.commit();

  setLibraryEntryExported(rootModel, exported, library);
}
项目:consulo    文件:FileEditorManagerTest.java   
private void openFiles(String s) throws IOException, JDOMException, InterruptedException, ExecutionException {
  Document document = JDOMUtil.loadDocument(s);
  Element rootElement = document.getRootElement();
  ExpandMacroToPathMap map = new ExpandMacroToPathMap();
  map.addMacroExpand(PathMacroUtil.PROJECT_DIR_MACRO_NAME, getTestDataPath());
  map.substitute(rootElement, true, true);

  myManager.loadState(rootElement);

  Future<?> future = ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
    @Override
    public void run() {
      myManager.getMainSplitters().openFiles();
    }
  });
  future.get();
}
项目:consulo    文件:BackgroundTaskByVfsChangeTaskImpl.java   
@Nonnull
@RequiredReadAction
private String[] generateFilePaths() {
  if (myProvider == null) {
    return ArrayUtil.EMPTY_STRING_ARRAY;
  }
  VirtualFile file = myVirtualFilePointer.getFile();
  if (file == null) {
    return ArrayUtil.EMPTY_STRING_ARRAY;
  }
  String[] generatedFiles = myProvider.getGeneratedFiles(myProject, file);
  if (generatedFiles.length == 0) {
    return ArrayUtil.EMPTY_STRING_ARRAY;
  }

  ExpandMacroToPathMap expandOutMacroToPathMap = createExpandOutMacroToPathMap();

  String[] allPaths = new String[generatedFiles.length];
  for (int i = 0; i < generatedFiles.length; i++) {
    String generatedFile = generatedFiles[i];
    String expanded = expandOutMacroToPathMap.substitute(generatedFile, SystemInfo.isFileSystemCaseSensitive);
    allPaths[i] = expanded;
  }
  return allPaths;
}
项目:intellij-ce-playground    文件:ModuleRootsExternalizationTest.java   
public void testExpandMacro1() {
  final ExpandMacroToPathMap map = new ExpandMacroToPathMap();
  map.addMacroExpand("MACRO", "C:/idea");

  final String expanded = map.substitute("jar://$MACRO$/lib/forms_rt.jar!/", false);
  assertEquals("jar://C:/idea/lib/forms_rt.jar!/", expanded);
}
项目:intellij-ce-playground    文件:ModuleRootsExternalizationTest.java   
public void testExpandMacro2() {
  final ExpandMacroToPathMap map = new ExpandMacroToPathMap();
  map.addMacroExpand("MACRO", "forms_rt.jar!/");

  final String expanded = map.substitute("jar://C:/idea/lib/$MACRO$", false);
  assertEquals("jar://C:/idea/lib/forms_rt.jar!/", expanded);
}
项目:intellij-ce-playground    文件:ModuleRootsExternalizationTest.java   
public void testExpandMacro3() {
  final ExpandMacroToPathMap map = new ExpandMacroToPathMap();
  map.addMacroExpand("MACRO1", "C:/idea");
  map.addMacroExpand("MACRO2", "forms_rt.jar!/");

  final String expanded = map.substitute("jar://$MACRO1$/lib/$MACRO2$", false);
  assertEquals("jar://C:/idea/lib/forms_rt.jar!/", expanded);
}
项目:intellij-ce-playground    文件:ModuleRootsExternalizationTest.java   
public void testExpandMacroNoExpand() {
  final ExpandMacroToPathMap map = new ExpandMacroToPathMap();
  map.addMacroExpand("MACRO", "C:/idea");

  final String expanded = map.substitute("jar://C:/idea$/lib/forms_rt.jar!/", false);
  assertEquals("jar://C:/idea$/lib/forms_rt.jar!/", expanded);
}
项目:intellij-ce-playground    文件:ModuleRootsExternalizationTest.java   
public void testExpandMacroNoExpand2() {
  final ExpandMacroToPathMap map = new ExpandMacroToPathMap();
  map.addMacroExpand("MACRO", "C:/idea");

  final String expanded = map.substitute("jar://C:/idea/lib/forms_rt.jar!/$", false);
  assertEquals("jar://C:/idea/lib/forms_rt.jar!/$", expanded);
}
项目:intellij-ce-playground    文件:ModuleRootsExternalizationTest.java   
public void testExpandMacroNoExpand3() {
  final ExpandMacroToPathMap map = new ExpandMacroToPathMap();
  map.addMacroExpand("MACRO", "C:/idea");

  final String expanded = map.substitute("jar://$UNKNOWN$/lib/forms_rt.jar!/", false);
  assertEquals("jar://$UNKNOWN$/lib/forms_rt.jar!/", expanded);
}
项目:intellij-ce-playground    文件:ProjectPathMacroManager.java   
@NotNull
@Override
public ExpandMacroToPathMap getExpandMacroMap() {
  final ExpandMacroToPathMap result = super.getExpandMacroMap();
  addFileHierarchyReplacements(result, PathMacrosImpl.PROJECT_DIR_MACRO_NAME, getProjectDir(myProject));
  return result;
}
项目:intellij-ce-playground    文件:BasePathMacroManager.java   
private static void addFileHierarchyReplacements(@NotNull ExpandMacroToPathMap result, @Nullable VirtualFile f, @NotNull String macro) {
  if (f == null) {
    return;
  }

  addFileHierarchyReplacements(result, f.getParent(), macro + "/..");
  result.put(macro, StringUtil.trimEnd(f.getPath(), "/"));
}
项目:intellij-ce-playground    文件:BasePathMacroManager.java   
@NotNull
public ExpandMacroToPathMap getExpandMacroMap() {
  ExpandMacroToPathMap result = new ExpandMacroToPathMap();
  for (Map.Entry<String, String> entry : PathMacroUtil.getGlobalSystemMacros().entrySet()) {
    result.addMacroExpand(entry.getKey(), entry.getValue());
  }
  getPathMacros().addMacroExpands(result);
  return result;
}
项目:intellij-ce-playground    文件:ModulePathMacroManager.java   
@NotNull
@Override
public ExpandMacroToPathMap getExpandMacroMap() {
  final ExpandMacroToPathMap result = new ExpandMacroToPathMap();
  if (!myModule.isDisposed()) {
    addFileHierarchyReplacements(result, PathMacroUtil.MODULE_DIR_MACRO_NAME, PathMacroUtil.getModuleDir(myModule.getModuleFilePath()));
  }

  result.putAll(super.getExpandMacroMap());
  return result;
}
项目:intellij-ce-playground    文件:ConversionContextImpl.java   
private ExpandMacroToPathMap createExpandMacroMap(@Nullable ModuleSettingsImpl moduleSettings) {
  final ExpandMacroToPathMap map = createExpandMacroMap();
  if (moduleSettings != null) {
    final String modulePath = FileUtil.toSystemIndependentName(moduleSettings.getModuleFile().getParentFile().getAbsolutePath());
    map.addMacroExpand(PathMacrosImpl.MODULE_DIR_MACRO_NAME, modulePath);
  }
  return map;
}
项目:intellij-ce-playground    文件:ConversionContextImpl.java   
private ExpandMacroToPathMap createExpandMacroMap() {
  final ExpandMacroToPathMap macros = new ExpandMacroToPathMap();
  final String projectDir = FileUtil.toSystemIndependentName(myProjectBaseDir.getAbsolutePath());
  macros.addMacroExpand(PathMacrosImpl.PROJECT_DIR_MACRO_NAME, projectDir);
  PathMacrosImpl.getInstanceEx().addMacroExpands(macros);
  return macros;
}
项目:intellij-ce-playground    文件:JpsEclipseClasspathReader.java   
@Override
protected void addJUnitDefaultLib(JpsModule rootModel, String junitName, ExpandMacroToPathMap macroMap) {
  final String ideaHome = macroMap.substitute("$APPLICATION_HOME_DIR$", SystemInfo.isFileSystemCaseSensitive);
  final FilenameFilter junitFilter = new FilenameFilter() {
    @Override
    public boolean accept(File dir, String name) {
      return name.startsWith("junit");
    }
  };
  File[] junitJars = new File(ideaHome, "lib").listFiles(junitFilter);
  if (junitJars == null || junitJars.length == 0) {
    junitJars = new File(new File(ideaHome, "community"), "lib").listFiles(junitFilter);
  }
  if (junitJars != null && junitJars.length > 0) {
    final boolean isJUnit4 = junitName.contains("4");
    File junitJar = null;
    for (File jar : junitJars) {
      final boolean isCurrentJarV4 = jar.getName().contains("4");
      if (isCurrentJarV4 && isJUnit4 || !isCurrentJarV4 && !isJUnit4) {
        junitJar = jar;
        break;
      }
    }
    if (junitJar != null) {
      final JpsLibrary jpsLibrary = rootModel.addModuleLibrary(junitName, JpsJavaLibraryType.INSTANCE);
      jpsLibrary.addRoot(pathToUrl(junitJar.getPath()), JpsOrderRootType.COMPILED);
      final JpsDependenciesList dependenciesList = rootModel.getDependenciesList();
      dependenciesList.addLibraryDependency(jpsLibrary);
    }
  }
}
项目:intellij-ce-playground    文件:JpsEclipseClasspathReader.java   
@Nullable
private String expandLinkedResourcesPath(final String path, ExpandMacroToPathMap expander) {
  final EclipseProjectFinder.LinkedResource linkedResource = EclipseProjectFinder.findLinkedResource(myRootPath, path);
  if (linkedResource != null) {
    if (linkedResource.containsPathVariable()) {
      final String toPathVariableFormat =
        getVariableRelatedPath(linkedResource.getVariableName(), linkedResource.getRelativeToVariablePath());
      return expander.substitute(toPathVariableFormat, SystemInfo.isFileSystemCaseSensitive);
    }
    return linkedResource.getLocation();
  }
  return null;
}
项目:intellij-ce-playground    文件:AbstractEclipseClasspathReader.java   
@Nullable
protected String expandLinkedResourcesPath(final ExpandMacroToPathMap macroMap,
                                           final String path) {
  final EclipseProjectFinder.LinkedResource linkedResource = EclipseProjectFinder.findLinkedResource(myRootPath, path);
  if (linkedResource != null) {
    if (linkedResource.containsPathVariable()) {
      final String toPathVariableFormat =
        getVariableRelatedPath(linkedResource.getVariableName(), linkedResource.getRelativeToVariablePath());
      return macroMap.substitute(toPathVariableFormat, SystemInfo.isFileSystemCaseSensitive);
    }
    return linkedResource.getLocation();
  }
  return null;
}
项目:intellij-ce-playground    文件:EclipseClasspathReader.java   
@Override
protected void addJUnitDefaultLib(ModifiableRootModel rootModel, String junitName, ExpandMacroToPathMap macroMap) {
  final Library library = rootModel.getModuleLibraryTable().getModifiableModel().createLibrary(junitName);
  final Library.ModifiableModel modifiableModel = library.getModifiableModel();
  modifiableModel.addRoot(getJunitClsUrl(junitName.contains("4")), OrderRootType.CLASSES);
  modifiableModel.commit();
}
项目:tools-idea    文件:Convertor34Test.java   
private static PerformAction createPerformAction(final String projectName) {
  return new PerformAction() {
    @Override
    public void performAction(VirtualFile rootDir, VirtualFile rootAfter) throws Exception {
      final VirtualFile projectFile = rootDir.findChild(projectName + ProjectFileType.DOT_DEFAULT_EXTENSION);
      assertNotNull(rootDir.getPath(), projectFile);

      final ExpandMacroToPathMap macros = new ExpandMacroToPathMap();
      macros.addMacroExpand(PathMacrosImpl.PROJECT_DIR_MACRO_NAME, rootDir.getPath());
      macros.addMacroExpand(PathMacrosImpl.MODULE_DIR_MACRO_NAME, rootDir.getPath());

      final Document projectDocument = JDOMUtil.loadDocument(VfsUtilCore.loadText(projectFile));
      macros.substitute(projectDocument.getRootElement(), true);

      Convertor34.execute(projectDocument.getRootElement(), projectFile.getPath(), null);

      ApplicationManager.getApplication().runWriteAction(new Runnable() {
        @Override
        public void run() {
          LocalFileSystem.getInstance().refresh(false);
        }
      });
      final Document moduleDocument = loadDocument(rootDir, projectName + ModuleFileType.DOT_DEFAULT_EXTENSION);
      macros.substitute(moduleDocument.getRootElement(), true);
      final Document goldenProjectDocument = loadDocument(rootAfter, projectName + ProjectFileType.DOT_DEFAULT_EXTENSION);
      macros.substitute(goldenProjectDocument.getRootElement(), true);
      final Document goldenModuleDocument = loadDocument(rootAfter, projectName + ModuleFileType.DOT_DEFAULT_EXTENSION);
      macros.substitute(goldenModuleDocument.getRootElement(), true);

      assertConfigsEqual("ProjectModuleManager", goldenProjectDocument, projectDocument);
      assertConfigsEqual("NewModuleRootManager", goldenModuleDocument, moduleDocument);
    }
  };
}
项目:tools-idea    文件:ModuleRootsExternalizationTest.java   
public void testExpandMacro1() {
  final ExpandMacroToPathMap map = new ExpandMacroToPathMap();
  map.addMacroExpand("MACRO", "C:/idea");

  final String expanded = map.substitute("jar://$MACRO$/lib/forms_rt.jar!/", false);
  assertEquals("jar://C:/idea/lib/forms_rt.jar!/", expanded);
}
项目:tools-idea    文件:ModuleRootsExternalizationTest.java   
public void testExpandMacro2() {
  final ExpandMacroToPathMap map = new ExpandMacroToPathMap();
  map.addMacroExpand("MACRO", "forms_rt.jar!/");

  final String expanded = map.substitute("jar://C:/idea/lib/$MACRO$", false);
  assertEquals("jar://C:/idea/lib/forms_rt.jar!/", expanded);
}
项目:tools-idea    文件:ModuleRootsExternalizationTest.java   
public void testExpandMacro3() {
  final ExpandMacroToPathMap map = new ExpandMacroToPathMap();
  map.addMacroExpand("MACRO1", "C:/idea");
  map.addMacroExpand("MACRO2", "forms_rt.jar!/");

  final String expanded = map.substitute("jar://$MACRO1$/lib/$MACRO2$", false);
  assertEquals("jar://C:/idea/lib/forms_rt.jar!/", expanded);
}
项目:tools-idea    文件:ModuleRootsExternalizationTest.java   
public void testExpandMacroNoExpand() {
  final ExpandMacroToPathMap map = new ExpandMacroToPathMap();
  map.addMacroExpand("MACRO", "C:/idea");

  final String expanded = map.substitute("jar://C:/idea$/lib/forms_rt.jar!/", false);
  assertEquals("jar://C:/idea$/lib/forms_rt.jar!/", expanded);
}
项目:tools-idea    文件:ModuleRootsExternalizationTest.java   
public void testExpandMacroNoExpand2() {
  final ExpandMacroToPathMap map = new ExpandMacroToPathMap();
  map.addMacroExpand("MACRO", "C:/idea");

  final String expanded = map.substitute("jar://C:/idea/lib/forms_rt.jar!/$", false);
  assertEquals("jar://C:/idea/lib/forms_rt.jar!/$", expanded);
}
项目:tools-idea    文件:ModuleRootsExternalizationTest.java   
public void testExpandMacroNoExpand3() {
  final ExpandMacroToPathMap map = new ExpandMacroToPathMap();
  map.addMacroExpand("MACRO", "C:/idea");

  final String expanded = map.substitute("jar://$UNKNOWN$/lib/forms_rt.jar!/", false);
  assertEquals("jar://$UNKNOWN$/lib/forms_rt.jar!/", expanded);
}
项目:tools-idea    文件:BasePathMacroManager.java   
public ExpandMacroToPathMap getExpandMacroMap() {
  ExpandMacroToPathMap result = new ExpandMacroToPathMap();
  for (Map.Entry<String, String> entry : PathMacroUtil.getGlobalSystemMacros().entrySet()) {
    result.addMacroExpand(entry.getKey(), entry.getValue());
  }
  getPathMacros().addMacroExpands(result);
  return result;
}
项目:tools-idea    文件:ModulePathMacroManager.java   
@Override
public ExpandMacroToPathMap getExpandMacroMap() {
  final ExpandMacroToPathMap result = new ExpandMacroToPathMap();

  if (!myModule.isDisposed()) {
    addFileHierarchyReplacements(result, PathMacrosImpl.MODULE_DIR_MACRO_NAME, PathMacroUtil.getModuleDir(myModule.getModuleFilePath()));
  }

  result.putAll(super.getExpandMacroMap());

  return result;
}