Unnamed: 0
int64 0
305k
| body
stringlengths 7
52.9k
| name
stringlengths 1
185
|
---|---|---|
0 | CharSequence (@NotNull String text, boolean caseSensitive, boolean recursively) { return recursively ? substituteRecursively(text, caseSensitive) : substitute(text, caseSensitive); } | substitute |
1 | void (@NotNull Element e, boolean caseSensitive) { substitute(e, caseSensitive, false); } | substitute |
2 | void (@NotNull Element element, boolean caseSensitive, boolean recursively, @Nullable PathMacroFilter filter) { if (filter != null && filter.skipPathMacros(element)) { return; } for (Content child : element.getContent()) { if (child instanceof Element) { substitute((Element)child, caseSensitive, recursively, filter); } else if (child instanceof Text) { Text t = (Text)child; String oldText = t.getText(); String newText = recursively ? substituteRecursively(oldText, caseSensitive).toString() : substitute(oldText, caseSensitive); if (!Strings.areSameInstance(oldText, newText)) { // it is faster to call 'setText' right away than perform additional 'equals' check t.setText(newText); } } else { LOG.error("Wrong content: " + child.getClass()); } } if (!element.hasAttributes()) { return; } for (Attribute attribute : element.getAttributes()) { if (filter == null || !filter.skipPathMacros(attribute)) { String newValue = getAttributeValue(attribute, filter, caseSensitive, recursively); if (!Strings.areSameInstance(attribute.getValue(), newValue)) { // it is faster to call 'setValue' right away than perform additional 'equals' check attribute.setValue(newValue); } } } } | substitute |
3 | String (@NotNull Attribute attribute, @Nullable PathMacroFilter filter, boolean caseSensitive, boolean recursively) { String oldValue = attribute.getValue(); if (recursively || (filter != null && filter.recursePathMacros(attribute))) { return substituteRecursively(oldValue, caseSensitive).toString(); } else { return substitute(oldValue, caseSensitive); } } | getAttributeValue |
4 | void (@NotNull Element e, boolean caseSensitive, boolean recursively) { substitute(e, caseSensitive, recursively, null); } | substitute |
5 | CharSequence (@NotNull String text, boolean caseSensitive) { return substitute(text, caseSensitive); } | substituteRecursively |
6 | void (@NotNull String macroName, @NotNull String path) { myMacroExpands.put(macroName, FileUtilRt.toSystemIndependentName(path)); } | addMacroExpand |
7 | void (@NotNull String fromText, @NotNull String toText) { myPlainMap.put(fromText, toText); } | put |
8 | void (@NotNull ExpandMacroToPathMap another) { myPlainMap.putAll(another.myPlainMap); myMacroExpands.putAll(another.myMacroExpands); } | putAll |
9 | String (@NotNull String text, boolean caseSensitive) { if (text.indexOf('$') < 0 && text.indexOf('%') < 0) { return text; } for (Map.Entry<String, String> entry : myPlainMap.entrySet()) { // when replacing macros with actual paths, the replace utility may be used as always 'case-sensitive' // for case-insensitive file systems, there will be no unnecessary toLowerCase() transforms. text = StringUtil.replace(text, entry.getKey(), entry.getValue(), false); } for (String macroName : myMacroExpands.keySet()) { text = replaceMacro(text, macroName, myMacroExpands.get(macroName)); } return text; } | substitute |
10 | String (@NotNull String text, @NotNull String macroName, @NotNull String replacement) { while (true) { int start = findMacroIndex(text, macroName); if (start < 0) { break; } int end = start + macroName.length() + 2; int slashCount = getSlashCount(text, end); String actualReplacement = slashCount > 0 && !replacement.endsWith("/") ? replacement + "/" : replacement; text = StringUtil.replaceSubstring(text, new TextRange(start, end + slashCount), actualReplacement); } return text; } | replaceMacro |
11 | int (@NotNull String text, int pos) { return StringUtil.isChar(text, pos, '/') ? StringUtil.isChar(text, pos + 1, '/') ? 2 : 1 : 0; } | getSlashCount |
12 | int (@NotNull String text, @NotNull String macroName) { int i = -1; while (true) { i = text.indexOf('$', i + 1); if (i < 0) { return -1; } if (StringUtil.startsWith(text, i + 1, macroName) && StringUtil.isChar(text, i + macroName.length() + 1, '$')) { return i; } } } | findMacroIndex |
13 | int () { return myPlainMap.hashCode() + myMacroExpands.hashCode(); } | hashCode |
14 | boolean (@NotNull Element element) { return false; } | skipPathMacros |
15 | boolean (@NotNull Attribute attribute) { return false; } | skipPathMacros |
16 | boolean (@NotNull Attribute attribute) { return false; } | recursePathMacros |
17 | void (@NotNull JpsProject project, @NotNull Element componentTag) { var optionsValues = new EnumMap<Options, Boolean>(Options.class); var optionElements = componentTag.getChildren(OPTION_TAG); for (var element : optionElements) { try { var name = Options.valueOf(element.getAttributeValue(NAME_ATTRIBUTE)); var value = Boolean.parseBoolean(element.getAttributeValue(VALUE_ATTRIBUTE)); optionsValues.put(name, value); } catch (Exception ignored) { } } var resolverConfigurationService = JpsDependencyResolverConfigurationService.getInstance(); var config = resolverConfigurationService.getOrCreateDependencyResolverConfiguration(project); if (optionsValues.containsKey(Options.VERIFY_SHA256_CHECKSUMS)) { config.setSha256ChecksumVerificationEnabled(optionsValues.get(Options.VERIFY_SHA256_CHECKSUMS)); } if (optionsValues.containsKey(Options.USE_BIND_REPOSITORY)) { config.setBindRepositoryEnabled(optionsValues.get(Options.USE_BIND_REPOSITORY)); } } | loadExtension |
18 | Runnable (final String name) { if (!LOG.isDebugEnabled()) { return EmptyRunnable.INSTANCE; } long start = System.nanoTime(); return () -> LOG.debug(name + " in " + TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start) + "ms"); } | startActivity |
19 | void (@NotNull JpsProject project, @NotNull Element componentTag) { String projectEncoding = null; Map<String, String> urlToEncoding = new HashMap<>(); for (Element fileTag : JDOMUtil.getChildren(componentTag, "file")) { String url = fileTag.getAttributeValue("url"); String encoding = fileTag.getAttributeValue("charset"); if (url.equals("PROJECT")) { projectEncoding = encoding; } else { urlToEncoding.put(url, encoding); } } JpsEncodingConfigurationService.getInstance().setEncodingConfiguration(project, projectEncoding, urlToEncoding); } | loadExtension |
20 | void (@NotNull JpsGlobal global, @NotNull Element componentTag) { String encoding = componentTag.getAttributeValue(ENCODING_ATTRIBUTE); JpsEncodingConfigurationService.getInstance().setGlobalEncoding(global, StringUtil.nullize(encoding)); } | loadExtension |
21 | void (@NotNull JpsGlobal global) { JpsEncodingConfigurationService.getInstance().setGlobalEncoding(global, CharsetToolkit.UTF8); } | loadExtensionWithDefaultSettings |
22 | void (@NotNull Path optionsDir) { Path defaultConfigFile = optionsDir.resolve("other.xml"); LOG.debug("Loading config from " + optionsDir.toAbsolutePath()); for (JpsGlobalExtensionSerializer serializer : SERIALIZERS) { loadGlobalComponents(optionsDir, defaultConfigFile, serializer); } for (JpsModelSerializerExtension extension : JpsModelSerializerExtension.getExtensions()) { for (JpsGlobalExtensionSerializer serializer : extension.getGlobalExtensionSerializers()) { loadGlobalComponents(optionsDir, defaultConfigFile, serializer); } } } | load |
23 | void (@NotNull Path optionsDir, @NotNull Path defaultConfigFile, JpsGlobalExtensionSerializer serializer) { loadComponents(optionsDir, defaultConfigFile.getParent(), serializer, myGlobal); } | loadGlobalComponents |
24 | void (@NotNull JpsGlobal global, @NotNull Element componentTag) { JpsPathVariablesConfiguration configuration = global.getContainer().setChild(PATH_VARIABLES_ROLE, new JpsPathVariablesConfigurationImpl()); for (Element macroTag : JDOMUtil.getChildren(componentTag, MACRO_TAG)) { String name = macroTag.getAttributeValue(NAME_ATTRIBUTE); String value = macroTag.getAttributeValue(VALUE_ATTRIBUTE); if (name != null && value != null) { configuration.addPathVariable(name, StringUtil.trimEnd(FileUtil.toSystemIndependentName(value), "/")); } } } | loadExtension |
25 | void (@NotNull JpsGlobal global, @NotNull Element componentTag) { JpsLibraryTableSerializer.loadLibraries(componentTag, global.getPathMapper(), global.getLibraryCollection()); } | loadExtension |
26 | void (@NotNull JpsGlobal global, @NotNull Element componentTag) { JpsSdkTableSerializer.loadSdks(componentTag, global.getLibraryCollection(), global.getPathMapper()); } | loadExtension |
27 | void (@NotNull JpsGlobal global, @NotNull Element componentTag) { Element ignoreFilesTag = componentTag.getChild("ignoreFiles"); if (ignoreFilesTag != null) { global.getFileTypesConfiguration().setIgnoredPatternString(ignoreFilesTag.getAttributeValue("list")); } } | loadExtension |
28 | void (String macroName, File file) { doAddFileHierarchyReplacements("$" + macroName + "$", file); } | addFileHierarchyReplacements |
29 | void (String macroName, String path) { myExpandMacroMap.addMacroExpand(macroName, path); } | addMacro |
30 | void (String macro, @Nullable File file) { if (file == null) { return; } doAddFileHierarchyReplacements(macro + "/..", file.getParentFile()); String path = FileUtilRt.toSystemIndependentName(file.getPath()); if (StringUtilRt.endsWithChar(path, '/')) { myExpandMacroMap.put(macro + "/", path); myExpandMacroMap.put(macro, path.substring(0, path.length()-1)); } else { myExpandMacroMap.put(macro, path); } } | doAddFileHierarchyReplacements |
31 | void (@NotNull Element element, boolean caseSensitive) { myExpandMacroMap.substitute(element, caseSensitive); } | substitute |
32 | ExpandMacroToPathMap () { return myExpandMacroMap; } | getExpandMacroMap |
33 | String (@NotNull String element, boolean caseSensitive) { return myExpandMacroMap.substitute(element, caseSensitive); } | substitute |
34 | String () { return myConfigFileName; } | getConfigFileName |
35 | String () { return myComponentName; } | getComponentName |
36 | void (@NotNull E e) { } | loadExtensionWithDefaultSettings |
37 | void (@NotNull E e, @NotNull Element componentTag) { } | saveExtension |
38 | Iterable<JpsModelSerializerExtension> () { return JpsServiceManager.getInstance().getExtensions(JpsModelSerializerExtension.class); } | getExtensions |
39 | void (@NotNull JpsModule module, @NotNull Element rootModel) { } | loadRootModel |
40 | void (@NotNull JpsModule module, @NotNull Element rootElement) { } | loadModuleOptions |
41 | List<JpsLibraryRootTypeSerializer> () { return Collections.emptyList(); } | getLibraryRootTypeSerializers |
42 | List<JpsLibraryRootTypeSerializer> () { return Collections.emptyList(); } | getSdkRootTypeSerializers |
43 | void (JpsDependencyElement dependency, Element orderEntry) { } | loadModuleDependencyProperties |
44 | String (JpsElementReference<? extends JpsCompositeElement> reference) { return null; } | getLibraryTableLevelId |
45 | JpsModuleClasspathSerializer () { return null; } | getClasspathSerializer |
46 | String () { return myTypeId; } | getTypeId |
47 | Type () { return myType; } | getType |
48 | JpsSerializationManager () { return JpsServiceManager.getInstance().getService(JpsSerializationManager.class); } | getInstance |
49 | String () { return Objects.requireNonNull(getGlobalSystemMacroValue(USER_HOME_NAME)); } | getUserHomePath |
50 | String () { return Strings.trimEnd(FileUtilRt.toSystemIndependentName(SystemProperties.getUserHome()), "/"); } | computeUserHomePath |
51 | String (@NotNull String path) { if (myWslRootPrefix == null || path.indexOf(':') != 1) { String wslPath; try { wslPath = runWslPath(path); } catch (IOException | InterruptedException e) { return path; } if (path.indexOf(':') == 1) { int pathLengthAfterDriveLetter = path.length() - 2; myWslRootPrefix = wslPath.substring(0, wslPath.length() - pathLengthAfterDriveLetter - 1); } return wslPath; } return myWslRootPrefix + Character.toLowerCase(path.charAt(0)) + FileUtil.toSystemIndependentName(path.substring(2)); } | mapPath |
52 | JpsMacroExpander (Map<String, String> pathVariables, @NotNull Path baseDir) { JpsMacroExpander expander = new JpsMacroExpander(pathVariables); expander.addFileHierarchyReplacements(PathMacroUtil.PROJECT_DIR_MACRO_NAME, baseDir.toFile()); return expander; } | createProjectMacroExpander |
53 | String (@NotNull Path dir) { String name = JpsPathUtil.readProjectName(dir); return name != null ? name : JpsPathUtil.getDefaultProjectName(dir); } | getDirectoryBaseProjectName |
54 | void (@NotNull Path dir, @NotNull Executor executor) { myProject.setName(getDirectoryBaseProjectName(dir)); Path defaultConfigFile = dir.resolve("misc.xml"); JpsSdkType<?> projectSdkType = loadProjectRoot(loadRootElement(defaultConfigFile)); for (JpsModelSerializerExtension extension : JpsModelSerializerExtension.getExtensions()) { for (JpsProjectExtensionSerializer serializer : extension.getProjectExtensionSerializers()) { loadComponents(dir, defaultConfigFile, serializer, myProject); } } Path externalConfigDir = resolveExternalProjectConfig("project"); if (externalConfigDir != null) { LOG.info("External project config dir is used: " + externalConfigDir); } Element moduleData = JDomSerializationUtil.findComponent(loadRootElement(dir.resolve("modules.xml")), MODULE_MANAGER_COMPONENT); Element externalModuleData; if (externalConfigDir == null) { externalModuleData = null; } else { Element rootElement = loadRootElement(externalConfigDir.resolve("modules.xml")); if (rootElement == null) { externalModuleData = null; } else { externalModuleData = JDomSerializationUtil.findComponent(rootElement, "ExternalProjectModuleManager"); if (externalModuleData == null) { externalModuleData = JDomSerializationUtil.findComponent(rootElement, "ExternalModuleListStorage"); } // old format (root tag is "component") if (externalModuleData == null && rootElement.getName().equals(JDomSerializationUtil.COMPONENT_ELEMENT)) { externalModuleData = rootElement; } } } if (externalModuleData != null) { String componentName = externalModuleData.getAttributeValue("name"); LOG.assertTrue(componentName != null && componentName.startsWith("External")); externalModuleData.setAttribute("name", componentName.substring("External".length())); if (moduleData == null) { moduleData = externalModuleData; } else { JDOMUtil.deepMerge(moduleData, externalModuleData); } } Path workspaceFile = dir.resolve("workspace.xml"); loadModules(moduleData, projectSdkType, workspaceFile, executor); Runnable timingLog = TimingLog.startActivity("loading project libraries"); for (Path libraryFile : listXmlFiles(dir.resolve("libraries"))) { loadProjectLibraries(loadRootElement(libraryFile)); } if (externalConfigDir != null) { loadProjectLibraries(loadRootElement(externalConfigDir.resolve("libraries.xml"))); } timingLog.run(); Runnable artifactsTimingLog = TimingLog.startActivity("loading artifacts"); for (Path artifactFile : listXmlFiles(dir.resolve("artifacts"))) { loadArtifacts(loadRootElement(artifactFile)); } if (externalConfigDir != null) { loadArtifacts(loadRootElement(externalConfigDir.resolve("artifacts.xml"))); } artifactsTimingLog.run(); if (hasRunConfigurationSerializers()) { Runnable runConfTimingLog = TimingLog.startActivity("loading run configurations"); for (Path configurationFile : listXmlFiles(dir.resolve("runConfigurations"))) { JpsRunConfigurationSerializer.loadRunConfigurations(myProject, loadRootElement(configurationFile)); } JpsRunConfigurationSerializer.loadRunConfigurations(myProject, JDomSerializationUtil.findComponent(loadRootElement(workspaceFile), "RunManager")); runConfTimingLog.run(); } } | loadFromDirectory |
55 | boolean () { for (JpsModelSerializerExtension extension : JpsModelSerializerExtension.getExtensions()) { if (!extension.getRunConfigurationPropertiesSerializers().isEmpty()) { return true; } } return false; } | hasRunConfigurationSerializers |
56 | List<Path> (@NotNull Path dir) { try { try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir, it -> it.getFileName().toString().endsWith(".xml") && Files.isRegularFile(it))) { return ContainerUtil.collect(stream.iterator()); } } catch (IOException e) { return Collections.emptyList(); } } | listXmlFiles |
57 | void (@NotNull Path iprFile, @NotNull Executor executor) { final Element iprRoot = loadRootElement(iprFile); String projectName = FileUtilRt.getNameWithoutExtension(iprFile.getFileName().toString()); myProject.setName(projectName); Path iwsFile = iprFile.getParent().resolve(projectName + ".iws"); Element iwsRoot = loadRootElement(iwsFile); JpsSdkType<?> projectSdkType = loadProjectRoot(iprRoot); for (JpsModelSerializerExtension extension : JpsModelSerializerExtension.getExtensions()) { for (JpsProjectExtensionSerializer serializer : extension.getProjectExtensionSerializers()) { Element rootTag = JpsProjectExtensionSerializer.WORKSPACE_FILE.equals(serializer.getConfigFileName()) ? iwsRoot : iprRoot; Element component = JDomSerializationUtil.findComponent(rootTag, serializer.getComponentName()); if (component != null) { serializer.loadExtension(myProject, component); } else { serializer.loadExtensionWithDefaultSettings(myProject); } } } loadModules(JDomSerializationUtil.findComponent(iprRoot, "ProjectModuleManager"), projectSdkType, iwsFile, executor); loadProjectLibraries(JDomSerializationUtil.findComponent(iprRoot, "libraryTable")); loadArtifacts(JDomSerializationUtil.findComponent(iprRoot, "ArtifactManager")); if (hasRunConfigurationSerializers()) { JpsRunConfigurationSerializer.loadRunConfigurations(myProject, JDomSerializationUtil.findComponent(iprRoot, "ProjectRunConfigurationManager")); JpsRunConfigurationSerializer.loadRunConfigurations(myProject, JDomSerializationUtil.findComponent(iwsRoot, "RunManager")); } } | loadFromIpr |
58 | void (@Nullable Element artifactManagerComponent) { JpsArtifactSerializer.loadArtifacts(myProject, artifactManagerComponent); } | loadArtifacts |
59 | void (@Nullable Element libraryTableElement) { JpsLibraryTableSerializer.loadLibraries(libraryTableElement, myPathMapper, myProject.getLibraryCollection()); } | loadProjectLibraries |
60 | void (@Nullable Element componentElement, @Nullable JpsSdkType<?> projectSdkType, @NotNull Path workspaceFile, @NotNull Executor executor) { Runnable timingLog = TimingLog.startActivity("loading modules"); if (componentElement == null) { return; } Set<String> unloadedModules = new HashSet<>(); if (!myLoadUnloadedModules && workspaceFile.toFile().exists()) { Element unloadedModulesList = JDomSerializationUtil.findComponent(loadRootElement(workspaceFile), "UnloadedModulesList"); for (Element element : JDOMUtil.getChildren(unloadedModulesList, "module")) { unloadedModules.add(element.getAttributeValue("name")); } } final Set<Path> foundFiles = CollectionFactory.createSmallMemoryFootprintSet(); final List<Path> moduleFiles = new ArrayList<>(); for (Element moduleElement : JDOMUtil.getChildren(componentElement.getChild(MODULES_TAG), MODULE_TAG)) { final String path = moduleElement.getAttributeValue(FILE_PATH_ATTRIBUTE); if (path != null) { final Path file = Path.of(path); if (foundFiles.add(file) && !unloadedModules.contains(getModuleName(file))) { moduleFiles.add(file); } } } List<JpsModule> modules = loadModules(moduleFiles, projectSdkType, myPathVariables, myPathMapper, executor); for (JpsModule module : modules) { myProject.addModule(module); } timingLog.run(); } | loadModules |
61 | List<JpsModule> (@NotNull List<? extends Path> moduleFiles, @Nullable JpsSdkType<?> projectSdkType, @NotNull Map<String, String> pathVariables, @NotNull JpsPathMapper pathMapper, @Nullable Executor executor) { if (executor == null) { executor = DefaultExecutorHolder.threadPool; } List<JpsModule> modules = new ArrayList<>(); List<CompletableFuture<Pair<Path, Element>>> futureModuleFilesContents = new ArrayList<>(); Path externalModuleDir = resolveExternalProjectConfig("modules"); if (externalModuleDir != null) { LOG.info("External project config dir is used for modules: " + externalModuleDir); } for (Path file : moduleFiles) { futureModuleFilesContents.add(CompletableFuture.supplyAsync(() -> { JpsMacroExpander expander = createModuleMacroExpander(pathVariables, file); Element data = loadRootElement(file, expander); if (externalModuleDir != null) { String externalName = FileUtilRt.getNameWithoutExtension(file.getFileName().toString()) + ".xml"; Element externalData = loadRootElement(externalModuleDir.resolve(externalName), expander); if (externalData != null) { if (data == null) { data = externalData; } else { JDOMUtil.deepMergeWithAttributes(data, externalData, List.of( new JDOMUtil.MergeAttribute("content", "url"), new JDOMUtil.MergeAttribute("component", "name") )); } } } if (data == null) { LOG.info("Module '" + getModuleName(file) + "' is skipped: " + file.toAbsolutePath() + " doesn't exist"); } else { // Copy the content roots that are defined in a separate tag, to a general content root component List<Element> components = data.getChildren("component"); Element rootManager = null; Element additionalElements = null; for (Element component : components) { String attributeValue = component.getAttributeValue("name"); if (attributeValue.equals("NewModuleRootManager")) rootManager = component; if (attributeValue.equals("AdditionalModuleElements")) additionalElements = component; if (rootManager != null && additionalElements != null) break; } if (rootManager != null && additionalElements != null) { // Cleanup attributes that aren't needed additionalElements.removeAttribute("name"); additionalElements.getChildren().forEach(o -> o.removeAttribute("dumb")); JDOMUtil.deepMerge(rootManager, additionalElements); } } return new Pair<>(file, data); }, executor)); } try { List<String> classpathDirs = new ArrayList<>(); for (CompletableFuture<Pair<Path, Element>> moduleFile : futureModuleFilesContents) { Element rootElement = moduleFile.join().getSecond(); if (rootElement != null) { String classpathDir = rootElement.getAttributeValue(CLASSPATH_DIR_ATTRIBUTE); if (classpathDir != null) { classpathDirs.add(classpathDir); } } } List<CompletableFuture<JpsModule>> futures = new ArrayList<>(); for (CompletableFuture<Pair<Path, Element>> futureModuleFile : futureModuleFilesContents) { Pair<Path, Element> moduleFile = futureModuleFile.join(); if (moduleFile.getSecond() != null) { futures.add(CompletableFuture.supplyAsync(() -> { return loadModule(moduleFile.getFirst(), moduleFile.getSecond(), classpathDirs, projectSdkType, pathVariables, pathMapper); }, executor)); } } for (CompletableFuture<JpsModule> future : futures) { JpsModule module = future.join(); if (module != null) { modules.add(module); } } return modules; } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException(e); } } | loadModules |
62 | JpsModule (@NotNull Path file, @NotNull Element moduleRoot, List<String> paths, @Nullable JpsSdkType<?> projectSdkType, Map<String, String> pathVariables, @NotNull JpsPathMapper pathMapper) { String name = getModuleName(file); final String typeId = moduleRoot.getAttributeValue("type"); final JpsModulePropertiesSerializer<?> serializer = getModulePropertiesSerializer(typeId); final JpsModule module = createModule(name, moduleRoot, serializer); module.getContainer().setChild(JpsModuleSerializationDataExtensionImpl.ROLE, new JpsModuleSerializationDataExtensionImpl(file.getParent())); for (JpsModelSerializerExtension extension : JpsModelSerializerExtension.getExtensions()) { extension.loadModuleOptions(module, moduleRoot); } String baseModulePath = FileUtilRt.toSystemIndependentName(file.getParent().toString()); String classpath = moduleRoot.getAttributeValue(CLASSPATH_ATTRIBUTE); if (classpath == null) { try { JpsModuleRootModelSerializer.loadRootModel(module, JDomSerializationUtil.findComponent(moduleRoot, "NewModuleRootManager"), projectSdkType, pathMapper); } catch (JpsSerializationFormatException e) { LOG.warn("Failed to load module configuration from " + file + ": " + e.getMessage(), e); } } else { for (JpsModelSerializerExtension extension : JpsModelSerializerExtension.getExtensions()) { JpsModuleClasspathSerializer classpathSerializer = extension.getClasspathSerializer(); if (classpathSerializer != null && classpathSerializer.getClasspathId().equals(classpath)) { String classpathDir = moduleRoot.getAttributeValue(CLASSPATH_DIR_ATTRIBUTE); final JpsMacroExpander expander = createModuleMacroExpander(pathVariables, file); classpathSerializer.loadClasspath(module, classpathDir, baseModulePath, expander, paths, projectSdkType); } } } Element facetsTag = JDomSerializationUtil.findComponent(moduleRoot, JpsFacetSerializer.FACET_MANAGER_COMPONENT_NAME); Element externalFacetsTag = JDomSerializationUtil.findComponent(moduleRoot, "ExternalFacetManager"); Element mergedFacetsTag; if (facetsTag == null) { mergedFacetsTag = externalFacetsTag; } else if (externalFacetsTag != null) { mergedFacetsTag = JDOMUtil.deepMerge(facetsTag, externalFacetsTag); } else { mergedFacetsTag = facetsTag; } JpsFacetSerializer.loadFacets(module, mergedFacetsTag); return module; } | loadModule |
63 | String (@NotNull Path file) { return FileUtilRt.getNameWithoutExtension(file.getFileName().toString()); } | getModuleName |
64 | JpsMacroExpander (final Map<String, String> pathVariables, @NotNull Path moduleFile) { JpsMacroExpander expander = new JpsMacroExpander(pathVariables); String moduleDirPath = PathMacroUtil.getModuleDir(moduleFile.toAbsolutePath().toString()); if (moduleDirPath != null) { expander.addFileHierarchyReplacements(PathMacroUtil.MODULE_DIR_MACRO_NAME, new File(FileUtilRt.toSystemDependentName(moduleDirPath))); } return expander; } | createModuleMacroExpander |
65 | JpsDummyElement (@Nullable Element componentElement) { return JpsElementFactory.getInstance().createDummyElement(); } | loadProperties |
66 | File () { String defaultMavenFolder = SystemProperties.getUserHome() + File.separator + M2_DIR; return new File(defaultMavenFolder, SETTINGS_XML); } | getUserMavenSettingsXml |
67 | File () { String mavenHome = resolveMavenHomeDirectory(); if (mavenHome == null) { return null; } return new File(mavenHome + File.separator + CONF_DIR, SETTINGS_XML); } | getGlobalMavenSettingsXml |
68 | String () { String m2home = System.getenv("M2_HOME"); if (isValidMavenHome(m2home)) return m2home; String mavenHome = System.getenv("MAVEN_HOME"); if (isValidMavenHome(mavenHome)) return mavenHome; String m2UserHome = SystemProperties.getUserHome() + File.separator + M2_DIR; if (isValidMavenHome(m2UserHome)) return m2UserHome; if (SystemInfoRt.isMac) { String mavenFromBrew = fromBrew(); if (isValidMavenHome(mavenFromBrew)) return mavenFromBrew; } if (SystemInfoRt.isLinux || SystemInfoRt.isMac) { String defaultHome = "/usr/share/maven"; if (isValidMavenHome(defaultHome)) return defaultHome; } return null; } | resolveMavenHomeDirectory |
69 | String () { String defaultMavenFolder = SystemProperties.getUserHome() + File.separator + M2_DIR; // Check user local settings File userSettingsFile = getUserMavenSettingsXml(); if (userSettingsFile.exists()) { String fromUserSettings = getRepositoryFromSettings(userSettingsFile); if (isNotEmpty(fromUserSettings) && new File(fromUserSettings).exists()) { return fromUserSettings; } } // Check global maven local settings File globalSettingsFile = getGlobalMavenSettingsXml(); if (globalSettingsFile != null && globalSettingsFile.exists()) { String fromGlobalSettings = getRepositoryFromSettings(globalSettingsFile); if (isNotEmpty(fromGlobalSettings) && new File(fromGlobalSettings).exists()) { return fromGlobalSettings; } } String defaultMavenRepository = defaultMavenFolder + File.separator + REPOSITORY_PATH; if (FileUtil.exists(defaultMavenFolder)) { return defaultMavenRepository; } return null; } | getMavenRepositoryPath |
70 | String () { final File brewDir = new File("/usr/local/Cellar/maven"); final String[] list = brewDir.list(); if (list == null || list.length == 0) return null; Arrays.sort(list, (o1, o2) -> compareVersionNumbers(o2, o1)); return brewDir + File.separator + list[0] + "/libexec"; } | fromBrew |
71 | String (final File file) { Element settingsXmlRoot; try { settingsXmlRoot = JDOMUtil.load(file); } catch (JDOMException | IOException e) { return null; } Optional<String> maybeRepository = KNOWN_NAMESPACES.stream() .map(it -> settingsXmlRoot.getChildText("localRepository", it)) .filter(it -> it != null && !isEmpty(it)) .findFirst(); return maybeRepository.orElse(null); } | getRepositoryFromSettings |
72 | boolean (@Nullable String path) { return isNotEmpty(path) && FileUtil.exists(path); } | isValidMavenHome |
73 | void (@NotNull File settingsXml, @NotNull Map<String, RemoteRepositoryAuthentication> output) { Element settingsXmlRoot; try { settingsXmlRoot = JDOMUtil.load(settingsXml); } catch (JDOMException | IOException e) { return; } Optional<Namespace> maybeNamespace = KNOWN_NAMESPACES.stream() .filter(it -> settingsXmlRoot.getChild("servers", it) != null) .findFirst(); if (maybeNamespace.isEmpty()) { return; } Namespace namespace = maybeNamespace.get(); Element serversElement = settingsXmlRoot.getChild("servers", namespace); for (Element serverElement : serversElement.getChildren("server", namespace)) { String id = serverElement.getChildText("id", namespace); String username = serverElement.getChildText("username", namespace); String password = serverElement.getChildText("password", namespace); if (id != null && username != null && password != null) { output.put(id, new RemoteRepositoryAuthentication(username, password)); } } } | loadAuthenticationFromSettings |
74 | String () { return username; } | getUsername |
75 | String () { return password; } | getPassword |
76 | Element (@Nullable Element root, @NonNls String componentName) { for (Element element : JDOMUtil.getChildren(root, COMPONENT_ELEMENT)) { if (isComponent(componentName, element)) { return element; } } return null; } | findComponent |
77 | boolean (@NotNull String componentName, @NotNull Element element) { return componentName.equals(element.getAttributeValue(Constants.NAME)); } | isComponent |
78 | Element (final String componentName) { final Element element = new Element(COMPONENT_ELEMENT); element.setAttribute(Constants.NAME, componentName); return element; } | createComponentElement |
79 | Element (@NotNull Element root, @NotNull String componentName) { Element component = findComponent(root, componentName); if (component == null) { component = createComponentElement(componentName); addComponent(root, component); } return component; } | findOrCreateComponentElement |
80 | void (@NotNull Element root, @NotNull Element component) { String componentName = component.getAttributeValue(Constants.NAME); Element old = findComponent(root, componentName); if (old != null) { root.removeContent(old); } for (int i = 0; i < root.getContent().size(); i++) { Content o = root.getContent().get(i); if (o instanceof Element) { Element element = (Element)o; if (element.getName().equals(COMPONENT_ELEMENT)) { final String name = element.getAttributeValue(Constants.NAME); if (componentName.compareTo(name) < 0) { root.addContent(i, component); return; } } } } root.addContent(component); } | addComponent |
81 | Element (@NotNull Path file) { return loadRootElement(file, myMacroExpander); } | loadRootElement |
82 | Element (@NotNull Path file, @NotNull JpsMacroExpander macroExpander) { final Element element = tryLoadRootElement(file); if (element != null) { macroExpander.substitute(element, SystemInfo.isFileSystemCaseSensitive); } return element; } | loadRootElement |
83 | Element (@NotNull Path file) { int i = 0; while (true) { try { return JDOMUtil.load(file); } catch (NoSuchFileException e) { return null; } catch (IOException | JDOMException e) { if (++i == MAX_ATTEMPTS) { //noinspection InstanceofCatchParameter throw new CannotLoadJpsModelException(file.toFile(), "Cannot " + (e instanceof IOException ? "read" : "parse") + " file " + file.toAbsolutePath() + ": " + e.getMessage(), e); } LOG.info("Loading attempt #" + i + " failed for " + file.toAbsolutePath(), e); try { LOG.info("File content: " + FileUtil.loadFile(file.toFile())); } catch (IOException ignored) { } } //most likely configuration file is being written by IDE so we'll wait a little try { //noinspection BusyWait Thread.sleep(300); } catch (InterruptedException ignored) { return null; } } } | tryLoadRootElement |
84 | JpsPathVariablesConfiguration (JpsGlobal global) { return global.getContainer().getChild(JpsGlobalLoader.PATH_VARIABLES_ROLE); } | getPathVariablesConfiguration |
85 | JpsPathVariablesConfiguration (JpsGlobal global) { JpsPathVariablesConfiguration child = global.getContainer().getChild(JpsGlobalLoader.PATH_VARIABLES_ROLE); if (child == null) { return global.getContainer().setChild(JpsGlobalLoader.PATH_VARIABLES_ROLE, new JpsPathVariablesConfigurationImpl()); } return child; } | getOrCreatePathVariablesConfiguration |
86 | JpsProjectSerializationDataExtension (@NotNull JpsProject project) { return project.getContainer().getChild(JpsProjectSerializationDataExtensionImpl.ROLE); } | getProjectExtension |
87 | File (@NotNull JpsProject project) { JpsProjectSerializationDataExtension extension = getProjectExtension(project); return extension != null ? extension.getBaseDirectory() : null; } | getBaseDirectory |
88 | JpsModuleSerializationDataExtension (@NotNull JpsModule project) { return project.getContainer().getChild(JpsModuleSerializationDataExtensionImpl.ROLE); } | getModuleExtension |
89 | File (@NotNull JpsModule module) { JpsModuleSerializationDataExtension extension = getModuleExtension(module); return extension != null ? extension.getBaseDirectory() : null; } | getBaseDirectory |
90 | String (@NotNull JpsGlobal global, @NotNull String name) { String value = PathMacroUtil.getGlobalSystemMacroValue(name, false); if (value != null) { return value; } JpsPathVariablesConfiguration configuration = getPathVariablesConfiguration(global); return configuration != null ? configuration.getUserVariableValue(name) : null; } | getPathVariableValue |
91 | File () { return myFile; } | getFile |
92 | void (JpsModule module, @Nullable Element facetManagerElement) { if (facetManagerElement == null) return; FacetManagerState state = XmlSerializer.deserialize(facetManagerElement, FacetManagerState.class); addFacets(module, state.facets, null); } | loadFacets |
93 | void (JpsModule module, List<FacetState> facets, @Nullable final JpsElement parentFacet) { for (FacetState facetState : facets) { final JpsFacetConfigurationSerializer<?> serializer = getModuleExtensionSerializer(facetState.getFacetType()); if (serializer != null) { final JpsElement element = addExtension(module, serializer, facetState, parentFacet); addFacets(module, facetState.subFacets, element); } } } | addFacets |
94 | JpsModuleReference (String facetId) { String moduleName = facetId.substring(0, facetId.indexOf('/')); return JpsElementFactory.getInstance().createModuleReference(moduleName); } | createModuleReference |
95 | String (final JpsModuleReference moduleReference, final String facetTypeId, final String facetName) { return moduleReference.getModuleName() + "/" + facetTypeId + "/" + facetName; } | getFacetId |
96 | String () { return myFacetType; } | getFacetType |
97 | String () { return myName; } | getName |
98 | String () { return myExternalSystemId; } | getExternalSystemId |
99 | String () { return myExternalSystemIdInInternalStorage; } | getExternalSystemIdInInternalStorage |