use of com.intellij.openapi.components.PathMacroManager in project intellij-plugins by JetBrains.
the class FlexBuildConfigurationImpl method collapsePaths.
static String collapsePaths(@Nullable final ComponentManager componentManager, final String value) {
if (componentManager == null)
return value;
if (!value.contains(CompilerOptionInfo.LIST_ENTRIES_SEPARATOR) && !value.contains(CompilerOptionInfo.LIST_ENTRY_PARTS_SEPARATOR)) {
return value;
}
final StringBuilder result = new StringBuilder();
final PathMacroManager pathMacroManager = PathMacroManager.getInstance(componentManager);
final String delimiters = CompilerOptionInfo.LIST_ENTRIES_SEPARATOR + CompilerOptionInfo.LIST_ENTRY_PARTS_SEPARATOR;
for (StringTokenizer tokenizer = new StringTokenizer(value, delimiters, true); tokenizer.hasMoreTokens(); ) {
String token = tokenizer.nextToken();
if (token.length() > 1) {
token = pathMacroManager.collapsePath(token);
}
result.append(token);
}
return result.toString();
}
use of com.intellij.openapi.components.PathMacroManager in project Perl5-IDEA by Camelcade.
the class PerlModuleExtension method loadState.
@Override
public void loadState(Element state) {
state = state.getChild(PERL_CONFIG);
myRoots.clear();
if (state == null) {
return;
}
PathMacroManager macroManager = ModulePathMacroManager.getInstance(myModule);
for (Element pathElement : state.getChildren(ELEMENT_PATH)) {
JpsModuleSourceRootPropertiesSerializer serializer = SERIALIZER_BY_ID_MAP.get(pathElement.getAttributeValue(ATTRIBUTE_TYPE));
if (serializer == null) {
continue;
}
String expandedPath = macroManager.expandPath(pathElement.getAttributeValue(ATTRIBUTE_VALUE));
VirtualFile libRoot = VfsUtil.findFileByIoFile(new File(expandedPath), true);
if (libRoot != null && libRoot.isValid() && libRoot.isDirectory()) {
myRoots.put(libRoot, (PerlSourceRootType) serializer.getType());
}
}
}
use of com.intellij.openapi.components.PathMacroManager in project intellij-community by JetBrains.
the class DefaultInspectionToolPresentation method writeOutput.
private synchronized void writeOutput(@NotNull final CommonProblemDescriptor[] descriptions, @NotNull RefEntity refElement) {
final Element parentNode = new Element(InspectionsBundle.message("inspection.problems"));
exportResults(descriptions, refElement, parentNode, d -> false);
final List list = parentNode.getChildren();
@NonNls final String ext = ".xml";
final String fileName = ourOutputPath + File.separator + myToolWrapper.getShortName() + ext;
final PathMacroManager pathMacroManager = PathMacroManager.getInstance(getContext().getProject());
PrintWriter printWriter = null;
try {
new File(ourOutputPath).mkdirs();
final File file = new File(fileName);
final CharArrayWriter writer = new CharArrayWriter();
if (!file.exists()) {
writer.append("<").append(InspectionsBundle.message("inspection.problems")).append(" " + GlobalInspectionContextBase.LOCAL_TOOL_ATTRIBUTE + "=\"").append(Boolean.toString(myToolWrapper instanceof LocalInspectionToolWrapper)).append("\">\n");
}
for (Object o : list) {
final Element element = (Element) o;
pathMacroManager.collapsePaths(element);
JDOMUtil.writeElement(element, writer, "\n");
}
printWriter = new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream(fileName, true), CharsetToolkit.UTF8_CHARSET)));
printWriter.append("\n");
printWriter.append(writer.toString());
} catch (IOException e) {
LOG.error(e);
} finally {
if (printWriter != null) {
printWriter.close();
}
}
}
use of com.intellij.openapi.components.PathMacroManager in project Perl5-IDEA by Camelcade.
the class PerlModuleExtension method getState.
@Nullable
@Override
public Element getState() {
Element perlConfig = new Element(PERL_CONFIG);
PathMacroManager macroManager = ModulePathMacroManager.getInstance(myModule);
for (VirtualFile root : myRoots.keySet()) {
if (!root.isValid() || !root.isDirectory()) {
continue;
}
JpsModuleSourceRootPropertiesSerializer serializer = SERIALIZER_BY_TYPE_MAP.get(myRoots.get(root));
if (serializer == null) {
continue;
}
String collapsedPath = macroManager.collapsePath(root.getCanonicalPath());
if (StringUtil.isEmpty(collapsedPath)) {
continue;
}
Element pathElement = new Element(ELEMENT_PATH);
pathElement.setAttribute(ATTRIBUTE_VALUE, collapsedPath);
pathElement.setAttribute(ATTRIBUTE_TYPE, serializer.getTypeId());
perlConfig.addContent(pathElement);
}
Element root = new Element("root");
if (!perlConfig.getChildren().isEmpty()) {
root.addContent(perlConfig);
}
return root;
}
Aggregations