Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
20,200
boolean () { return false; }
identifier
20,201
List<String> (String parameterName) { String singularName = StringUtil.unpluralize(parameterName); if (singularName == null) singularName = parameterName; List<String> result = new ArrayList<>(); String[] parts = NameUtil.splitNameIntoWords(singularName); for (int i = 0; i < parts.length; i++) { result.add(StringUtil.decapitalize(StringUtil.join(parts, i, parts.length, ""))); } return result; }
collectPossibleNameForCollectionParameter
20,202
boolean (MavenDomParameter parameter) { String type = parameter.getType().getStringValue(); if (type == null) return false; return type.endsWith("[]") || COLLECTIONS_TYPE_NAMES.contains(type); }
isCollection
20,203
MavenDomMojo () { return (MavenDomMojo)parameter.getParent().getParent(); }
getMojo
20,204
int () { if (!Boolean.parseBoolean(parameter.getRequired().getStringValue())) return 0; if (!StringUtil.isEmptyOrSpaces(defaultValue) || !StringUtil.isEmptyOrSpaces(expression)) { return 1; } return 2; }
getRequiringLevel
20,205
XmlElementDescriptor (XmlTag tag) { DomElement domElement = DomManagerImpl.getDomManager(tag.getProject()).getDomElement(tag); if (domElement == null) { PsiElement configuration = PsiTreeUtil.findFirstParent(tag, element -> element instanceof XmlTag && "configuration".equals(((XmlTag)element).getName())); if (configuration instanceof XmlTag) { DomElement configurationElement = DomManagerImpl.getDomManager(tag.getProject()).getDomElement((XmlTag)configuration); if (configurationElement instanceof MavenDomConfiguration && configurationElement.getGenericInfo().getFixedChildrenDescriptions().isEmpty()) { return new AnyXmlElementDescriptor(null, null); } } } return MavenDomElementDescriptorHolder.getInstance(tag.getProject()).getDescriptor(tag); }
getDescriptor
20,206
DependencyConflictId (@NotNull MavenDomDependency dep) { String groupId = dep.getGroupId().getStringValue(); if (StringUtil.isEmpty(groupId)) return null; String artifactId = dep.getArtifactId().getStringValue(); if (StringUtil.isEmpty(artifactId)) return null; return new DependencyConflictId(groupId, artifactId, dep.getType().getStringValue(), dep.getClassifier().getStringValue()); }
create
20,207
DependencyConflictId (@NotNull MavenArtifact dep) { return create(dep.getGroupId(), dep.getArtifactId(), dep.getType(), dep.getClassifier()); }
create
20,208
DependencyConflictId (String groupId, String artifactId, String type, String classifier) { if (StringUtil.isEmpty(groupId)) return null; if (StringUtil.isEmpty(artifactId)) return null; return new DependencyConflictId(groupId, artifactId, type, classifier); }
create
20,209
String () { return groupId; }
getGroupId
20,210
String () { return artifactId; }
getArtifactId
20,211
String () { return type; }
getType
20,212
String () { return classifier; }
getClassifier
20,213
boolean (Object o) { if (this == o) return true; if (!(o instanceof DependencyConflictId id)) return false; if (!artifactId.equals(id.artifactId)) return false; if (classifier != null ? !classifier.equals(id.classifier) : id.classifier != null) return false; if (!groupId.equals(id.groupId)) return false; if (!type.equals(id.type)) return false; return true; }
equals
20,214
int () { int result = groupId.hashCode(); result = 31 * result + artifactId.hashCode(); result = 31 * result + type.hashCode(); result = 31 * result + (classifier != null ? classifier.hashCode() : 0); return result; }
hashCode
20,215
void (ResourceRegistrar registrar) { Map.of( MAVEN_PROJECT_SCHEMA_URL, "/schemas/maven-4.0.0.xsd", "http://maven.apache.org/maven-v4_0_0.xsd", "/schemas/maven-4.0.0.xsd", MAVEN_PROFILES_SCHEMA_URL, "/schemas/profiles-1.0.0.xsd", MAVEN_SETTINGS_SCHEMA_URL, "/schemas/settings-1.0.0.xsd", MAVEN_SETTINGS_SCHEMA_URL_1_1, "/schemas/settings-1.1.0.xsd", MAVEN_SETTINGS_SCHEMA_URL_1_2, "/schemas/settings-1.2.0.xsd" ).forEach((schemaUrl, schemaPath) -> addStdResource(registrar, schemaUrl, schemaPath)); }
registerResources
20,216
void (ResourceRegistrar registrar, String schemaUrl, String schemaPath) { registrar.addStdResource(schemaUrl, schemaPath, getClass()); if (schemaUrl.startsWith("http://")) { String schemaUrlHttps = schemaUrl.replace("http://", "https://"); registrar.addStdResource(schemaUrlHttps, schemaPath, getClass()); } }
addStdResource
20,217
VirtualFile (@NotNull String url) { String location = ((ExternalResourceManagerEx)ExternalResourceManager.getInstance()).getStdResource(url, null); assert location != null : "cannot find a standard resource for " + url; VirtualFile result = VfsUtilCore.findRelativeFile(location, null); assert result != null : "cannot find a schema file for URL: " + url + " location: " + location; return result; }
getSchemaFile
20,218
int () { return INTEGER_ITEM; }
getType
20,219
boolean () { return BigInteger_ZERO.equals(value); }
isNull
20,220
int (Item item) { if (item == null) { return BigInteger_ZERO.equals(value) ? 0 : 1; // 1.0 == 1, 1.1 > 1 } return switch (item.getType()) { case INTEGER_ITEM -> value.compareTo(((IntegerItem)item).value); case STRING_ITEM -> 1; // 1.1 > 1-sp case LIST_ITEM -> 1; // 1.1 > 1-1 default -> throw new RuntimeException("invalid item: " + item.getClass()); }; }
compareTo
20,221
String () { return value.toString(); }
toString
20,222
int () { return STRING_ITEM; }
getType
20,223
boolean () { return (comparableQualifier(value).compareTo(RELEASE_VERSION_INDEX) == 0); }
isNull
20,224
String (String qualifier) { int i = _QUALIFIERS.indexOf(qualifier); return i == -1 ? _QUALIFIERS.size() + "-" + qualifier : String.valueOf(i); }
comparableQualifier
20,225
int (Item item) { if (item == null) { // 1-rc < 1, 1-ga > 1 return comparableQualifier(value).compareTo(RELEASE_VERSION_INDEX); } return switch (item.getType()) { case INTEGER_ITEM -> -1; // 1.any < 1.1 ? case STRING_ITEM -> comparableQualifier(value).compareTo(comparableQualifier(((StringItem)item).value)); case LIST_ITEM -> -1; // 1.any < 1-1 default -> throw new RuntimeException("invalid item: " + item.getClass()); }; }
compareTo
20,226
String () { return value; }
toString
20,227
int () { return LIST_ITEM; }
getType
20,228
boolean () { return (size() == 0); }
isNull
20,229
int (Item item) { if (item == null) { if (size() == 0) { return 0; // 1-0 = 1- (normalize) = 1 } Item first = get(0); return first.compareTo(null); } return switch (item.getType()) { case INTEGER_ITEM -> -1; // 1-1 < 1.0.x case STRING_ITEM -> 1; // 1-1 > 1-sp case LIST_ITEM -> { Iterator<Item> left = iterator(); Iterator<Item> right = ((ListItem)item).iterator(); while (left.hasNext() || right.hasNext()) { Item l = left.hasNext() ? left.next() : null; Item r = right.hasNext() ? right.next() : null; // if this is shorter, then invert the compare and mul with -1 int result = l == null ? -1 * r.compareTo(l) : l.compareTo(r); if (result != 0) { yield result; } } yield 0; } default -> throw new RuntimeException("invalid item: " + item.getClass()); }; }
compareTo
20,230
String () { StringBuilder buffer = new StringBuilder("("); for (Iterator<Item> iter = iterator(); iter.hasNext(); ) { buffer.append(iter.next()); if (iter.hasNext()) { buffer.append(','); } } buffer.append(')'); return buffer.toString(); }
toString
20,231
void (String version) { this.value = version; items = new ListItem(); version = StringUtil.toLowerCase(version); ListItem list = items; Stack<Item> stack = new Stack<>(); stack.push(list); boolean isDigit = false; int startIndex = 0; for (int i = 0; i < version.length(); i++) { char c = version.charAt(i); if (c == '.') { if (i == startIndex) { list.add(IntegerItem.ZERO); } else { list.add(parseItem(isDigit, version.substring(startIndex, i))); } startIndex = i + 1; } else if (c == '-') { if (i == startIndex) { list.add(IntegerItem.ZERO); } else { list.add(parseItem(isDigit, version.substring(startIndex, i))); } startIndex = i + 1; if (isDigit) { list.normalize(); // 1.0-* = 1-* if ((i + 1 < version.length()) && Character.isDigit(version.charAt(i + 1))) { // new ListItem only if previous were digits and new char is a digit, // ie need to differentiate only 1.1 from 1-1 list.add(list = new ListItem()); stack.push(list); } } } else if (Character.isDigit(c)) { if (!isDigit && i > startIndex) { list.add(new StringItem(version.substring(startIndex, i), true)); startIndex = i; } isDigit = true; } else { if (isDigit && i > startIndex) { list.add(parseItem(true, version.substring(startIndex, i))); startIndex = i; } isDigit = false; } } if (version.length() > startIndex) { list.add(parseItem(isDigit, version.substring(startIndex))); } while (!stack.isEmpty()) { list = (ListItem)stack.pop(); list.normalize(); } canonical = items.toString(); }
parseVersion
20,232
Item (boolean isDigit, String buf) { return isDigit ? new IntegerItem(buf) : new StringItem(buf, false); }
parseItem
20,233
int (MavenVersionComparable o) { return items.compareTo(o.items); }
compareTo
20,234
String () { return value; }
toString
20,235
boolean (Object o) { return (o instanceof MavenVersionComparable) && canonical.equals(((MavenVersionComparable)o).canonical); }
equals
20,236
int () { return canonical.hashCode(); }
hashCode
20,237
boolean (PsiFile file) { return isProjectFile(file) || isProfilesFile(file) || isSettingsFile(file); }
isMavenFile
20,238
boolean (PsiFile file) { if (!(file instanceof XmlFile)) return false; XmlTag rootTag = ((XmlFile)file).getRootTag(); if (rootTag == null || !"project".equals(rootTag.getName())) return false; String xmlns = rootTag.getAttributeValue("xmlns"); if (xmlns != null && xmlns.startsWith("http://maven.apache.org/POM/")) { return true; } return MavenUtil.isPomFileName(file.getName()); }
isProjectFile
20,239
boolean (PsiFile file) { if (!(file instanceof XmlFile)) return false; return MavenConstants.PROFILES_XML.equals(file.getName()); }
isProfilesFile
20,240
boolean (PsiFile file) { if (!(file instanceof XmlFile)) return false; XmlTag rootTag = ((XmlFile)file).getRootTag(); if (rootTag == null || !"settings".equals(rootTag.getName())) return false; String xmlns = rootTag.getAttributeValue("xmlns"); if (xmlns != null) { return xmlns.contains("maven"); } boolean hasTag = false; for (PsiElement e = rootTag.getFirstChild(); e != null; e = e.getNextSibling()) { if (e instanceof XmlTag) { if (SUBTAGS_IN_SETTINGS_FILE.contains(((XmlTag)e).getName())) return true; hasTag = true; } } return !hasTag; }
isSettingsFile
20,241
boolean (PsiElement element) { return isMavenFile(element.getContainingFile()); }
isMavenFile
20,242
Module (@NotNull PsiFile psiFile) { VirtualFile file = psiFile.getVirtualFile(); if (file == null) return null; Project project = psiFile.getProject(); MavenProjectsManager manager = MavenProjectsManager.getInstance(project); if (!manager.isMavenizedProject()) return null; ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex(); Module module = index.getModuleForFile(file); if (module == null || !manager.isMavenizedModule(module)) return null; return module; }
findContainingMavenizedModule
20,243
boolean (PsiElement target) { XmlTag tag = PsiTreeUtil.getParentOfType(target, XmlTag.class, false); if (tag == null) return false; return DomUtil.findDomElement(tag, MavenDomProperties.class) != null; }
isMavenProperty
20,244
String (VirtualFile parent, VirtualFile child) { String result = FileUtil.getRelativePath(parent.getPath(), child.getPath(), '/'); if (result == null) { MavenLog.LOG.warn("cannot calculate relative path for\nparent: " + parent + "\nchild: " + child); result = child.getPath(); } return FileUtil.toSystemIndependentName(result); }
calcRelativePath
20,245
MavenDomParent (MavenDomProjectModel mavenModel, MavenProject parentProject) { MavenDomParent result = mavenModel.getMavenParent(); VirtualFile pomFile = DomUtil.getFile(mavenModel).getVirtualFile(); Project project = mavenModel.getManager().getProject(); MavenId parentId = parentProject.getMavenId(); result.getGroupId().setStringValue(parentId.getGroupId()); result.getArtifactId().setStringValue(parentId.getArtifactId()); result.getVersion().setStringValue(parentId.getVersion()); if (!Comparing.equal(pomFile.getParent().getParent(), parentProject.getDirectoryFile()) || !FileUtil.namesEqual(MavenConstants.POM_XML, parentProject.getFile().getName())) { result.getRelativePath().setValue(PsiManager.getInstance(project).findFile(parentProject.getFile())); } return result; }
updateMavenParent
20,246
VirtualFile (@NotNull DomElement element) { PsiFile psiFile = DomUtil.getFile(element); return getVirtualFile(psiFile); }
getVirtualFile
20,247
VirtualFile (@NotNull PsiElement element) { PsiFile psiFile = element.getContainingFile(); return getVirtualFile(psiFile); }
getVirtualFile
20,248
VirtualFile (PsiFile psiFile) { if (psiFile == null) return null; psiFile = psiFile.getOriginalFile(); VirtualFile virtualFile = psiFile.getVirtualFile(); if (virtualFile instanceof LightVirtualFile) { virtualFile = ObjectUtils.chooseNotNull(psiFile.getUserData(MavenGroovyPomCompletionContributor.ORIGINAL_POM_FILE), virtualFile); } return virtualFile; }
getVirtualFile
20,249
MavenProject (@NotNull MavenDomProjectModel projectDom) { XmlElement element = projectDom.getXmlElement(); if (element == null) return null; VirtualFile file = getVirtualFile(element); if (file == null) return null; MavenProjectsManager manager = MavenProjectsManager.getInstance(element.getProject()); return manager.findProject(file); }
findProject
20,250
MavenProject (@NotNull DomElement element) { PsiElement psi = element.getXmlElement(); return psi == null ? null : findContainingProject(psi); }
findContainingProject
20,251
MavenProject (@NotNull PsiElement element) { VirtualFile file = getVirtualFile(element); if (file == null) return null; MavenProjectsManager manager = MavenProjectsManager.getInstance(element.getProject()); return manager.findContainingProject(file); }
findContainingProject
20,252
MavenDomProjectModel (@NotNull Project project, @NotNull VirtualFile file) { return getMavenDomModel(project, file, MavenDomProjectModel.class); }
getMavenDomProjectModel
20,253
MavenDomProfiles (@NotNull Project project, @NotNull VirtualFile file) { MavenDomProfilesModel model = getMavenDomModel(project, file, MavenDomProfilesModel.class); if (model != null) return model.getProfiles(); return getMavenDomModel(project, file, MavenDomProfiles.class); // try old-style model }
getMavenDomProfilesModel
20,254
XmlTag (@NotNull DomElement domElement, @NotNull String path) { List<String> elements = StringUtil.split(path, "."); if (elements.isEmpty()) return null; Pair<String, Integer> nameAndIndex = translateTagName(elements.get(0)); String name = nameAndIndex.first; Integer index = nameAndIndex.second; XmlTag result = domElement.getXmlTag(); if (result == null || !name.equals(result.getName())) return null; result = getIndexedTag(result, index); for (String each : elements.subList(1, elements.size())) { nameAndIndex = translateTagName(each); name = nameAndIndex.first; index = nameAndIndex.second; result = result.findFirstSubTag(name); if (result == null) return null; result = getIndexedTag(result, index); } return result; }
findTag
20,255
XmlTag (XmlTag parent, Integer index) { if (index == null) return parent; XmlTag[] children = parent.getSubTags(); if (index < 0 || index >= children.length) return null; return children[index]; }
getIndexedTag
20,256
PropertiesFile (@NotNull Project project, @NotNull VirtualFile file) { PsiFile psiFile = PsiManager.getInstance(project).findFile(file); if (!(psiFile instanceof PropertiesFile)) return null; return (PropertiesFile)psiFile; }
getPropertiesFile
20,257
IProperty (@NotNull Project project, @NotNull VirtualFile file, @NotNull String propName) { PropertiesFile propertiesFile = getPropertiesFile(project, file); return propertiesFile == null ? null : propertiesFile.findPropertyByKey(propName); }
findProperty
20,258
PsiElement (@NotNull Project project, @NotNull VirtualFile file, @NotNull String propName) { IProperty prop = findProperty(project, file, propName); return prop == null ? null : prop.getPsiElement().getFirstChild().getNextSibling().getNextSibling(); }
findPropertyValue
20,259
Set<VirtualFile> (@NotNull MavenProject mavenProject) { Pair<Long, Set<VirtualFile>> cachedValue = mavenProject.getCachedValue(FILTERED_RESOURCES_ROOTS_KEY); if (cachedValue == null || cachedValue.first != VirtualFileManager.getInstance().getModificationCount()) { Set<VirtualFile> set = null; for (MavenResource resource : ContainerUtil.concat(mavenProject.getResources(), mavenProject.getTestResources())) { if (!resource.isFiltered()) continue; String resourceDirectory = resource.getDirectory(); VirtualFile resourceDir = LocalFileSystem.getInstance().findFileByPath(resourceDirectory); if (resourceDir == null) continue; if (set == null) { set = new HashSet<>(); } set.add(resourceDir); } if (set == null) { set = Collections.emptySet(); } cachedValue = Pair.create(VirtualFileManager.getInstance().getModificationCount(), set); mavenProject.putCachedValue(FILTERED_RESOURCES_ROOTS_KEY, cachedValue); } return cachedValue.second; }
getFilteredResourcesRoots
20,260
boolean (PsiElement element) { PsiFile psiFile = element.getContainingFile(); VirtualFile file = getVirtualFile(psiFile); if (file == null) return false; MavenProjectsManager manager = MavenProjectsManager.getInstance(psiFile.getProject()); MavenProject mavenProject = manager.findContainingProject(file); if (mavenProject == null) return false; Set<VirtualFile> filteredRoots = getFilteredResourcesRoots(mavenProject); if (!filteredRoots.isEmpty()) { for (VirtualFile f = file.getParent(); f != null; f = f.getParent()) { if (filteredRoots.contains(f)) { return true; } } } return false; }
isFilteredResourceFile
20,261
List<DomFileElement<MavenDomProjectModel>> (Project p) { return DomService.getInstance().getFileElements(MavenDomProjectModel.class, p, GlobalSearchScope.projectScope(p)); }
collectProjectModels
20,262
MavenId (PsiFile psiFile) { MavenDomProjectModel model = getMavenDomModel(psiFile, MavenDomProjectModel.class); if (model == null) { return new MavenId(null, null, null); } String groupId = model.getGroupId().getStringValue(); String artifactId = model.getArtifactId().getStringValue(); String version = model.getVersion().getStringValue(); if (groupId == null) { groupId = model.getMavenParent().getGroupId().getStringValue(); } if (version == null) { version = model.getMavenParent().getVersion().getStringValue(); } return new MavenId(groupId, artifactId, version); }
describe
20,263
MavenDomDependency (MavenDomProjectModel model, @Nullable Editor editor, @NotNull final MavenId id) { return createDomDependency(model.getDependencies(), editor, id); }
createDomDependency
20,264
MavenDomDependency (MavenDomDependencies dependencies, @Nullable Editor editor, @NotNull final MavenCoordinate id) { MavenDomDependency dep = createDomDependency(dependencies, editor); dep.getGroupId().setStringValue(id.getGroupId()); dep.getArtifactId().setStringValue(id.getArtifactId()); dep.getVersion().setStringValue(id.getVersion()); return dep; }
createDomDependency
20,265
MavenDomDependency (@NotNull MavenDomProjectModel model, @Nullable Editor editor) { return createDomDependency(model.getDependencies(), editor); }
createDomDependency
20,266
MavenDomDependency (@NotNull MavenDomDependencies dependencies, @Nullable Editor editor) { int index = getCollectionIndex(dependencies, editor); if (index >= 0) { DomCollectionChildDescription childDescription = dependencies.getGenericInfo().getCollectionChildDescription("dependency"); if (childDescription != null) { DomElement element = childDescription.addValue(dependencies, index); if (element instanceof MavenDomDependency) { return (MavenDomDependency)element; } } } return dependencies.addDependency(); }
createDomDependency
20,267
int (@NotNull final MavenDomDependencies dependencies, @Nullable final Editor editor) { if (editor != null) { int offset = editor.getCaretModel().getOffset(); List<MavenDomDependency> dependencyList = dependencies.getDependencies(); for (int i = 0; i < dependencyList.size(); i++) { MavenDomDependency dependency = dependencyList.get(i); XmlElement xmlElement = dependency.getXmlElement(); if (xmlElement != null && xmlElement.getTextRange().getStartOffset() >= offset) { return i; } } } return -1; }
getCollectionIndex
20,268
String (MavenDomProjectModel model) { MavenProject mavenProject = findProject(model); if (mavenProject != null) { return mavenProject.getDisplayName(); } else { String name = model.getName().getStringValue(); if (!StringUtil.isEmptyOrSpaces(name)) { return name; } else { return "pom.xml"; // ? } } }
getProjectName
20,269
String (@Nullable VirtualFile file, @NotNull Project project) { VirtualFile directory = file == null ? null : file.getParent(); MavenDistribution distribution; if (directory == null) { distribution = MavenDistributionsCache.getInstance(project).getSettingsDistribution(); } else { distribution = MavenDistributionsCache.getInstance(project).getMavenDistribution(directory.getPath()); } return distribution.getVersion(); }
getMavenVersion
20,270
boolean (PsiFile file) { return file instanceof XmlFile && MavenDomUtil.isMavenFile(file); }
isAvailable
20,271
XmlElementDescriptor (XmlTag tag, XmlTag contextTag, XmlElementDescriptor parentDescriptor) { DomElement domElement = DomManagerImpl.getDomManager(tag.getProject()).getDomElement(contextTag); if (domElement != null) { MavenDomConfiguration configuration = DomUtil.getParentOfType(domElement, MavenDomConfiguration.class, false); if (configuration != null && configuration.getGenericInfo().getFixedChildrenDescriptions().isEmpty()) { return new AnyXmlElementDescriptor(null, null); } } return super.getElementDescriptor(tag, contextTag, parentDescriptor); }
getElementDescriptor
20,272
void () { super.initializeFileDescription(); registerReferenceInjector(new MavenPropertyPsiReferenceInjector()); }
initializeFileDescription
20,273
MavenProject (@NotNull DomElement domElement) { XmlElement xmlElement = domElement.getXmlElement(); if (xmlElement == null) return null; PsiFile psiFile = xmlElement.getContainingFile(); if (psiFile == null) return null; VirtualFile file = psiFile.getVirtualFile(); if (file == null) return null; return MavenProjectsManager.getInstance(psiFile.getProject()).findProject(file); }
findMavenProject
20,274
MavenDomPluginModel (DomElement element) { Project project = element.getManager().getProject(); MavenDomPlugin pluginElement = element.getParentOfType(MavenDomPlugin.class, false); if (pluginElement == null) return null; String groupId = pluginElement.getGroupId().getStringValue(); String artifactId = pluginElement.getArtifactId().getStringValue(); String version = pluginElement.getVersion().getStringValue(); if (StringUtil.isEmpty(version)) { MavenProject mavenProject = findMavenProject(element); if (mavenProject != null) { for (MavenPlugin plugin : mavenProject.getPlugins()) { if (MavenArtifactUtil.isPluginIdEquals(groupId, artifactId, plugin.getGroupId(), plugin.getArtifactId())) { MavenId pluginMavenId = plugin.getMavenId(); version = pluginMavenId.getVersion(); break; } } } } return getMavenPluginModel(project, groupId, artifactId, version); }
getMavenPluginModel
20,275
MavenDomPluginModel (Project project, String groupId, String artifactId, String version) { VirtualFile pluginXmlFile = getPluginXmlFile(project, groupId, artifactId, version); if (pluginXmlFile == null) return null; return MavenDomUtil.getMavenDomModel(project, pluginXmlFile, MavenDomPluginModel.class); }
getMavenPluginModel
20,276
boolean (@NotNull MavenDomConfiguration configuration, @Nullable String groupId, @NotNull String artifactId) { MavenDomPlugin domPlugin = configuration.getParentOfType(MavenDomPlugin.class, true); if (domPlugin == null) return false; return isPlugin(domPlugin, groupId, artifactId); }
isPlugin
20,277
boolean (@NotNull MavenDomPlugin plugin, @Nullable String groupId, @NotNull String artifactId) { if (!artifactId.equals(plugin.getArtifactId().getStringValue())) return false; String pluginGroupId = plugin.getGroupId().getStringValue(); if (groupId == null) { return pluginGroupId == null || (pluginGroupId.equals("org.apache.maven.plugins") || pluginGroupId.equals("org.codehaus.mojo")); } if (pluginGroupId == null && (groupId.equals("org.apache.maven.plugins") || groupId.equals("org.codehaus.mojo"))) { return true; } return groupId.equals(pluginGroupId); }
isPlugin
20,278
VirtualFile (Project project, String groupId, String artifactId, String version) { Path file = MavenArtifactUtil.getArtifactNioPath(MavenProjectsManager.getInstance(project).getLocalRepository(), groupId, artifactId, version, "jar"); VirtualFile pluginFile = LocalFileSystem.getInstance().findFileByNioFile(file); if (pluginFile == null) return null; VirtualFile pluginJarRoot = JarFileSystem.getInstance().getJarRootForLocalFile(pluginFile); if (pluginJarRoot == null) return null; return pluginJarRoot.findFileByRelativePath(MavenArtifactUtil.MAVEN_PLUGIN_DESCRIPTOR); }
getPluginXmlFile
20,279
List<String> (PsiElement element, PsiElement originalElement) { element = getMavenElement(element); if (element == null) return null; if (MavenDomUtil.isMavenProperty(element)) return Collections.emptyList(); // todo hard-coded maven version // todo add auto-opening the element's doc //String name = ((PsiNamedElement)element).getName(); return Collections.singletonList("http://maven.apache.org/ref/2.2.1/maven-model/maven.html"); }
getUrlFor
20,280
String (PsiElement e, DescKind kind, boolean html) { e = getMavenElement(e); if (e == null) return null; if (e instanceof FakePsiElement) { return ((FakePsiElement)e).getPresentableText(); } boolean property = MavenDomUtil.isMavenProperty(e); String type = property ? MavenDomBundle.message("text.property") : MavenDomBundle.message("text.model.property"); if (kind == DescKind.TYPE) return type; String name = buildPropertyName(e, property); if (kind == DescKind.NAME) return name; if (kind == DescKind.TYPE_NAME_VALUE) { String br = html ? "<br>" : "\n "; String[] bold = html ? new String[]{"<b>", "</b>"} : new String[]{"", ""}; String valueSuffix = ""; if (e instanceof XmlTag) { valueSuffix = ": " + bold[0] + ((XmlTag)e).getValue().getTrimmedText() + bold[1]; } return type + br + name + valueSuffix; } MavenLog.LOG.error("unexpected desc kind: " + kind); return null; }
getMavenElementDescription
20,281
String (PsiElement e, boolean property) { if (property) return DescriptiveNameUtil.getDescriptiveName(e); //NON-NLS - suprress warning List<String> path = new ArrayList<>(); do { path.add(DescriptiveNameUtil.getDescriptiveName(e)); } while ((e = PsiTreeUtil.getParentOfType(e, XmlTag.class)) != null); Collections.reverse(path); return StringUtil.join(path, "."); }
buildPropertyName
20,282
PsiElement (PsiElement e) { if (e instanceof MavenPsiElementWrapper) e = ((MavenPsiElementWrapper)e).getWrappee(); if (!MavenDomUtil.isMavenFile(e)) return null; if (e instanceof PsiFile) return null; return e; }
getMavenElement
20,283
void (@NotNull MavenDomConfigurationParameter param, @NotNull DomExtensionsRegistrar r) { for (XmlAttribute each : param.getXmlTag().getAttributes()) { String name = each.getName(); if (CompletionUtil.DUMMY_IDENTIFIER_TRIMMED.equals(name)) continue; r.registerGenericAttributeValueChildExtension(new XmlName(name), String.class); } }
registerExtensions
20,284
String () { return MavenSchemaProvider.MAVEN_PROJECT_SCHEMA_URL; }
getSchemaUrl
20,285
String () { return MavenSchemaProvider.MAVEN_PROFILES_SCHEMA_URL; }
getSchemaUrl
20,286
String () { return MavenSchemaProvider.MAVEN_SETTINGS_SCHEMA_URL; }
getSchemaUrl
20,287
String () { return MavenSchemaProvider.MAVEN_SETTINGS_SCHEMA_URL_1_1; }
getSchemaUrl
20,288
String () { return MavenSchemaProvider.MAVEN_SETTINGS_SCHEMA_URL_1_2; }
getSchemaUrl
20,289
MavenDomElementDescriptorHolder (@NotNull Project project) { return project.getService(MavenDomElementDescriptorHolder.class); }
getInstance
20,290
XmlElementDescriptor (@NotNull XmlTag tag) { FileKind kind = getFileKind(tag.getContainingFile()); if (kind == null) return null; XmlNSDescriptorImpl desc; synchronized (this) { desc = tryGetOrCreateDescriptor(kind); if (desc == null) return null; } LOG.assertTrue(tag.isValid()); LOG.assertTrue(desc.isValid()); return desc.getElementDescriptor(tag.getName(), desc.getDefaultNamespace()); }
getDescriptor
20,291
XmlNSDescriptorImpl (final FileKind kind) { CachedValue<XmlNSDescriptorImpl> result = myDescriptorsMap.get(kind); if (result == null) { result = CachedValuesManager.getManager(myProject).createCachedValue( () -> CachedValueProvider.Result.create(doCreateDescriptor(kind), PsiModificationTracker.MODIFICATION_COUNT), false); myDescriptorsMap.put(kind, result); } return result.getValue(); }
tryGetOrCreateDescriptor
20,292
XmlNSDescriptorImpl (FileKind kind) { String schemaUrl = kind.getSchemaUrl(); String location = ExternalResourceManager.getInstance().getResourceLocation(schemaUrl); if (schemaUrl.equals(location)) return null; VirtualFile schema; try { schema = VfsUtil.findFileByURL(new URL(location)); } catch (MalformedURLException ignore) { return null; } if (schema == null) return null; PsiFile psiFile = PsiManager.getInstance(myProject).findFile(schema); if (!(psiFile instanceof XmlFile)) return null; XmlNSDescriptorImpl result = new XmlNSDescriptorImpl(); result.init(psiFile); return result; }
doCreateDescriptor
20,293
FileKind (PsiFile file) { if (MavenDomUtil.isProjectFile(file)) return FileKind.PROJECT_FILE; if (MavenDomUtil.isProfilesFile(file)) return FileKind.PROFILES_FILE; if (MavenDomUtil.isSettingsFile(file)) return getSettingsFileKind(file); return null; }
getFileKind
20,294
FileKind (PsiFile file) { String nameSpace = MavenDomUtil.getXmlSettingsNameSpace(file); if (nameSpace == null) return FileKind.SETTINGS_FILE; if (nameSpace.contains("1.1.0")) return FileKind.SETTINGS_FILE_1_1; if (nameSpace.contains("1.2.0")) return FileKind.SETTINGS_FILE_1_2; return FileKind.SETTINGS_FILE; }
getSettingsFileKind
20,295
boolean (@NotNull XmlFile file, final Module module) { return MavenDomUtil.isMavenFile(file) && super.isMyFile(file, module); }
isMyFile
20,296
DomElementsAnnotator () { return new MavenDomAnnotator(); }
createAnnotator
20,297
boolean (@NotNull XmlFile file, @Nullable Module module) { XmlTag rootTag = file.getRootTag(); assert rootTag != null; // rootTag.getName() == "plugin" return rootTag.findFirstSubTag("mojos") != null && rootTag.findFirstSubTag("artifactId") != null; }
isMyFile
20,298
String (String text, MavenDomProjectModel projectDom) { XmlElement element = projectDom.getXmlElement(); if (element == null) return text; VirtualFile file = MavenDomUtil.getVirtualFile(element); if (file == null) return text; MavenProjectsManager mavenProjectsManager = MavenProjectsManager.getInstance(projectDom.getManager().getProject()); MavenProject mavenProject = mavenProjectsManager.findProject(file); var additionalPropertySource = new AdditionalPropertySourceImpl(mavenProject, projectDom); return new MavenPropertyResolverHelper(projectDom, mavenProjectsManager, mavenProject, additionalPropertySource) .filterText(text); }
resolve
20,299
Properties (@Nullable MavenProject project, MavenDomProjectModel projectDom) { var result = new Properties(); result.putAll(collectPropertyMapFromDOM(project, projectDom)); return result; }
collectPropertiesFromDOM