Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
26,000
String () { return myInvalidJdk; }
getInvalidJdk
26,001
void (String name) { myKnownCons.add(name); }
registerCon
26,002
String[] () { return ArrayUtilRt.toStringArray(myKnownCons); }
getUsedCons
26,003
CachedXmlDocumentSet () { return myDocumentSet; }
getDocumentSet
26,004
void (@Nullable CachedXmlDocumentSet documentSet) { myDocumentSet = documentSet; }
setDocumentSet
26,005
void (String path, String var) { myEclipseVariablePaths.put(path, var); }
registerEclipseVariablePath
26,006
void (String path, String var) { myEclipseVariablePaths.put(SRC_PREFIX + path, var); }
registerEclipseSrcVariablePath
26,007
void (String path, String var) { myEclipseVariablePaths.put(SRC_LINK_PREFIX + path, var); }
registerEclipseLinkedSrcVarPath
26,008
String (String path) { return myEclipseVariablePaths.get(SRC_LINK_PREFIX + path); }
getEclipseLinkedSrcVariablePath
26,009
void (String path, String var) { myEclipseVariablePaths.put(LINK_PREFIX + path, var); }
registerEclipseLinkedVarPath
26,010
String (String path) { return myEclipseVariablePaths.get(LINK_PREFIX + path); }
getEclipseLinkedVarPath
26,011
String (String path) { return myEclipseVariablePaths.get(path); }
getEclipseVariablePath
26,012
String (String path) { return myEclipseVariablePaths.get(SRC_PREFIX + path); }
getEclipseSrcVariablePath
26,013
void (String con) { myUnknownCons.add(con); }
registerUnknownCons
26,014
Set<String> () { return myUnknownCons; }
getUnknownCons
26,015
boolean () { return myForceConfigureJDK; }
isForceConfigureJDK
26,016
void () { myForceConfigureJDK = true; myExpectedModuleSourcePlace++; }
setForceConfigureJDK
26,017
void (String url) { myEclipseUrls.add(url); }
registerEclipseLibUrl
26,018
boolean (String url) { return myEclipseUrls.contains(url); }
isEclipseLibUrl
26,019
Resolution (@NotNull Storage storage, @NotNull StateStorageOperation operation) { if (operation == StateStorageOperation.READ) { return Resolution.DO; } if (isEclipseStorage(myModule) || (myEclipseUrls.isEmpty() && myEclipseVariablePaths.isEmpty() && !myForceConfigureJDK && myUnknownCons.isEmpty())) { return Resolution.CLEAR; } else { return Resolution.DO; } }
getResolution
26,020
Element () { Element root = new Element("EclipseModuleSettings"); for (String eclipseUrl : myEclipseUrls) { root.addContent(new Element(LIBELEMENT).setAttribute(VALUE_ATTR, eclipseUrl)); } for (String var : myEclipseVariablePaths.keySet()) { Element varElement = new Element(VARELEMENT); if (var.startsWith(SRC_PREFIX)) { varElement.setAttribute(VAR_ATTRIBUTE, StringUtil.trimStart(var, SRC_PREFIX)); varElement.setAttribute(PREFIX_ATTR, SRC_PREFIX); } else if (var.startsWith(SRC_LINK_PREFIX)) { varElement.setAttribute(VAR_ATTRIBUTE, StringUtil.trimStart(var, SRC_LINK_PREFIX)); varElement.setAttribute(PREFIX_ATTR, SRC_LINK_PREFIX); } else if (var.startsWith(LINK_PREFIX)) { varElement.setAttribute(VAR_ATTRIBUTE, StringUtil.trimStart(var, LINK_PREFIX)); varElement.setAttribute(PREFIX_ATTR, LINK_PREFIX); } else { varElement.setAttribute(VAR_ATTRIBUTE, var); } varElement.setAttribute(VALUE_ATTR, myEclipseVariablePaths.get(var)); root.addContent(varElement); } for (String unknownCon : myUnknownCons) { root.addContent(new Element(CONELEMENT).setAttribute(VALUE_ATTR, unknownCon)); } if (myForceConfigureJDK) { root.setAttribute(FORCED_JDK, String.valueOf(true)); } Element srcDescriptionElement = new Element(SRC_DESCRIPTION); srcDescriptionElement.setAttribute(EXPECTED_POSITION, String.valueOf(myExpectedModuleSourcePlace)); for (String srcUrl : mySrcPlace.keySet()) { Element srcFolder = new Element(SRC_FOLDER); srcFolder.setAttribute(VALUE_ATTR, srcUrl); srcFolder.setAttribute(EXPECTED_POSITION, mySrcPlace.get(srcUrl).toString()); srcDescriptionElement.addContent(srcFolder); } root.addContent(srcDescriptionElement); return root; }
getState
26,021
void (@NotNull Element state) { myEclipseUrls.clear(); myEclipseVariablePaths.clear(); myUnknownCons.clear(); mySrcPlace.clear(); myKnownCons.clear(); for (Element o : state.getChildren(LIBELEMENT)) { myEclipseUrls.add(o.getAttributeValue(VALUE_ATTR)); } for (Element o : state.getChildren(VARELEMENT)) { myEclipseVariablePaths.put(o.getAttributeValue(VAR_ATTRIBUTE), o.getAttributeValue(PREFIX_ATTR, "") + o.getAttributeValue(VALUE_ATTR)); } for (Element o : state.getChildren(CONELEMENT)) { myUnknownCons.add(o.getAttributeValue(VALUE_ATTR)); } myForceConfigureJDK = Boolean.parseBoolean(state.getAttributeValue(FORCED_JDK, "false")); Element srcDescriptionElement = state.getChild(SRC_DESCRIPTION); if (srcDescriptionElement != null) { myExpectedModuleSourcePlace = Integer.parseInt(srcDescriptionElement.getAttributeValue(EXPECTED_POSITION)); for (Element o : srcDescriptionElement.getChildren(SRC_FOLDER)) { mySrcPlace.put(o.getAttributeValue(VALUE_ATTR), Integer.parseInt(o.getAttributeValue(EXPECTED_POSITION))); } } }
loadState
26,022
void (int expectedModuleSourcePlace) { myExpectedModuleSourcePlace = expectedModuleSourcePlace; }
setExpectedModuleSourcePlace
26,023
boolean (int expectedPlace) { return myExpectedModuleSourcePlace == expectedPlace; }
isExpectedModuleSourcePlace
26,024
void (String srcUrl, int placeIdx) { mySrcPlace.put(srcUrl, placeIdx); }
registerSrcPlace
26,025
int (String srcUtl) { Integer v = mySrcPlace.get(srcUtl); return v == null ? -1 : v; }
getSrcPlace
26,026
String (@NotNull String name) { return nameToDir.get(name); }
getParent
26,027
void (@NotNull String name, @NotNull String path) { nameToDir.put(name, path); }
register
26,028
void (@NotNull String name) { nameToDir.remove(name); }
unregister
26,029
boolean (@NotNull String name) { return getFile(name, false) != null; }
exists
26,030
void (Consumer<? super List<String>> onFinish) { AppJavaExecutorUtil.executeOnPooledIoThread(() -> { try { RecentProjectsManagerBase manager = (RecentProjectsManagerBase)RecentProjectsManager.getInstance(); @Nls String groupName = EclipseBundle.message("eclipse.projects"); ProjectGroup group = ContainerUtil.find(manager.getGroups(), g -> groupName.equals(g.getName())); String property = "eclipse.projects.detected"; if (group == null && PropertiesComponent.getInstance().isValueSet(property)) { // the group was removed by user return; } List<String> projects = new ArrayList<>(); new EclipseProjectDetector().collectProjectPaths(projects); HashSet<String> set = new HashSet<>(projects); if (!PropertiesComponent.getInstance().isValueSet(property)) { EclipseProjectDetectorUsagesCollector.logProjectsDetected(set.size()); PropertiesComponent.getInstance().setValue(property, ""); } projects.removeAll(manager.getRecentPaths()); if (projects.isEmpty()) return; if (group == null) { group = new ProjectGroup(groupName); group.setBottomGroup(true); group.setProjects(new ArrayList<>(set)); manager.addGroup(group); } else { group.getProjects().retainAll(set); } ProjectGroup finalGroup = group; ApplicationManager.getApplication().invokeLater(() -> onFinish.accept(finalGroup.getProjects())); } catch (Exception e) { LOG.error(e); } }); }
detectProjects
26,031
void (@Nullable ProjectGroup projectGroup) { if (projectGroup != null && EclipseBundle.message("eclipse.projects").equals(projectGroup.getName())) { EclipseProjectDetectorUsagesCollector.logProjectOpened(false); } }
logRecentProjectOpened
26,032
void (List<String> projects, Path path) { File file = path.toFile(); if (!file.exists()) return; try { String prefs = FileUtil.loadFile(file); String[] workspaces = getWorkspaces(prefs); for (String workspace : workspaces) { scanForProjects(workspace, projects); } } catch (IOException ignore) { } }
collectProjects
26,033
void (String workspace, List<String> projects) { if (isInSpecialMacFolder(workspace)) { return; } File[] files = new File(workspace).listFiles(); if (files == null) { return; } for (File file : files) { if (isInSpecialMacFolder(file.getPath())) { continue; } String[] list = file.list(); if (list != null && ContainerUtil.or(list, s -> ".project".equals(s)) && ContainerUtil.or(list, s -> ".classpath".equals(s))) { projects.add(file.getPath()); } } }
scanForProjects
26,034
boolean (String file) { if (!SystemInfo.isMac) return false; if (FileSystemUtil.isSymLink(file)) { return true; } String home = System.getProperty("user.home"); Path path = Path.of(file); return path.startsWith(Path.of(home, "Documents")) || path.startsWith(Path.of(home, "Pictures")) || path.startsWith(Path.of(home, "Downloads")) || path.startsWith(Path.of(home, "Desktop")) || path.startsWith(Path.of(home, "Library")); }
isInSpecialMacFolder
26,035
void (File file, Consumer<File> processor, int depth) { if (depth == 0 || isInSpecialMacFolder(file.getPath())) return; processor.accept(file); File[] files = file.listFiles(pathname -> !pathname.getName().startsWith(".")); if (files == null) return; for (File child : files) { visitFiles( child, processor, depth - 1); } }
visitFiles
26,036
void () { EclipseProjectDetectorUsagesCollector.logProjectOpened(true); }
projectOpened
26,037
void (@NotNull final AnActionEvent e) { e.getPresentation().setEnabled(e.getProject() != null); }
update
26,038
ActionUpdateThread () { return ActionUpdateThread.BGT; }
getActionUpdateThread
26,039
void (@NotNull AnActionEvent e) { Project project = e.getData(CommonDataKeys.PROJECT); // to flush iml files if (project == null) { return; } project.save(); List<Module> modules = new SmartList<>(); List<Module> incompatibleModules = new SmartList<>(); for (Module module : ModuleManager.getInstance(project).getModules()) { if (!EclipseModuleManagerImpl.isEclipseStorage(module)) { try { ClasspathStorageProvider provider = ClasspathStorage.getProvider(JpsEclipseClasspathSerializer.CLASSPATH_STORAGE_ID); if (provider != null) { provider.assertCompatible(ModuleRootManager.getInstance(module)); } modules.add(module); } catch (ConfigurationException ignored) { incompatibleModules.add(module); } } } //todo suggest smth with hierarchy modules if (incompatibleModules.isEmpty()) { if (modules.isEmpty()) { Messages.showInfoMessage(project, EclipseBundle.message("eclipse.export.nothing.to.do"), EclipseBundle.message("eclipse.export.dialog.title")); return; } } else if (Messages.showOkCancelDialog(project, EclipseBundle .message("dialog.message.incompatible.modules.found", StringUtil.join(incompatibleModules, module -> module.getName(), "<br><li>")), EclipseBundle.message("eclipse.export.dialog.title"), Messages.getWarningIcon()) != Messages.OK) { return; } modules.addAll(incompatibleModules); ExportEclipseProjectsDialog dialog = new ExportEclipseProjectsDialog(project, modules); if (!dialog.showAndGet()) { return; } if (dialog.isLink()) { for (Module module : dialog.getSelectedModules()) { ClasspathStorage.setStorageType(ModuleRootManager.getInstance(module), JpsEclipseClasspathSerializer.CLASSPATH_STORAGE_ID); } } else { Map<Module, String> module2StorageRoot = new LinkedHashMap<>(); for (Module module : dialog.getSelectedModules()) { VirtualFile[] contentRoots = ModuleRootManager.getInstance(module).getContentRoots(); String storageRoot = contentRoots.length == 1 ? contentRoots[0].getPath() : ClasspathStorage.getStorageRootFromOptions(module); module2StorageRoot.put(module, storageRoot); try { DotProjectFileHelper.saveDotProjectFile(module, storageRoot); } catch (Exception e1) { LOG.error(e1); } } for (Module module : module2StorageRoot.keySet()) { ModuleRootModel model = ModuleRootManager.getInstance(module); String storageRoot = module2StorageRoot.get(module); try { Element classpathElement = new EclipseClasspathWriter().writeClasspath(model); File classpathFile = new File(storageRoot, EclipseXml.CLASSPATH_FILE); if (!FileUtil.createIfDoesntExist(classpathFile)) { continue; } EclipseJDOMUtil.output(classpathElement, classpathFile, project); final Element ideaSpecific = new Element(IdeaXml.COMPONENT_TAG); if (IdeaSpecificSettings.writeIdeaSpecificClasspath(ideaSpecific, model)) { File emlFile = new File(storageRoot, module.getName() + EclipseXml.IDEA_SETTINGS_POSTFIX); if (!FileUtil.createIfDoesntExist(emlFile)) { continue; } EclipseJDOMUtil.output(ideaSpecific, emlFile, project); } } catch (Exception e1) { LOG.error(e1); } } } try { EclipseUserLibrariesHelper.appendProjectLibraries(project, dialog.getUserLibrariesFile()); } catch (IOException e1) { LOG.error(e1); } project.save(); }
actionPerformed
26,040
void (ActionEvent e) { myUserLibrariesTF.setEnabled(myExportProjectLibrariesCb.isSelected()); myPathToUserLibsLabel.setEnabled(myExportProjectLibrariesCb.isSelected()); }
actionPerformed
26,041
JComponent () { return contentPane; }
createCenterPanel
26,042
void () { moduleChooser = new ElementsChooser<>(true) { @Override protected String getItemText(@NotNull final Module module) { return module.getName(); } }; }
createUIComponents
26,043
String (@NotNull final Module module) { return module.getName(); }
getItemText
26,044
boolean () { return linkCheckBox.isSelected(); }
isLink
26,045
List<Module> () { return moduleChooser.getMarkedElements(); }
getSelectedModules
26,046
File () { return myExportProjectLibrariesCb.isSelected() ? new File(myUserLibrariesTF.getText()) : null; }
getUserLibrariesFile
26,047
void (final Library library, final Element libElement) { final VirtualFile[] files = library.getFiles(OrderRootType.CLASSES); for (VirtualFile file : files) { Element archElement = new Element("archive"); if (file.getFileSystem() instanceof JarFileSystem) { final VirtualFile localFile = JarFileSystem.getInstance().getVirtualFileForJar(file); if (localFile != null) { file = localFile; } } archElement.setAttribute("path", file.getPath()); libElement.addContent(archElement); } }
writeUserLibrary
26,048
void (@NotNull ModifiableRootModel model) { myContentEntry = model.addContentEntry(pathToUrl(myRootPath)); }
init
26,049
void (Set<? super String> usedVariables, Element classpathElement, final String rootPath) { for (Element element : classpathElement.getChildren(EclipseXml.CLASSPATHENTRY_TAG)) { String path = element.getAttributeValue(EclipseXml.PATH_ATTR); if (path == null) { continue; } String kind = element.getAttributeValue(EclipseXml.KIND_ATTR); if (Comparing.strEqual(kind, EclipseXml.VAR_KIND)) { createEPathVariable(path, 0); String srcPath = element.getAttributeValue(EclipseXml.SOURCEPATH_ATTR); if (srcPath != null) { createEPathVariable(srcPath, srcVarStart(srcPath)); } } else if (Comparing.strEqual(kind, EclipseXml.SRC_KIND) || Comparing.strEqual(kind, EclipseXml.OUTPUT_KIND)) { EclipseProjectFinder.LinkedResource linkedResource = EclipseProjectFinder.findLinkedResource(rootPath, path); if (linkedResource != null && linkedResource.containsPathVariable()) { usedVariables.add(linkedResource.getVariableName()); } } } }
collectVariables
26,050
int (ModifiableRootModel rootModel) { return rearrangeOrderEntryOfType(rootModel, ModuleSourceOrderEntry.class); }
rearrange
26,051
String (ModifiableRootModel rootModel, String path) { final VirtualFile contentRoot = myContentEntry.getFile(); if (contentRoot != null) { return EPathUtil.expandEclipsePath2Url(path, rootModel, myCurrentRoots, contentRoot); } return EPathUtil.expandEclipsePath2Url(path, rootModel, myCurrentRoots); }
expandEclipsePath2Url
26,052
Set<String> () { return EclipseNatureImporter.getAllDefinedCons(); }
getDefinedCons
26,053
void (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); }
addModuleLibrary
26,054
void (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(); }
addJUnitDefaultLib
26,055
void (ModifiableRootModel rootModel, String srcUrl, boolean testFolder) { myContentEntry.addSourceFolder(srcUrl, testFolder); }
addSourceFolderToCurrentContentRoot
26,056
void (ModifiableRootModel rootModel, String srcUrl, boolean testFolder) { rootModel.addContentEntry(srcUrl).addSourceFolder(srcUrl, testFolder); }
addSourceFolder
26,057
void (ModifiableRootModel rootModel, Collection<? super String> unknownJdks, EclipseModuleManager eclipseModuleManager, String jdkName) { if (jdkName == null) { rootModel.inheritSdk(); } else { final Sdk moduleJdk = ProjectJdkTable.getInstance().findJdk(jdkName); if (moduleJdk != null) { rootModel.setSdk(moduleJdk); } else { rootModel.setInvalidSdk(jdkName, IdeaXml.JAVA_SDK_TYPE); eclipseModuleManager.setInvalidJdk(jdkName); unknownJdks.add(jdkName); } } rearrangeOrderEntryOfType(rootModel, JdkOrderEntry.class); }
setUpModuleJdk
26,058
void (ModifiableRootModel rootModel, boolean exported, String moduleName) { rootModel.addInvalidModuleEntry(moduleName).setExported(exported); }
addInvalidModuleEntry
26,059
int (ModifiableRootModel rootModel, Class<? extends OrderEntry> orderEntryClass) { OrderEntry[] orderEntries = rootModel.getOrderEntries(); int moduleSourcesIdx = 0; for (OrderEntry orderEntry : orderEntries) { if (orderEntryClass.isAssignableFrom(orderEntry.getClass())) { break; } moduleSourcesIdx++; } orderEntries = ArrayUtil.append(orderEntries, orderEntries[moduleSourcesIdx]); orderEntries = ArrayUtil.remove(orderEntries, moduleSourcesIdx); rootModel.rearrangeOrderEntries(orderEntries); return orderEntries.length - 1; }
rearrangeOrderEntryOfType
26,060
void (ModifiableRootModel rootModel, final String path) { setOutputUrl(rootModel, path); }
setupOutput
26,061
void (@NotNull ModifiableRootModel rootModel, @NotNull @NonNls String path) { CompilerModuleExtension compilerModuleExtension = rootModel.getModuleExtension(CompilerModuleExtension.class); compilerModuleExtension.setCompilerOutputPath(pathToUrl(path)); compilerModuleExtension.inheritCompilerOutputPath(false); }
setOutputUrl
26,062
void (ModifiableRootModel rootModel, boolean exported, Library library) { for (OrderEntry orderEntry : rootModel.getOrderEntries()) { if (orderEntry instanceof LibraryOrderEntry && ((LibraryOrderEntry)orderEntry).isModuleLevel() && Comparing.equal(((LibraryOrderEntry)orderEntry).getLibrary(), library)) { ((LibraryOrderEntry)orderEntry).setExported(exported); break; } } }
setLibraryEntryExported
26,063
void (final ModifiableRootModel rootModel, final Collection<? super String> unknownLibraries, final boolean exported, final String name, final boolean applicationLevel) { Library lib = findLibraryByName(myProject, name); if (lib != null) { rootModel.addLibraryEntry(lib).setExported(exported); } else { unknownLibraries.add(name); rootModel.addInvalidLibrary(name, applicationLevel ? LibraryTablesRegistrar.APPLICATION_LEVEL : LibraryTablesRegistrar.PROJECT_LEVEL).setExported(exported); } }
addNamedLibrary
26,064
Library (Project project, String name) { final LibraryTablesRegistrar tablesRegistrar = LibraryTablesRegistrar.getInstance(); Library lib = tablesRegistrar.getLibraryTable().getLibraryByName(name); if (lib == null) { lib = tablesRegistrar.getLibraryTable(project).getLibraryByName(name); } if (lib == null) { for (LibraryTable table : tablesRegistrar.getCustomLibraryTables()) { lib = table.getLibraryByName(name); if (lib != null) { break; } } } return lib; }
findLibraryByName
26,065
String (final boolean version4) { String url = version4 ? JavaSdkUtil.getJunit4JarPath() : JavaSdkUtil.getJunit3JarPath(); final VirtualFile localFile = VirtualFileManager.getInstance().findFileByUrl(pathToUrl(url)); if (localFile != null) { final VirtualFile jarFile = JarFileSystem.getInstance().getJarRootForLocalFile(localFile); url = jarFile != null ? jarFile.getUrl() : localFile.getUrl(); } return url; }
getJunitClsUrl
26,066
String (String url) { final VirtualFile localFile = VirtualFileManager.getInstance().findFileByUrl(url); if (localFile != null) { final VirtualFile jarFile = JarFileSystem.getInstance().getJarRootForLocalFile(localFile); if (jarFile != null) { return jarFile.getUrl(); } } return url; }
prepareValidUrlInsideJar
26,067
boolean (@NotNull Element root, @NotNull ModuleRootModel model) { boolean isModified = false; CompilerModuleExtension compilerModuleExtension = model.getModuleExtension(CompilerModuleExtension.class); if (compilerModuleExtension.getCompilerOutputUrlForTests() != null) { final Element pathElement = new Element(IdeaXml.OUTPUT_TEST_TAG); pathElement.setAttribute(IdeaXml.URL_ATTR, compilerModuleExtension.getCompilerOutputUrlForTests()); root.addContent(pathElement); isModified = true; } if (compilerModuleExtension.isCompilerOutputPathInherited()) { root.setAttribute(JpsJavaModelSerializerExtension.INHERIT_COMPILER_OUTPUT_ATTRIBUTE, String.valueOf(true)); isModified = true; } if (compilerModuleExtension.isExcludeOutput()) { root.addContent(new Element(IdeaXml.EXCLUDE_OUTPUT_TAG)); isModified = true; } LanguageLevelModuleExtension languageLevelModuleExtension = model.getModuleExtension(LanguageLevelModuleExtension.class); LanguageLevel languageLevel = languageLevelModuleExtension.getLanguageLevel(); if (languageLevel != null) { root.setAttribute(JpsJavaModelSerializerExtension.MODULE_LANGUAGE_LEVEL_ATTRIBUTE, languageLevel.name()); isModified = true; } for (ContentEntry entry : model.getContentEntries()) { Element contentEntryElement = new Element(IdeaXml.CONTENT_ENTRY_TAG); contentEntryElement.setAttribute(IdeaXml.URL_ATTR, entry.getUrl()); root.addContent(contentEntryElement); for (SourceFolder sourceFolder : entry.getSourceFolders()) { if (sourceFolder.isTestSource()) { Element element = new Element(IdeaXml.TEST_FOLDER_TAG); contentEntryElement.addContent(element); element.setAttribute(IdeaXml.URL_ATTR, sourceFolder.getUrl()); isModified = true; } String packagePrefix = sourceFolder.getPackagePrefix(); if (!StringUtil.isEmptyOrSpaces(packagePrefix)) { Element element = new Element(IdeaXml.PACKAGE_PREFIX_TAG); contentEntryElement.addContent(element); element.setAttribute(IdeaXml.URL_ATTR, sourceFolder.getUrl()); element.setAttribute(IdeaXml.PACKAGE_PREFIX_VALUE_ATTR, packagePrefix); isModified = true; } } VirtualFile entryFile = entry.getFile(); for (ExcludeFolder excludeFolder : entry.getExcludeFolders()) { VirtualFile excludeFile = excludeFolder.getFile(); if (entryFile == null || excludeFile == null || VfsUtilCore.isAncestor(entryFile, excludeFile, false)) { Element element = new Element(IdeaXml.EXCLUDE_FOLDER_TAG); contentEntryElement.addContent(element); element.setAttribute(IdeaXml.URL_ATTR, excludeFolder.getUrl()); isModified = true; } } } Map<String, String> libLevels = new LinkedHashMap<>(); for (OrderEntry entry : model.getOrderEntries()) { if (entry instanceof ModuleOrderEntry) { final DependencyScope scope = ((ModuleOrderEntry)entry).getScope(); if (!scope.equals(DependencyScope.COMPILE)) { Element element = new Element("module"); element.setAttribute("name", ((ModuleOrderEntry)entry).getModuleName()); element.setAttribute("scope", scope.name()); root.addContent(element); isModified = true; } } if (entry instanceof JdkOrderEntry) { final Sdk jdk = ((JdkOrderEntry)entry).getJdk(); if (EclipseModuleManagerImpl.getInstance(entry.getOwnerModule()).getInvalidJdk() != null || jdk != null) { if (entry instanceof InheritedJdkOrderEntry) { root.setAttribute(INHERIT_JDK, "true"); } else { String jdkName = ((JdkOrderEntry)entry).getJdkName(); if (jdkName != null) { root.setAttribute("jdk", jdkName); } if (jdk != null) { root.setAttribute("jdk_type", jdk.getSdkType().getName()); } } isModified = true; } } if (!(entry instanceof LibraryOrderEntry libraryEntry)) continue; Element element = new Element("lib"); String libraryName = ((LibraryOrderEntry)entry).getLibraryName(); if (libraryName == null) { final String[] urls = libraryEntry.getRootUrls(OrderRootType.CLASSES); if (urls.length > 0) { VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(urls[0]); final VirtualFile fileForJar = JarFileSystem.getInstance().getVirtualFileForJar(file); if (fileForJar != null) { file = fileForJar; } libraryName = file != null ? file.getName() : null; } if (libraryName == null) { libraryName = libraryEntry.getPresentableName(); } } element.setAttribute("name", libraryName); DependencyScope scope = libraryEntry.getScope(); element.setAttribute("scope", scope.name()); if (libraryEntry.isModuleLevel()) { final String[] urls = libraryEntry.getRootUrls(OrderRootType.SOURCES); String eclipseUrl = null; if (urls.length > 0) { eclipseUrl = urls[0]; final int jarSeparatorIdx = urls[0].indexOf(JarFileSystem.JAR_SEPARATOR); if (jarSeparatorIdx > -1) { eclipseUrl = eclipseUrl.substring(0, jarSeparatorIdx); } } for (String url : urls) { Element srcElement = new Element(SRCROOT_ATTR); srcElement.setAttribute("url", url); if (!areUrlsPointTheSame(url, eclipseUrl)) { srcElement.setAttribute(SRCROOT_BIND_ATTR, String.valueOf(false)); } element.addContent(srcElement); } final String[] javadocUrls = libraryEntry.getRootUrls(JavadocOrderRootType.getInstance()); for (int i = 1; i < javadocUrls.length; i++) { Element javadocElement = new Element(JAVADOCROOT_ATTR); javadocElement.setAttribute("url", javadocUrls[i]); element.addContent(javadocElement); } for (String srcUrl : libraryEntry.getRootUrls(OrderRootType.SOURCES)) { appendModuleRelatedRoot(element, srcUrl, RELATIVE_MODULE_SRC, model); } for (String classesUrl : libraryEntry.getRootUrls(OrderRootType.CLASSES)) { appendModuleRelatedRoot(element, classesUrl, RELATIVE_MODULE_CLS, model); } for (String javadocUrl : libraryEntry.getRootUrls(JavadocOrderRootType.getInstance())) { appendModuleRelatedRoot(element, javadocUrl, RELATIVE_MODULE_JAVADOC, model); } if (!element.getChildren().isEmpty()) { root.addContent(element); isModified = true; continue; } } else { String libraryLevel = libraryEntry.getLibraryLevel(); if (!LibraryTablesRegistrar.APPLICATION_LEVEL.equals(libraryLevel)) { libLevels.put(libraryEntry.getLibraryName(), libraryLevel); } } if (!scope.equals(DependencyScope.COMPILE)) { root.addContent(element); isModified = true; } } if (!libLevels.isEmpty()) { Element libLevelsElement = new Element("levels"); for (String libName : libLevels.keySet()) { Element libElement = new Element("level"); libElement.setAttribute("name", libName); libElement.setAttribute("value", libLevels.get(libName)); libLevelsElement.addContent(libElement); } root.addContent(libLevelsElement); } PathMacroManager.getInstance(model.getModule()).collapsePaths(root); return isModified; }
writeIdeaSpecificClasspath
26,068
void (Element element, String classesUrl, final String rootName, ModuleRootModel model) { VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(classesUrl); if (file == null) { return; } final Project project = model.getModule().getProject(); if (file.getFileSystem() instanceof JarFileSystem) { file = JarFileSystem.getInstance().getVirtualFileForJar(file); assert file != null; } final Module module = ModuleUtilCore.findModuleForFile(file, project); if (module != null) { 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; } } } }
appendModuleRelatedRoot
26,069
boolean (Element element, String classesUrl, String rootName, VirtualFile file, Module module) { 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)); element.addContent(clsElement); return true; } } return false; }
appendRelatedToModule
26,070
Element (@NotNull ModuleRootModel model) { Element classpathElement = new Element(EclipseXml.CLASSPATH_TAG); for (OrderEntry orderEntry : model.getOrderEntries()) { createClasspathEntry(orderEntry, classpathElement, model); } String outputPath = "bin"; final String compilerOutputUrl = model.getModuleExtension(CompilerModuleExtension.class).getCompilerOutputUrl(); final EclipseModuleManager eclipseModuleManager = EclipseModuleManagerImpl.getInstance(model.getModule()); final String linkedPath = eclipseModuleManager.getEclipseLinkedVarPath(compilerOutputUrl); if (linkedPath != null) { outputPath = linkedPath; } else { VirtualFile contentRoot = EPathUtil.getContentRoot(model); VirtualFile output = model.getModuleExtension(CompilerModuleExtension.class).getCompilerOutputPath(); if (contentRoot != null && output != null && VfsUtilCore.isAncestor(contentRoot, output, false)) { outputPath = EPathUtil.collapse2EclipsePath(output.getUrl(), model); } else if (output == null && compilerOutputUrl != null) { outputPath = EPathUtil.collapse2EclipsePath(compilerOutputUrl, model); } } for (String support : eclipseModuleManager.getUsedCons()) { addOrderEntry(EclipseXml.CON_KIND, support, classpathElement, eclipseModuleManager.getSrcPlace(support), myOldEntries); } setAttributeIfAbsent(addOrderEntry(EclipseXml.OUTPUT_KIND, outputPath, classpathElement), EclipseXml.PATH_ATTR, EclipseXml.BIN_DIR); return classpathElement; }
writeClasspath
26,071
Element (String kind, String path, Element classpathRoot) { return addOrderEntry(kind, path, classpathRoot, myOldEntries); }
addOrderEntry
26,072
Element (String kind, String path, Element classpathRoot, Map<String, Element> oldEntries) { return addOrderEntry(kind, path, classpathRoot, -1, oldEntries); }
addOrderEntry
26,073
Element (@NotNull String kind, String path, Element classpathRoot, int index, Map<String, Element> oldEntries) { Element element = getOldElement(kind, path, oldEntries); if (element != null) { Element clonedElement = element.clone(); if (index == -1 || index >= classpathRoot.getContentSize()) { classpathRoot.addContent(clonedElement); } else { classpathRoot.addContent(index, clonedElement); } return clonedElement; } Element orderEntry = new Element(EclipseXml.CLASSPATHENTRY_TAG); orderEntry.setAttribute(EclipseXml.KIND_ATTR, kind); if (path != null) { orderEntry.setAttribute(EclipseXml.PATH_ATTR, path); } if (index == -1 || index >= classpathRoot.getContentSize()) { classpathRoot.addContent(orderEntry); } else { classpathRoot.addContent(index, orderEntry); } return orderEntry; }
addOrderEntry
26,074
Element (@NotNull String kind, String path, Map<String, Element> entries) { return entries.get(kind + getJREKey(path)); }
getOldElement
26,075
String (String path) { return path.startsWith(EclipseXml.JRE_CONTAINER) ? EclipseXml.JRE_CONTAINER : path; }
getJREKey
26,076
void (Element orderEntry, ExportableOrderEntry dependency) { setExported(orderEntry, dependency.isExported()); }
setExported
26,077
void (Element orderEntry, boolean exported) { setOrRemoveAttribute(orderEntry, EclipseXml.EXPORTED_ATTR, exported ? EclipseXml.TRUE_VALUE : null); }
setExported
26,078
void (@NotNull Element element, @NotNull String name, @Nullable String value) { if (value == null) { element.removeAttribute(name); } else { element.setAttribute(name, value); } }
setOrRemoveAttribute
26,079
void (@NotNull Element element, String name, String value) { if (element.getAttribute(name) == null) { element.setAttribute(name, value); } }
setAttributeIfAbsent
26,080
void (Element element, ModuleRootModel model, final List<String> currentRoots, Library.ModifiableModel modifiableModel) { final Element attributes = element.getChild("attributes"); if (attributes == null) { return; } for (Element attribute : attributes.getChildren("attribute")) { if (Comparing.strEqual(attribute.getAttributeValue("name"), JAVADOC_LOCATION)) { String javadocPath = attribute.getAttributeValue("value"); if (!SystemInfo.isWindows) { javadocPath = javadocPath.replaceFirst(FILE_PROTOCOL, FILE_PROTOCOL + "/"); } modifiableModel.addRoot(toIdeaJavadocUrl(model, javadocPath, currentRoots), JavadocOrderRootType.getInstance()); } } }
appendJavadocRoots
26,081
String (ModuleRootModel model, String javadocPath, List<String> currentRoots) { if (javadocPath.startsWith(FILE_PROTOCOL)) { if (new File(javadocPath.substring(FILE_PROTOCOL.length())).exists()) { return VfsUtilCore.pathToUrl(javadocPath.substring(FILE_PROTOCOL.length())); } } else { final String protocol = VirtualFileManager.extractProtocol(javadocPath); if (Comparing.strEqual(protocol, HttpFileSystem.getInstance().getProtocol())) { return javadocPath; } else if (javadocPath.startsWith(JAR_PREFIX)) { final String jarJavadocPath = javadocPath.substring(JAR_PREFIX.length()); if (jarJavadocPath.startsWith(PLATFORM_PROTOCOL)) { final String relativeToPlatform = jarJavadocPath.substring(PLATFORM_PROTOCOL.length() + "resource".length()); // starts with leading / final VirtualFile currentRoot = getContentRoot(model); final String currentModulePath = (currentRoot != null ? currentRoot.getParent().getPath() : model.getModule().getProject().getBaseDir().getPath()) + relativeToPlatform; if (isJarFileExist(currentModulePath)) { return VirtualFileManager.constructUrl(JarFileSystem.PROTOCOL, currentModulePath); } else { final String moduleName = EPathCommonUtil.getRelativeModuleName(relativeToPlatform); final String relativeToModulePathWithJarSuffix = EPathCommonUtil.getRelativeToModulePath(relativeToPlatform); final String relativeToModulePath = stripPathInsideJar(relativeToModulePathWithJarSuffix); final Module otherModule = ModuleManager.getInstance(model.getModule().getProject()).findModuleByName(moduleName); String url = null; if (otherModule != null && otherModule != model.getModule()) { url = expandEclipseRelative2OtherModule(otherModule, relativeToModulePath); } else if (currentRoots != null) { url = EPathCommonUtil.expandEclipseRelative2ContentRoots(currentRoots, moduleName, relativeToModulePath); } if (url != null) { assert relativeToModulePathWithJarSuffix != null; assert relativeToModulePath != null; if (relativeToModulePath.length() < relativeToModulePathWithJarSuffix.length()) { url += relativeToModulePathWithJarSuffix.substring(relativeToModulePath.length()); } return VirtualFileManager.constructUrl(JarFileSystem.PROTOCOL, VfsUtilCore.urlToPath(url)); } } } else if (jarJavadocPath.startsWith(FILE_PROTOCOL)) { final String localFile = jarJavadocPath.substring(FILE_PROTOCOL.length()); if (isJarFileExist(localFile)) { return VirtualFileManager.constructUrl(JarFileSystem.PROTOCOL, localFile); } } } } return javadocPath; }
toIdeaJavadocUrl
26,082
String (@Nullable String relativeToModulePathWithJarSuffix) { String relativeToModulePath = relativeToModulePathWithJarSuffix; if (relativeToModulePath != null) { int jarSufIdx = relativeToModulePathWithJarSuffix.indexOf(JarFileSystem.JAR_SEPARATOR); if (jarSufIdx != -1) { relativeToModulePath = relativeToModulePath.substring(0, jarSufIdx); } } return relativeToModulePath; }
stripPathInsideJar
26,083
boolean (String path) { final int jarSufIdx = path.indexOf(JarFileSystem.JAR_SEPARATOR); if (jarSufIdx != -1) { path = path.substring(0, jarSufIdx); } return new File(path).exists(); }
isJarFileExist
26,084
String (ModuleRootModel model, String javadocPath) { final String protocol = VirtualFileManager.extractProtocol(javadocPath); if (!Comparing.strEqual(protocol, HttpFileSystem.getInstance().getProtocol())) { final String path = VfsUtilCore.urlToPath(javadocPath); final VirtualFile contentRoot = getContentRoot(model); final Project project = model.getModule().getProject(); final VirtualFile baseDir = contentRoot != null ? contentRoot.getParent() : project.getBaseDir(); if (Comparing.strEqual(protocol, JarFileSystem.getInstance().getProtocol())) { final VirtualFile javadocFile = JarFileSystem.getInstance().getVirtualFileForJar(VirtualFileManager.getInstance().findFileByUrl(javadocPath)); if (javadocFile != null) { final String relativeUrl; if (contentRoot != null && VfsUtilCore.isAncestor(contentRoot, javadocFile, false)) { relativeUrl = "/" + VfsUtilCore.getRelativePath(javadocFile, baseDir, '/'); } else { relativeUrl = collapse2eclipseRelative2OtherModule(project, javadocFile); } if (relativeUrl != null) { if (!javadocPath.contains(JarFileSystem.JAR_SEPARATOR)) { javadocPath = StringUtil.trimEnd(javadocPath, "/") + JarFileSystem.JAR_SEPARATOR; } javadocPath = JAR_PREFIX + PLATFORM_PROTOCOL + "resource" + relativeUrl + javadocPath.substring(javadocFile.getUrl().length() - 1); } else { LOG.info("Javadoc path: " + javadocPath); final Module module = ModuleUtilCore.findModuleForFile(javadocFile, project); LOG.info("Module: " + (module != null ? module.getName() : "not found")); if (module != null) { LOG.info("Content roots: " + Arrays.toString(ModuleRootManager.getInstance(module).getContentRoots())); } javadocPath = JAR_PREFIX + FILE_PROTOCOL + StringUtil.trimStart(path, "/"); } } else { javadocPath = JAR_PREFIX + FILE_PROTOCOL + StringUtil.trimStart(path, "/"); } } else if (new File(path).exists()) { javadocPath = FILE_PROTOCOL + StringUtil.trimStart(path, "/"); } } return javadocPath; }
toEclipseJavadocPath
26,085
void (Element orderEntry, LibraryOrderEntry libraryOrderEntry, final ModuleRootModel model) { setupAttributes(orderEntry, s -> toEclipseJavadocPath(model, s), JAVADOC_LOCATION, libraryOrderEntry.getRootUrls(JavadocOrderRootType.getInstance())); }
setupJavadocAttributes
26,086
boolean (String ideaUrl, String eclipseUrl) { final String path = VfsUtilCore.urlToPath(eclipseUrl); if (ideaUrl.contains(path)) { return true; } else { final String relativeToModulePath = EPathCommonUtil.getRelativeToModulePath(path); final int relativeIdx = relativeToModulePath != null ? ideaUrl.indexOf(relativeToModulePath) : -1; if (relativeIdx != -1) { final String pathToProjectFile = VfsUtilCore.urlToPath(ideaUrl.substring(0, relativeIdx)); if (Comparing.strEqual(EPathCommonUtil.getRelativeModuleName(path), EclipseProjectFinder.findProjectName(pathToProjectFile))) { return true; } } } return false; }
areUrlsPointTheSame
26,087
String (final String path, final ModifiableRootModel model, final List<String> currentRoots) { final VirtualFile contentRoot = getContentRoot(model); LOG.assertTrue(contentRoot != null); return expandEclipsePath2Url(path, model, currentRoots, contentRoot); }
expandEclipsePath2Url
26,088
String (final String path, final ModifiableRootModel model, final List<String> currentRoots, final @NotNull VirtualFile contentRoot) { final String rootPath = contentRoot.getPath(); String url = null; if (new File(path).exists()) { //absolute path url = EPathCommonUtil.pathToUrl(path); } else { if (path.startsWith("/")) { //relative to other project final String moduleName = EPathCommonUtil.getRelativeModuleName(path); final String relativeToRootPath = EPathCommonUtil.getRelativeToModulePath(path); final Module otherModule = ModuleManager.getInstance(model.getModule().getProject()).findModuleByName(moduleName); if (otherModule != null && otherModule != model.getModule()) { url = expandEclipseRelative2OtherModule(otherModule, relativeToRootPath); } else if (currentRoots != null) { url = EPathCommonUtil.expandEclipseRelative2ContentRoots(currentRoots, moduleName, relativeToRootPath); } } else { final String relativePath = new File(rootPath, path).getPath(); //inside current project final File file = new File(relativePath); if (file.exists()) { url = EPathCommonUtil.pathToUrl(relativePath); } } } if (url == null) { url = EPathCommonUtil.pathToUrl(path); } final VirtualFile localFile = VirtualFileManager.getInstance().findFileByUrl(url); if (localFile != null) { final VirtualFile jarFile = JarFileSystem.getInstance().getJarRootForLocalFile(localFile); if (jarFile != null) { url = jarFile.getUrl(); } } return url; }
expandEclipsePath2Url
26,089
String (final String url, final ModuleRootModel model) { final Project project = model.getModule().getProject(); final VirtualFile contentRoot = getContentRoot(model); VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(url); if (file != null) { LOG.assertTrue(file.isValid()); if (file.getFileSystem() instanceof JarFileSystem) { final VirtualFile jarFile = JarFileSystem.getInstance().getVirtualFileForJar(file); if (jarFile == null) { LOG.error("Url: '" + url + "'; file: " + file); return ProjectRootManagerImpl.Companion.extractLocalPath(url); } file = jarFile; } if (contentRoot != null && VfsUtilCore.isAncestor(contentRoot, file, false)) { //inside current project return VfsUtilCore.getRelativePath(file, contentRoot, '/'); } else { final String path = collapse2eclipseRelative2OtherModule(project, file); //relative to other project if (path != null) { return path; } } } else { //try to avoid absolute path for deleted file if (contentRoot != null) { final String rootUrl = contentRoot.getUrl(); if (url.startsWith(rootUrl) && url.length() > rootUrl.length()) { return url.substring(rootUrl.length() + 1); //without leading / } } final VirtualFile projectBaseDir = contentRoot != null ? contentRoot.getParent() : project.getBaseDir(); assert projectBaseDir != null; final String projectUrl = projectBaseDir.getUrl(); if (url.startsWith(projectUrl)) { return url.substring(projectUrl.length()); //leading / } final String path = VfsUtilCore.urlToPath(url); final String projectPath = projectBaseDir.getPath(); if (path.startsWith(projectPath)) { return ProjectRootManagerImpl.Companion.extractLocalPath(path.substring(projectPath.length())); } } return ProjectRootManagerImpl.Companion.extractLocalPath(url); //absolute path }
collapse2EclipsePath
26,090
void (ActionEvent e) { updateProjectListEnabledStatus(); }
actionPerformed
26,091
void (ActionEvent e) { updateProjectListEnabledStatus(); }
actionPerformed
26,092
void (ListSelectionEvent e) { EclipseProjectCodeStyleData codeStyleData = myCodeStylesList.getSelectedValue(); updateOnSelectedItemChange(codeStyleData); }
valueChanged
26,093
void (ActionEvent e) { updateOnOrganizeImportsBoxChange(); }
actionPerformed
26,094
void (@NotNull JBLabel hintLabel) { hintLabel.setForeground(JBColor.GRAY); hintLabel.setFont(UIUtil.getLabelFont(UIUtil.FontSize.SMALL)); }
customizeHintLabel
26,095
JComponent () { return myTopPanel; }
getComponent
26,096
void () { EclipseImportBuilder builder = (EclipseImportBuilder)getWizardContext().getProjectBuilder(); assert builder != null; if (myImportCodeStyleRB.isSelected()) { builder.getParameters().codeStyleData = myCodeStylesList.getSelectedValue(); } }
updateDataModel
26,097
void (@Nullable EclipseProjectCodeStyleData codeStyleData) { myOrganizeImportsCheckBox.setEnabled(codeStyleData != null && codeStyleData.isEclipseImportsConfigAvailable()); myOrganizeImportsCheckBox.setSelected(codeStyleData != null && codeStyleData.isImportOrganizeImportsConfig()); }
updateOnSelectedItemChange
26,098
void () { EclipseProjectCodeStyleData codeStyleData = myCodeStylesList.getSelectedValue(); if (codeStyleData != null) { codeStyleData.setImportOrganizeImportsConfig(myOrganizeImportsCheckBox.isSelected()); } }
updateOnOrganizeImportsBoxChange
26,099
void () { myCodeStylesListModel.clear(); for(EclipseProjectCodeStyleData codeStyleData : getCodeStylesList()) { myCodeStylesListModel.addElement(codeStyleData); } boolean isEnabled = !myCodeStylesListModel.isEmpty(); myImportCodeStyleRB.setEnabled(isEnabled); myImportCodeStyleLabel.setEnabled(isEnabled); myUseDefaultCodeStyleRB.setSelected(true); updateProjectListEnabledStatus(); }
updateStep