mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
This commit is contained in:
+37
-34
@@ -77,23 +77,22 @@ public class IdeaSpecificSettings extends AbstractIdeaSpecificSettings<Modifiabl
|
||||
|
||||
@Override
|
||||
protected void setupLibraryRoots(Element root, ModifiableRootModel model) {
|
||||
for (Object o : root.getChildren("lib")) {
|
||||
Element libElement = (Element)o;
|
||||
for (Element libElement : root.getChildren("lib")) {
|
||||
final String libName = libElement.getAttributeValue("name");
|
||||
Library libraryByName = model.getModuleLibraryTable().getLibraryByName(libName);
|
||||
if (libraryByName != null) {
|
||||
appendLibraryScope(model, libElement, libraryByName);
|
||||
final Library.ModifiableModel modifiableModel = libraryByName.getModifiableModel();
|
||||
replaceCollapsedByEclipseSourceRoots(libElement, modifiableModel);
|
||||
for (Object r : libElement.getChildren(JAVADOCROOT_ATTR)) {
|
||||
final String url = ((Element)r).getAttributeValue("url");
|
||||
modifiableModel.addRoot(url, JavadocOrderRootType.getInstance());
|
||||
for (Element r : libElement.getChildren(JAVADOCROOT_ATTR)) {
|
||||
modifiableModel.addRoot(r.getAttributeValue("url"), JavadocOrderRootType.getInstance());
|
||||
}
|
||||
replaceModuleRelatedRoots(model.getProject(), modifiableModel, libElement, OrderRootType.SOURCES, RELATIVE_MODULE_SRC);
|
||||
replaceModuleRelatedRoots(model.getProject(), modifiableModel, libElement, OrderRootType.CLASSES, RELATIVE_MODULE_CLS);
|
||||
replaceModuleRelatedRoots(model.getProject(), modifiableModel, libElement, JavadocOrderRootType.getInstance(), RELATIVE_MODULE_JAVADOC);
|
||||
modifiableModel.commit();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
final Library library = EclipseClasspathReader.findLibraryByName(model.getProject(), libName);
|
||||
if (library != null) {
|
||||
appendLibraryScope(model, libElement, library);
|
||||
@@ -107,7 +106,8 @@ public class IdeaSpecificSettings extends AbstractIdeaSpecificSettings<Modifiabl
|
||||
final String inheritJdk = root.getAttributeValue(INHERIT_JDK);
|
||||
if (inheritJdk != null && Boolean.parseBoolean(inheritJdk)) {
|
||||
model.inheritSdk();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
final String jdkName = root.getAttributeValue("jdk");
|
||||
if (jdkName != null) {
|
||||
final Sdk jdkByName = ProjectJdkTable.getInstance().findJdk(jdkName);
|
||||
@@ -146,9 +146,9 @@ public class IdeaSpecificSettings extends AbstractIdeaSpecificSettings<Modifiabl
|
||||
|
||||
@Override
|
||||
protected void overrideModulesScopes(Element root, ModifiableRootModel model) {
|
||||
for (Object o : root.getChildren("module")) {
|
||||
final String moduleName = ((Element)o).getAttributeValue("name");
|
||||
final String scope = ((Element)o).getAttributeValue("scope");
|
||||
for (Element o : root.getChildren("module")) {
|
||||
String moduleName = o.getAttributeValue("name");
|
||||
String scope = o.getAttributeValue("scope");
|
||||
if (scope != null) {
|
||||
for (OrderEntry entry : model.getOrderEntries()) {
|
||||
if (entry instanceof ModuleOrderEntry && Comparing.strEqual(((ModuleOrderEntry)entry).getModuleName(), moduleName)) {
|
||||
@@ -176,9 +176,9 @@ public class IdeaSpecificSettings extends AbstractIdeaSpecificSettings<Modifiabl
|
||||
String[] srcUrlsFromClasspath = modifiableModel.getUrls(OrderRootType.SOURCES);
|
||||
LOG.assertTrue(srcUrlsFromClasspath.length <= 1);
|
||||
final String eclipseUrl = srcUrlsFromClasspath.length > 0 ? srcUrlsFromClasspath[0] : null;
|
||||
for (Object r : libElement.getChildren(SRCROOT_ATTR)) {
|
||||
final String url = ((Element)r).getAttributeValue("url");
|
||||
final String bindAttr = ((Element)r).getAttributeValue(SRCROOT_BIND_ATTR);
|
||||
for (Element r : libElement.getChildren(SRCROOT_ATTR)) {
|
||||
final String url = r.getAttributeValue("url");
|
||||
final String bindAttr = r.getAttributeValue(SRCROOT_BIND_ATTR);
|
||||
boolean notBind = bindAttr != null && !Boolean.parseBoolean(bindAttr);
|
||||
if (notBind) {
|
||||
modifiableModel.addRoot(url, OrderRootType.SOURCES);
|
||||
@@ -205,8 +205,8 @@ public class IdeaSpecificSettings extends AbstractIdeaSpecificSettings<Modifiabl
|
||||
}
|
||||
|
||||
final boolean[] testFolders = new boolean[sourceFoldersUrls.length];
|
||||
for (Object o : root.getChildren(IdeaXml.TEST_FOLDER_TAG)) {
|
||||
final String url = ((Element)o).getAttributeValue(IdeaXml.URL_ATTR);
|
||||
for (Element o : root.getChildren(IdeaXml.TEST_FOLDER_TAG)) {
|
||||
final String url = o.getAttributeValue(IdeaXml.URL_ATTR);
|
||||
for (int i = 0; i < sourceFoldersUrls.length; i++) {
|
||||
if (Comparing.strEqual(sourceFoldersUrls[i], url)) {
|
||||
testFolders[i] = true;
|
||||
@@ -219,8 +219,7 @@ public class IdeaSpecificSettings extends AbstractIdeaSpecificSettings<Modifiabl
|
||||
entry.addSourceFolder(sourceFoldersUrls[i], testFolders[i]);
|
||||
}
|
||||
|
||||
for (Object o : root.getChildren(IdeaXml.PACKAGE_PREFIX_TAG)) {
|
||||
Element ppElement = (Element)o;
|
||||
for (Element ppElement : root.getChildren(IdeaXml.PACKAGE_PREFIX_TAG)) {
|
||||
final String prefix = ppElement.getAttributeValue(IdeaXml.PACKAGE_PREFIX_VALUE_ATTR);
|
||||
final String url = ppElement.getAttributeValue(IdeaXml.URL_ATTR);
|
||||
for (SourceFolder folder : entry.getSourceFolders()) {
|
||||
@@ -232,8 +231,8 @@ public class IdeaSpecificSettings extends AbstractIdeaSpecificSettings<Modifiabl
|
||||
}
|
||||
|
||||
final String url = entry.getUrl();
|
||||
for (Object o : root.getChildren(IdeaXml.EXCLUDE_FOLDER_TAG)) {
|
||||
final String excludeUrl = ((Element)o).getAttributeValue(IdeaXml.URL_ATTR);
|
||||
for (Element o : root.getChildren(IdeaXml.EXCLUDE_FOLDER_TAG)) {
|
||||
final String excludeUrl = o.getAttributeValue(IdeaXml.URL_ATTR);
|
||||
if (FileUtil.isAncestor(new File(url), new File(excludeUrl), false)) { //check if it is excluded manually
|
||||
entry.addExcludeFolder(excludeUrl);
|
||||
}
|
||||
@@ -408,8 +407,8 @@ public class IdeaSpecificSettings extends AbstractIdeaSpecificSettings<Modifiabl
|
||||
final Library.ModifiableModel modifiableModel, final Element libElement,
|
||||
final OrderRootType orderRootType, final String relativeModuleName) {
|
||||
final List<String> urls = new ArrayList<String>(Arrays.asList(modifiableModel.getUrls(orderRootType)));
|
||||
for (Object r : libElement.getChildren(relativeModuleName)) {
|
||||
final String root = PathMacroManager.getInstance(project).expandPath(((Element)r).getAttributeValue(PROJECT_RELATED));
|
||||
for (Element r : libElement.getChildren(relativeModuleName)) {
|
||||
final String root = PathMacroManager.getInstance(project).expandPath(r.getAttributeValue(PROJECT_RELATED));
|
||||
for (Iterator<String> iterator = urls.iterator(); iterator.hasNext();) {
|
||||
final String url = iterator.next();
|
||||
if (areUrlsPointTheSame(root, url)) {
|
||||
@@ -424,18 +423,23 @@ public class IdeaSpecificSettings extends AbstractIdeaSpecificSettings<Modifiabl
|
||||
|
||||
public static boolean appendModuleRelatedRoot(Element element, String classesUrl, final String rootName, ModuleRootModel model) {
|
||||
VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(classesUrl);
|
||||
if (file == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Project project = model.getModule().getProject();
|
||||
if (file != null) {
|
||||
if (file.getFileSystem() instanceof JarFileSystem) {
|
||||
file = JarFileSystem.getInstance().getVirtualFileForJar(file);
|
||||
assert file != null;
|
||||
}
|
||||
final Module module = ModuleUtilCore.findModuleForFile(file, project);
|
||||
if (module != null) {
|
||||
return appendRelatedToModule(element, classesUrl, rootName, file, module);
|
||||
} else if (ProjectRootManager.getInstance(project).getFileIndex().isExcluded(file)) {
|
||||
for (Module aModule : ModuleManager.getInstance(project).getModules()) {
|
||||
if (appendRelatedToModule(element, classesUrl, rootName, file, aModule)) return true;
|
||||
if (file.getFileSystem() instanceof JarFileSystem) {
|
||||
file = JarFileSystem.getInstance().getVirtualFileForJar(file);
|
||||
assert file != null;
|
||||
}
|
||||
final Module module = ModuleUtilCore.findModuleForFile(file, project);
|
||||
if (module != null) {
|
||||
return appendRelatedToModule(element, classesUrl, rootName, file, module);
|
||||
}
|
||||
else if (ProjectRootManager.getInstance(project).getFileIndex().isExcluded(file)) {
|
||||
for (Module aModule : ModuleManager.getInstance(project).getModules()) {
|
||||
if (appendRelatedToModule(element, classesUrl, rootName, file, aModule)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -443,8 +447,7 @@ public class IdeaSpecificSettings extends AbstractIdeaSpecificSettings<Modifiabl
|
||||
}
|
||||
|
||||
private static boolean appendRelatedToModule(Element element, String classesUrl, String rootName, VirtualFile file, Module module) {
|
||||
final VirtualFile[] contentRoots = ModuleRootManager.getInstance(module).getContentRoots();
|
||||
for (VirtualFile contentRoot : contentRoots) {
|
||||
for (VirtualFile contentRoot : ModuleRootManager.getInstance(module).getContentRoots()) {
|
||||
if (VfsUtilCore.isAncestor(contentRoot, file, false)) {
|
||||
final Element clsElement = new Element(rootName);
|
||||
clsElement.setAttribute(PROJECT_RELATED, PathMacroManager.getInstance(module.getProject()).collapsePath(classesUrl));
|
||||
|
||||
Reference in New Issue
Block a user