Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
5,400
void () { }
dispose
5,401
AntDisposable () { return ApplicationManager.getApplication().getService(AntDisposable.class); }
getInstance
5,402
AntDisposable (Project project) { return project.getService(AntDisposable.class); }
getInstance
5,403
ReflectedProject (final ClassLoader classLoader) { ourProjectsLock.lock(); try { for (Iterator<SoftReference<Pair<ReflectedProject, ClassLoader>>> iterator = ourProjects.iterator(); iterator.hasNext();) { final SoftReference<Pair<ReflectedProject, ClassLoader>> ref = iterator.next(); final Pair<ReflectedProject, ClassLoader> pair = ref.get(); if (pair == null) { iterator.remove(); } else { if (pair.second == classLoader) { return pair.first; } } } } finally { ourProjectsLock.unlock(); } final ReflectedProject reflectedProj = new ReflectedProject(classLoader); ourProjectsLock.lock(); try { ourProjects.add(new SoftReference<>( Pair.create(reflectedProj, classLoader) )); } finally { ourProjectsLock.unlock(); } return reflectedProj; }
getProject
5,404
Object () { return myProject; }
getProject
5,405
Iterator<String> () { final String prefix = getPropertyPrefixValue(); final Iterator<String> delegate = buildProperties().keySet().iterator(); if (prefix == null) { return delegate; } return new Iterator<>() { @Override public boolean hasNext() { return delegate.hasNext(); } @Override public String next() { return prefix + delegate.next(); } @Override public void remove() { delegate.remove(); } }; }
getNamesIterator
5,406
boolean () { return delegate.hasNext(); }
hasNext
5,407
String () { return prefix + delegate.next(); }
next
5,408
void () { delegate.remove(); }
remove
5,409
PsiElement (final String propertyName) { DomTarget domTarget = DomTarget.getTarget(this); if (domTarget == null) { final GenericAttributeValue<String> environment = getEnvironment(); if (environment.getRawText() != null) { domTarget = DomTarget.getTarget(this, environment); } if (domTarget == null) { final GenericAttributeValue<String> resource = getResource(); if (resource.getRawText() != null) { domTarget = DomTarget.getTarget(this, resource); } } } if (domTarget != null) { return PomService.convertToPsi(domTarget); } final PsiFileSystemItem psiFile = getFile().getValue(); if (psiFile != null) { final String prefix = getPropertyPrefixValue(); String _propertyName = propertyName; if (prefix != null) { if (!propertyName.startsWith(prefix)) { return null; } _propertyName = propertyName.substring(prefix.length()); } final PropertiesFile pf = toPropertiesFile(psiFile); if (pf != null) { final IProperty property = pf.findPropertyByKey(_propertyName); return property != null? property.getPsiElement() : null; } } return null; }
getNavigationElement
5,410
String (String propertyName) { final String prefix = getPropertyPrefixValue(); if (prefix != null) { if (!propertyName.startsWith(prefix)) { return null; } propertyName = propertyName.substring(prefix.length()); } return buildProperties().get(propertyName); }
getPropertyValue
5,411
String () { final GenericAttributeValue<String> prefixValue = getPrefix(); if (prefixValue == null) { return null; } // prefix is only valid when loading from an url, file or resource final boolean prefixIsApplicable = (getName().getRawText() == null) && (getUrl().getRawText() != null || getFile().getRawText() != null || getResource().getRawText() != null); if (!prefixIsApplicable) { return null; } final String prefix = prefixValue.getRawText(); if (prefix != null && !prefix.endsWith(".")) { return prefix + "."; } return prefix; }
getPropertyPrefixValue
5,412
ClassLoader () { ClassLoader loader = myCachedLoader; if (loader == null) { myCachedLoader = loader = CustomAntElementsRegistry.createClassLoader(CustomAntElementsRegistry.collectUrls(this), getContextAntProject()); } return loader; }
getClassLoader
5,413
PropertiesFile () { return toPropertiesFile(getFile().getValue()); }
getPropertiesFile
5,414
PropertiesFile (@Nullable final PsiFileSystemItem item) { if (item instanceof PropertiesFile) { return (PropertiesFile)item; } // Sometimes XmlPropertiesFile is just XmlFile, sao we should ask PropertiesImplUtil about that. return item instanceof PsiFile? PropertiesImplUtil.getPropertiesFile(((PsiFile)item)) : null; }
toPropertiesFile
5,415
boolean (@NotNull XmlFile file, @Nullable Module module) { return super.isMyFile(file, module) && isAntLibFile(file); }
isMyFile
5,416
boolean (final XmlFile xmlFile) { final XmlDocument document = xmlFile.getDocument(); if (document != null) { final XmlTag tag = document.getRootTag(); return tag != null && ROOT_TAG_NAME.equals(tag.getName()) && tag.getContext() instanceof XmlDocument; } return false; }
isAntLibFile
5,417
List<Pattern> (final boolean caseSensitive) { return Arrays.asList( convertToRegexPattern("**/*~", caseSensitive), convertToRegexPattern("**/#*#", caseSensitive), convertToRegexPattern("**/.#*", caseSensitive), convertToRegexPattern("**/%*%", caseSensitive), convertToRegexPattern("**/._*", caseSensitive), convertToRegexPattern("**/CVS", caseSensitive), convertToRegexPattern("**/CVS/**", caseSensitive), convertToRegexPattern("**/.cvsignore", caseSensitive), convertToRegexPattern("**/SCCS", caseSensitive), convertToRegexPattern("**/SCCS/**", caseSensitive), convertToRegexPattern("**/vssver.scc", caseSensitive), convertToRegexPattern("**/.svn", caseSensitive), convertToRegexPattern("**/.svn/**", caseSensitive), convertToRegexPattern("**/_svn", caseSensitive), convertToRegexPattern("**/_svn/**", caseSensitive), convertToRegexPattern("**/.DS_Store", caseSensitive) ); }
getDefaultExcludes
5,418
boolean () { return myIncludePatterns.size() > 0; }
hasIncludePatterns
5,419
void (AntDomElement element) { // todo: add support to includefile and excludefile if ("include".equals(element.getXmlElementName()) && !(element instanceof AntDomInclude)) { if (isEnabled(element)) { final String value = getAttributeValue(element, "name"); if (value != null) { addIncludePattern(value); } } } else if ("exclude".equals(element.getXmlElementName())) { if (isEnabled(element)) { final String value = getAttributeValue(element, "name"); if (value != null) { addExcludePattern(value); } } } else { // todo: add support to includesfile and excludesfile final String includeAttribs = getAttributeValue(element, "includes"); if (includeAttribs != null) { addPatterns(true, includeAttribs); } final String excludeAttribs = getAttributeValue(element, "excludes"); if (excludeAttribs != null) { addPatterns(false, excludeAttribs); } } final AntDomElement referred = element.getRefId().getValue(); if (referred != null) { referred.accept(this); } super.visitAntDomElement(element); }
visitAntDomElement
5,420
void (final String antPattern) { myExcludePatterns.add(convertToRegexPattern(antPattern, myCaseSensitive)); }
addExcludePattern
5,421
void (final String antPattern) { myIncludePatterns.add(convertToRegexPattern(antPattern, myCaseSensitive)); String normalizedPattern = antPattern.endsWith("/") || antPattern.endsWith(File.separator)? antPattern.replace(File.separatorChar, '/') + "**" : antPattern.replace(File.separatorChar, '/'); if (normalizedPattern.startsWith("/") && normalizedPattern.length() > 1) { // cut first leading slash if any normalizedPattern = normalizedPattern.substring(1); } if (!normalizedPattern.startsWith("/")) { final String[] patDirs = normalizedPattern.split(ourSeparatorPattern); final PrefixItem[] items = new PrefixItem[patDirs.length]; for (int i = 0; i < patDirs.length; i++) { items[i] = new PrefixItem(patDirs[i]); } myCouldBeIncludedPatterns.add(items); } }
addIncludePattern
5,422
boolean (final String relativePath) { final String path = relativePath.replace('\\', '/'); boolean accepted = myIncludePatterns.size() == 0; for (Pattern includePattern : myIncludePatterns) { if (includePattern.matcher(path).matches()) { accepted = true; break; } } if (accepted) { for (Pattern excludePattern : myExcludePatterns) { if (excludePattern.matcher(path).matches()) { accepted = false; break; } } } return accepted; }
acceptPath
5,423
boolean (AntDomElement element) { final String ifProperty = getAttributeValue(element, "if"); if (ifProperty != null && PropertyResolver.resolve(element.getContextAntProject(), ifProperty, element).element() == null) { return false; } final String unlessProperty = getAttributeValue(element, "unless"); if (unlessProperty != null && PropertyResolver.resolve(element.getContextAntProject(), unlessProperty, element).element() != null) { return false; } return true; }
isEnabled
5,424
void (final boolean addToIncludes, final String patternString) { final StringTokenizer tokenizer = new StringTokenizer(patternString, ", \t", false); while (tokenizer.hasMoreTokens()) { final String pattern = tokenizer.nextToken(); if (pattern.length() > 0) { if (addToIncludes) { addIncludePattern(pattern); } else { addExcludePattern(pattern); } } } }
addPatterns
5,425
Pattern (@NonNls final String antPattern, final boolean caseSensitive) { return Pattern.compile(FileUtil.convertAntToRegexp(antPattern), caseSensitive? 0 : Pattern.CASE_INSENSITIVE); }
convertToRegexPattern
5,426
AntDomPattern (AntDomElement element, final boolean honorDefaultExcludes, final boolean caseSensitive) { final AntDomPattern antPattern = new AntDomPattern(caseSensitive); element.accept(antPattern); if (honorDefaultExcludes) { antPattern.myExcludePatterns.addAll(caseSensitive? ourDefaultExcludes : ourCaseInsensitiveDefaultExcludes); } return antPattern; }
create
5,427
boolean (PrefixItem[] patDirs, String str) { final String[] strDirs = str.split(ourSeparatorPattern); int patIdxStart = 0; final int patIdxEnd = patDirs.length-1; int strIdxStart = 0; final int strIdxEnd = strDirs.length-1; // up to first '**' while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) { final AntDomPattern.PrefixItem item = patDirs[patIdxStart]; if ("**".equals(item.getStrPattern())) { break; } if (!item.getPattern().matcher(strDirs[strIdxStart]).matches()) { return false; } patIdxStart++; strIdxStart++; } if (strIdxStart > strIdxEnd) { // String is exhausted return true; } if (patIdxStart > patIdxEnd) { // String not exhausted, but pattern is. Failure. return false; } // pattern now holds ** while string is not exhausted // this will generate false positives but we can live with that. return true; }
matchPatternStart
5,428
boolean (String relativePath) { if (myIncludePatterns.size() == 0) { return true; } return myCouldBeIncludedPatterns.stream().anyMatch(couldBeIncludedPattern -> matchPatternStart(couldBeIncludedPattern, relativePath)); }
couldBeIncluded
5,429
String () { return myStrPattern; }
getStrPattern
5,430
Pattern () { if (myCompiledPattern == null) { myCompiledPattern = Pattern.compile(FileUtil.convertAntToRegexp(myStrPattern), myCaseSensitive ? 0 : Pattern.CASE_INSENSITIVE); } return myCompiledPattern; }
getPattern
5,431
void (AntDomProject startProject, String initialTargetName) { myStage = Stage.RESOLVE_MAP_BUILDING_STAGE; startProject.accept(this); stageCompleted(Stage.RESOLVE_MAP_BUILDING_STAGE, Stage.TARGETS_WALKUP_STAGE); if (!myStopped) { myStage = Stage.TARGETS_WALKUP_STAGE; final AntDomTarget target = initialTargetName != null? getTargetByName(initialTargetName) : null; if (target != null) { processTarget(initialTargetName, target); } List<String> unprocessed = null; for (String s : myTargetsResolveMap.keySet()) { if (!myProcessedTargets.contains(s)) { if (unprocessed == null) { unprocessed = new ArrayList<>(); } unprocessed.add(s); } } if (unprocessed != null) { for (String targetName : unprocessed) { processTarget(targetName, myTargetsResolveMap.get(targetName)); } } } }
execute
5,432
void (String targetEffectiveName, AntDomTarget target) { myCurrentTargetEffectiveName.push(targetEffectiveName); try { target.accept(this); } finally { myCurrentTargetEffectiveName.pop(); } }
processTarget
5,433
void (AntDomTarget target) { if (myStage == Stage.TARGETS_WALKUP_STAGE) { final String targetEffectiveName = myCurrentTargetEffectiveName.peek(); if (myProcessedTargets.add(targetEffectiveName)) { final List<String> depsList = myDependenciesMap.get(targetEffectiveName); if (depsList != null) { for (String dependencyName : depsList) { final AntDomTarget dependency = getTargetByName(dependencyName); if (dependency != null) { processTarget(dependencyName, dependency); } } } super.visitTarget(target); } } else if (myStage == Stage.RESOLVE_MAP_BUILDING_STAGE){ final String declaredTargetName = target.getName().getRawText(); String effectiveTargetName; final InclusionKind inclusionKind = myNameContext.getCurrentInclusionKind(); switch (inclusionKind) { case IMPORT -> { final String alias = myNameContext.getShortPrefix() + declaredTargetName; if (!myTargetsResolveMap.containsKey(declaredTargetName)) { effectiveTargetName = declaredTargetName; myTargetsResolveMap.put(alias, target); } else { effectiveTargetName = alias; } } case INCLUDE -> effectiveTargetName = myNameContext.getFQPrefix() + declaredTargetName; default -> effectiveTargetName = declaredTargetName; } if (effectiveTargetName != null) { final AntDomTarget existingTarget = myTargetsResolveMap.get(effectiveTargetName); if (existingTarget != null && Comparing.equal(existingTarget.getAntProject(), target.getAntProject())) { duplicateTargetFound(existingTarget, target, effectiveTargetName); } else { myTargetsResolveMap.put(effectiveTargetName, target); final String dependsStr = target.getDependsList().getRawText(); Map<String, Pair<AntDomTarget, String>> depsMap = Collections.emptyMap(); if (dependsStr != null) { depsMap = new HashMap<>(); final StringTokenizer tokenizer = new StringTokenizer(dependsStr, ",", false); while (tokenizer.hasMoreTokens()) { final String token = tokenizer.nextToken().trim(); final String dependentTargetEffectiveName = myNameContext.calcTargetReferenceText(token); final AntDomTarget dependent = getTargetByName(dependentTargetEffectiveName); if (dependent != null) { depsMap.put(token, Pair.create(dependent, dependentTargetEffectiveName)); } addDependency(effectiveTargetName, dependentTargetEffectiveName); } } targetDefined(target, effectiveTargetName, depsMap); } } } }
visitTarget
5,434
void (AntDomElement element) { if (myStopped) { return; } if (element.equals(myContextElement)) { stop(); } else { if (element instanceof PropertiesProvider) { propertyProviderFound(((PropertiesProvider)element)); } } if (!myStopped) { //super.visitAntDomElement(element); for (Iterator<AntDomElement> iterator = element.getAntChildrenIterator(); iterator.hasNext();) { AntDomElement child = iterator.next(); child.accept(this); if (myStage == Stage.TARGETS_WALKUP_STAGE) { if (myStopped) { break; } } } } }
visitAntDomElement
5,435
AntDomTarget (@NonNls String effectiveName) { return myTargetsResolveMap.get(effectiveName); }
getTargetByName
5,436
AntDomElement () { return myContextElement; }
getContextElement
5,437
void () { myStopped = true; }
stop
5,438
void (AntDomInclude includeTag) { processFileInclusion(includeTag, InclusionKind.INCLUDE); }
visitInclude
5,439
void (AntDomImport importTag) { processFileInclusion(importTag, InclusionKind.IMPORT); }
visitImport
5,440
void (AntDomProject project) { if (myVisitedProjects.add(project)) { try { super.visitProject(project); } finally { myVisitedProjects.remove(project); } } }
visitProject
5,441
void (AntDomIncludingDirective directive, final InclusionKind kind) { if (directive.equals(myContextElement)) { stop(); } if (myStopped) { return; } final PsiFileSystemItem item = directive.getFile().getValue(); if (item instanceof PsiFile) { final AntDomProject slaveProject = item instanceof XmlFile ? AntSupport.getAntDomProjectForceAntFile((XmlFile)item) : null; if (slaveProject != null) { myNameContext.pushPrefix(directive, kind, slaveProject); try { slaveProject.accept(this); } finally { myNameContext.popPrefix(); } } } }
processFileInclusion
5,442
void (String effectiveTargetName, String dependentTargetEffectiveName) { List<String> list = myDependenciesMap.get(effectiveTargetName); if (list == null) { myDependenciesMap.put(effectiveTargetName, list = new ArrayList<>()); } list.add(dependentTargetEffectiveName); }
addDependency
5,443
void (AntDomTarget target, String taregetEffectiveName, Map<String, Pair<AntDomTarget, String>> dependenciesMap) { }
targetDefined
5,444
void (AntDomTarget existingTarget, AntDomTarget duplicatingTarget, String taregetEffectiveName) { }
duplicateTargetFound
5,445
void (Stage completedStage, Stage startingStage) { }
stageCompleted
5,446
String () { return myDisplayName; }
toString
5,447
String (String targetReferenceText) { if (!myPrefixes.isEmpty()) { final InclusionKind kind = myPrefixes.getLast().getSecond(); if (kind == InclusionKind.INCLUDE) { return getFQPrefix() + targetReferenceText; } } return targetReferenceText; }
calcTargetReferenceText
5,448
InclusionKind () { if (myPrefixes.isEmpty()) { return InclusionKind.TOPLEVEL; } return myPrefixes.getLast().getSecond(); }
getCurrentInclusionKind
5,449
String () { if (myCurrentPrefix != null) { return myCurrentPrefix; } if (myPrefixes.isEmpty()) { return ""; } StringBuilder buf = new StringBuilder(); for (Pair<String, InclusionKind> prefix : myPrefixes) { buf.append(prefix.getFirst()); } return myCurrentPrefix = buf.toString(); }
getFQPrefix
5,450
String () { return myPrefixes.isEmpty()? "" : myPrefixes.getLast().getFirst(); }
getShortPrefix
5,451
void (AntDomIncludingDirective directive, final InclusionKind kind, final @NotNull AntDomProject slaveProject) { final String separator = directive.getTargetPrefixSeparatorValue(); String prefix = directive.getTargetPrefix().getStringValue(); if (prefix == null) { prefix = slaveProject.getName().getRawText(); if (prefix == null) { prefix = "anonymous" + (myDefaultPrefixCounter++); } } pushPrefix(prefix.endsWith(separator) ? prefix : prefix + separator, kind); }
pushPrefix
5,452
void (String prefix, InclusionKind kind) { myCurrentPrefix = null; myPrefixes.addLast(Pair.create(prefix, kind)); }
pushPrefix
5,453
void () { myCurrentPrefix = null; myPrefixes.removeLast(); }
popPrefix
5,454
List<File> (AntDomPattern pattern, Set<AntFilesProvider> processed) { final List<File> files = super.getFiles(pattern, processed); for (Iterator<AntDomElement> iterator = getAntChildrenIterator(); iterator.hasNext();) { AntDomElement child = iterator.next(); if (child instanceof AntFilesProvider) { files.addAll(((AntFilesProvider)child).getFiles(processed)); } } return files; }
getFiles
5,455
List<File> (Set<AntFilesProvider> processed) { if (processed.contains(this)) { return Collections.emptyList(); } List<File> result = myCachedFiles; if (result == null) { myCachedFiles = result = getFilesImpl(processed); } return result; }
getFiles
5,456
List<File> (final Set<AntFilesProvider> processed) { processed.add(this); try { final AntDomElement referenced = getRefId().getValue(); if (referenced instanceof AntFilesProvider) { return ((AntFilesProvider)referenced).getFiles(processed); } return getFiles(getAntPattern(), processed); } finally { processed.remove(this); } }
getFilesImpl
5,457
AntDomPattern () { return AntDomPattern.create(this, shouldHonorDefaultExcludes(), matchPatternsCaseSensitive()); }
getAntPattern
5,458
List<File> (@Nullable AntDomPattern pattern, final Set<AntFilesProvider> processed) { return Collections.emptyList(); }
getFiles
5,459
boolean () { @NonNls final String value = getDefaultExcludes().getRawText(); return value == null || value.equalsIgnoreCase("yes") || value.equalsIgnoreCase("true"); }
shouldHonorDefaultExcludes
5,460
boolean () { @NonNls final String value = getCaseSensitive().getRawText(); return value == null || value.equalsIgnoreCase("yes") || value.equalsIgnoreCase("true"); }
matchPatternsCaseSensitive
5,461
File (final String path) { if (path == null) { return null; } try { final File file = new File(path); if (file.isAbsolute()) { return file.getCanonicalFile(); } final String baseDir = getContextAntProject().getProjectBasedirPath(); if (baseDir == null) { return null; } return new File(FileUtil.toCanonicalPath(new File(baseDir, path).getPath())); } catch (IOException e) { return null; } }
getCanonicalFile
5,462
PsiFileSystemItem () { final PsiFileSystemItem basedir = getBasedir().getValue(); if (basedir != null) { return basedir; } final XmlTag tag = getXmlTag(); final VirtualFile containingFile = tag.getContainingFile().getOriginalFile().getVirtualFile(); if (containingFile == null) { return null; } final VirtualFile parent = containingFile.getParent(); if (parent == null) { return null; } return tag.getManager().findDirectory(parent); }
getProjectBasedir
5,463
AntDomTarget (String declaredName) { for (AntDomTarget target : getDeclaredTargets()) { if (declaredName.equals(target.getName().getRawText())) { return target; } } return null; }
findDeclaredTarget
5,464
ClassLoader () { ClassLoader loader = myClassLoader; if (loader == null) { final XmlTag tag = getXmlTag(); final PsiFile containingFile = tag.getContainingFile(); final AntBuildFileImpl buildFile = (AntBuildFileImpl)AntConfigurationBase.getInstance(containingFile.getProject()).getAntBuildFile(containingFile); if (buildFile != null) { loader = buildFile.getClassLoader(); } else { AntInstallation antInstallation = getAntInstallation(); loader = antInstallation.getClassLoader(); } myClassLoader = loader; } return loader; }
getClassLoader
5,465
AntInstallation () { final AntConfigurationBase configuration = AntConfigurationBase.getInstance(getManager().getProject()); AntInstallation antInstallation = null; if (configuration != null) { antInstallation = configuration.getProjectDefaultAnt(); } if (antInstallation == null) { antInstallation = GlobalAntConfiguration.getInstance().getBundledAnt(); } assert antInstallation != null; return antInstallation; }
getAntInstallation
5,466
Sdk () { final XmlTag tag = getXmlTag(); final PsiFile containingFile = tag.getContainingFile(); final AntBuildFileImpl buildFile = (AntBuildFileImpl)AntConfigurationBase.getInstance(containingFile.getProject()).getAntBuildFile(containingFile); if (buildFile != null) { String jdkName = AntBuildFileImpl.CUSTOM_JDK_NAME.get(buildFile.getAllOptions()); if (StringUtil.isEmptyOrSpaces(jdkName)) { jdkName = AntConfigurationImpl.DEFAULT_JDK_NAME.get(buildFile.getAllOptions()); } if (!StringUtil.isEmptyOrSpaces(jdkName)) { return ProjectJdkTable.getInstance().findJdk(jdkName); } } return ProjectRootManager.getInstance(tag.getProject()).getProjectSdk(); }
getTargetJdk
5,467
Iterator<String> () { return getProperties().keySet().iterator(); }
getNamesIterator
5,468
String (String propertyName) { return getProperties().get(propertyName); }
getPropertyValue
5,469
PsiElement (String propertyName) { final DomTarget target = DomTarget.getTarget(this); final PsiElement nameElementPsi = target != null ? PomService.convertToPsi(target) : null; if (nameElementPsi != null) { return nameElementPsi; } final XmlElement xmlElement = getXmlElement(); return xmlElement != null? xmlElement.getNavigationElement() : null; }
getNavigationElement
5,470
void (final Map<String, String> map, String name, String value) { map.putIfAbsent(name, value); }
appendProperty
5,471
boolean () { return myIsComplete; }
isComplete
5,472
CustomAntElementsRegistry (AntDomProject antProject) { final AntDomProject contextProject = antProject.getContextAntProject(); CustomAntElementsRegistry registry = contextProject != null? contextProject.getUserData(REGISTRY_KEY) : null; if (registry == null) { registry = new CustomAntElementsRegistry(antProject); if (registry.isComplete()) { antProject.putUserData(REGISTRY_KEY, registry); } } return registry; }
getInstance
5,473
Set<XmlName> (AntDomElement parentElement) { if (parentElement instanceof AntDomCustomElement) { // this case is already handled in AntDomExtender when defining children return Collections.emptySet(); } final Set<XmlName> result = new HashSet<>(); final Pair<AntDomMacroDef, AntDomScriptDef> contextMacroOrScriptDef = getContextMacroOrScriptDef(parentElement); final AntDomMacroDef restrictToMacroDef = Pair.getFirst(contextMacroOrScriptDef); final AntDomScriptDef restrictToScriptDef = Pair.getSecond(contextMacroOrScriptDef); final boolean parentIsDataType = parentElement.isDataType(); for (final XmlName xmlName : myCustomElements.keySet()) { final AntDomNamedElement declaringElement = myDeclarations.get(xmlName); if (declaringElement instanceof AntDomMacrodefElement) { if (restrictToMacroDef == null || !restrictToMacroDef.equals(declaringElement.getParentOfType(AntDomMacroDef.class, true))) { continue; } } else if (declaringElement instanceof AntDomScriptdefElement) { if (restrictToScriptDef == null || !restrictToScriptDef.equals(declaringElement.getParentOfType(AntDomScriptDef.class, true))) { continue; } } if (declaringElement != null) { if (declaringElement.equals(restrictToMacroDef) || declaringElement.equals(restrictToScriptDef)) { continue; } } if (parentIsDataType) { if (declaringElement instanceof AntDomMacroDef || declaringElement instanceof AntDomScriptDef || declaringElement instanceof AntDomTaskdef) { continue; } if (declaringElement instanceof AntDomTypeDef typedef) { Class<?> clazz = lookupClass(xmlName); if (clazz != null && typedef.isTask(clazz)) { continue; } } } result.add(xmlName); } return result; }
getCompletionVariants
5,474
AntDomElement (final AntDomElement parentElement, final XmlName customElementName) { final AntDomElement declaration = myDeclarations.get(customElementName); if (declaration == null) { return null; } if (declaration instanceof AntDomMacrodefElement) { final Pair<AntDomMacroDef, AntDomScriptDef> contextMacroOrScriptDef = getContextMacroOrScriptDef(parentElement); final AntDomMacroDef macrodefUsed = Pair.getFirst(contextMacroOrScriptDef); if (macrodefUsed == null || !macrodefUsed.equals(declaration.getParentOfType(AntDomMacroDef.class, true))) { return null; } } else if (declaration instanceof AntDomScriptdefElement) { final Pair<AntDomMacroDef, AntDomScriptDef> contextMacroOrScriptDef = getContextMacroOrScriptDef(parentElement); final AntDomScriptDef scriptDefUsed = Pair.getSecond(contextMacroOrScriptDef); if (scriptDefUsed == null || !scriptDefUsed.equals(declaration.getParentOfType(AntDomScriptDef.class, true))) { return null; } } return declaration; }
findDeclaringElement
5,475
AntDomNamedElement (XmlName customElementName) { return myDeclarations.get(customElementName); }
getDeclaringElement
5,476
boolean (AntDomTypeDef typedef) { final String generalError = myTypeDefErrors.get(typedef); if (generalError != null) { return true; } return StreamEx.ofKeys(myDeclarations, typedef::equals).anyMatch(name -> lookupError(name) != null); }
hasTypeLoadingErrors
5,477
void (AntDomCustomClasspathComponent typedef, AntDomProject antProject) { final String loaderRef = typedef.getLoaderRef().getStringValue(); if (loaderRef != null) { if (!myNamedLoaders.containsKey(loaderRef)) { myNamedLoaders.put(loaderRef, createClassLoader(collectUrls(typedef), antProject)); } } }
rememberNamedClassLoader
5,478
ClassLoader (AntDomCustomClasspathComponent customComponent, AntDomProject antProject) { final String loaderRef = customComponent.getLoaderRef().getStringValue(); if (loaderRef != null) { final ClassLoader loader = myNamedLoaders.get(loaderRef); if (loader != null) { return loader; } } return createClassLoader(collectUrls(customComponent), antProject); }
getClassLoader
5,479
PsiFile (PsiFile originalFile, LanguageFileType fileType) { final VirtualFile vFile = originalFile.getVirtualFile(); if (vFile == null) { return null; } try { return loadContentAsFile(originalFile.getProject(), vFile.getInputStream(), fileType); } catch (IOException e) { LOG.info(e); } return null; }
loadContentAsFile
5,480
void (@NotNull AntDomNamedElement declaringTag, String customTagName, String nsUri, ClassProvider classProvider) { final XmlName xmlName = new XmlName(customTagName, nsUri == null? "" : nsUri); myCustomElements.put(xmlName, classProvider); myDeclarations.put(xmlName, declaringTag); ProgressManager.checkCanceled(); }
addCustomDefinition
5,481
boolean (AntDomTypeDef typedef, @NotNull final String resourceOrFileName) { final String format = typedef.getFormat().getStringValue(); if (format != null) { return "xml".equalsIgnoreCase(format); } return StringUtil.endsWithIgnoreCase(resourceOrFileName, ".xml"); }
isXmlFormat
5,482
ClassLoader (List<Path> files, AntDomProject antProject) { ClassLoader parentLoader = antProject.getClassLoader(); if (files.isEmpty()) { return parentLoader; } return new AntResourcesClassLoader(files, parentLoader, false, false); }
createClassLoader
5,483
List<Path> (AntDomClasspathElement typedef) { boolean cleanupNeeded = false; if (!ourIsBuildingClasspathForCustomTagLoading.get()) { ourIsBuildingClasspathForCustomTagLoading.set(Boolean.TRUE); cleanupNeeded = true; } try { List<Path> paths = new ArrayList<>(); // check classpath attribute List<File> cpFiles = typedef.getClasspath().getValue(); if (cpFiles != null) { addClasspathEntries(paths, cpFiles); } final HashSet<AntFilesProvider> processed = new HashSet<>(); final AntDomElement referencedPath = typedef.getClasspathRef().getValue(); if (referencedPath instanceof AntFilesProvider) { addClasspathEntries(paths, ((AntFilesProvider)referencedPath).getFiles(processed)); } // check nested elements for (Iterator<AntDomElement> it = typedef.getAntChildrenIterator(); it.hasNext();) { AntDomElement child = it.next(); if (child instanceof AntFilesProvider) { addClasspathEntries(paths, ((AntFilesProvider)child).getFiles(processed)); } } return paths; } finally { if (cleanupNeeded) { ourIsBuildingClasspathForCustomTagLoading.remove(); } } }
collectUrls
5,484
void (List<Path> paths, List<File> cpFiles) { for (File file : cpFiles) { if (!isValidClassPathEntry(file)) { continue; } Path path; try { path = file.toPath(); } catch (InvalidPathException e) { LOG.info(e); continue; } paths.add(path); } }
addClasspathEntries
5,485
boolean (File file) { if (file.isFile()) { final String name = file.getName(); return StringUtilRt.endsWithIgnoreCase(name, ".jar") || StringUtilRt.endsWithIgnoreCase(name, ".zip"); } return true; }
isValidClassPathEntry
5,486
void (AntDomElement element) { ProgressManager.checkCanceled(); if (element instanceof AntDomCustomElement || myElementsOnThePath.contains(element)) { return; // avoid stack overflow } myElementsOnThePath.add(element); try { final XmlTag tag = element.getXmlTag(); if (tag != null) { final String[] uris = tag.knownNamespaces(); for (String uri : uris) { if (!processedAntlibs.contains(uri)) { processedAntlibs.add(uri); final String antLibResource = AntDomAntlib.toAntlibResource(uri); if (antLibResource != null) { final XmlElement xmlElement = element.getXmlElement(); if (xmlElement != null) { final ClassLoader loader = myAntProject.getClassLoader(); final InputStream stream = loader.getResourceAsStream(antLibResource); if (stream != null) { try { final XmlFile xmlFile = (XmlFile)loadContentAsFile(xmlElement.getProject(), stream, XmlFileType.INSTANCE); loadDefinitionsFromAntlib(xmlFile, uri, loader, null, myAntProject); } catch (IOException e) { LOG.info(e); } } } } } } } super.visitAntDomElement(element); } finally { myElementsOnThePath.remove(element); } }
visitAntDomElement
5,487
void (AntDomMacroDef macrodef) { ProgressManager.checkCanceled(); final String customTagName = macrodef.getName().getStringValue(); if (customTagName != null) { final String nsUri = macrodef.getUri().getStringValue(); addCustomDefinition(macrodef, customTagName, nsUri, ClassProvider.EMPTY); for (AntDomMacrodefElement element : macrodef.getMacroElements()) { final String customSubTagName = element.getName().getStringValue(); if (customSubTagName != null) { addCustomDefinition(element, customSubTagName, nsUri, ClassProvider.EMPTY); } } } }
visitMacroDef
5,488
void (AntDomScriptDef scriptdef) { ProgressManager.checkCanceled(); final String customTagName = scriptdef.getName().getStringValue(); if (customTagName != null) { final String nsUri = scriptdef.getUri().getStringValue(); final ClassLoader classLoader = getClassLoader(scriptdef, myAntProject); // register the scriptdef addCustomDefinition(scriptdef, customTagName, nsUri, ClassProvider.EMPTY); // registering nested elements ReflectedProject reflectedProject = null; for (AntDomScriptdefElement element : scriptdef.getScriptdefElements()) { final String customSubTagName = element.getName().getStringValue(); if (customSubTagName != null) { final String classname = element.getClassname().getStringValue(); if (classname != null) { addCustomDefinition(element, customTagName, nsUri, ClassProvider.create(classname, classLoader)); } else { Class<?> clazz = null; final String typeName = element.getElementType().getStringValue(); if (typeName != null) { clazz = lookupClass(new XmlName(typeName)); if (clazz == null) { if (reflectedProject == null) { // lazy init reflectedProject = ReflectedProject.getProject(myAntProject.getClassLoader()); } Map<String, Class<?>> coreTasks = reflectedProject.getTaskDefinitions(); if (coreTasks != null) { clazz = coreTasks.get(typeName); } if (clazz == null) { Map<String, Class<?>> coreTypes = reflectedProject.getDataTypeDefinitions(); if (coreTypes != null) { clazz = coreTypes.get(typeName); } } } } addCustomDefinition(element, customSubTagName, nsUri, ClassProvider.create(clazz)); } } } } }
visitScriptDef
5,489
void (AntDomPresetDef presetdef) { ProgressManager.checkCanceled(); final String customTagName = presetdef.getName().getStringValue(); if (customTagName != null) { final String nsUri = presetdef.getUri().getStringValue(); addCustomDefinition(presetdef, customTagName, nsUri, ClassProvider.EMPTY); } }
visitPresetDef
5,490
void (AntDomTypeDef typedef) { ProgressManager.checkCanceled(); // if loaderRef attribute is specified, make sure the loader is built and stored rememberNamedClassLoader(typedef, myAntProject); defineCustomElements(typedef, myAntProject); }
visitTypeDef
5,491
void (AntDomInclude includeTag) { ProgressManager.checkCanceled(); processInclude(includeTag); }
visitInclude
5,492
void (AntDomImport importTag) { ProgressManager.checkCanceled(); processInclude(importTag); }
visitImport
5,493
void (AntDomIncludingDirective directive) { final PsiFileSystemItem item = directive.getFile().getValue(); if (item instanceof PsiFile) { final AntDomProject slaveProject = AntSupport.getAntDomProject((PsiFile)item); if (slaveProject != null) { slaveProject.accept(this); } } }
processInclude
5,494
void (AntDomTypeDef typedef, final AntDomProject antProject) { final String uri = typedef.getUri().getStringValue(); final String customTagName = typedef.getName().getStringValue(); final String classname = typedef.getClassName().getStringValue(); if (classname != null && customTagName != null) { addCustomDefinition(typedef, customTagName, uri, ClassProvider.create(classname, getClassLoader(typedef, antProject))); } else { defineCustomElementsFromResources(typedef, uri, antProject, null); } }
defineCustomElements
5,495
void (AntDomTypeDef typedef, final String uri, AntDomProject antProject, ClassLoader loader) { final XmlElement xmlElement = antProject.getXmlElement(); final Project project = xmlElement != null? xmlElement.getProject() : null; if (project == null) { return; } XmlFile xmlFile = null; PropertiesFile propFile = null; final String resource = typedef.getResource().getStringValue(); if (resource != null) { if (loader == null) { loader = getClassLoader(typedef, antProject); } final InputStream stream = loader.getResourceAsStream(resource); if (stream != null) { try { if (isXmlFormat(typedef, resource)) { xmlFile = (XmlFile)loadContentAsFile(project, stream, XmlFileType.INSTANCE); } else { propFile = (PropertiesFile)loadContentAsFile(project, stream, PropertiesFileType.INSTANCE); } } catch (IOException e) { LOG.info(e); } } else { myTypeDefErrors.put(typedef, "Resource \"" + resource + "\" not found in the classpath"); } } else { final PsiFileSystemItem file = typedef.getFile().getValue(); if (file instanceof PsiFile) { if (isXmlFormat(typedef, file.getName())) { xmlFile = file instanceof XmlFile ? (XmlFile)file : (XmlFile)loadContentAsFile((PsiFile)file, XmlFileType.INSTANCE); } else { // assume properties format propFile = file instanceof PropertiesFile ? (PropertiesFile)file : (PropertiesFile)loadContentAsFile((PsiFile)file, PropertiesFileType.INSTANCE); } } } if (propFile != null) { if (loader == null) { // if not initialized yet loader = getClassLoader(typedef, antProject); } for (final IProperty property : propFile.getProperties()) { addCustomDefinition(typedef, property.getUnescapedKey(), uri, ClassProvider.create(property.getUnescapedValue(), loader)); } } if (xmlFile != null) { if (loader == null) { // if not initialized yet loader = getClassLoader(typedef, antProject); } loadDefinitionsFromAntlib(xmlFile, uri, loader, typedef, antProject); } }
defineCustomElementsFromResources
5,496
void (XmlFile xmlFile, String uri, ClassLoader loader, @Nullable AntDomTypeDef typedef, AntDomProject antProject) { final AntDomAntlib antLib = AntSupport.getAntLib(xmlFile); if (antLib != null) { final List<AntDomTypeDef> defs = new ArrayList<>(); defs.addAll(antLib.getTaskdefs()); defs.addAll(antLib.getTypedefs()); if (!defs.isEmpty()) { for (AntDomTypeDef def : defs) { final String tagName = def.getName().getStringValue(); final String className = def.getClassName().getStringValue(); if (tagName != null && className != null) { AntDomNamedElement declaringElement = typedef != null? typedef : def; addCustomDefinition(declaringElement, tagName, uri, ClassProvider.create(className, loader)); } else { defineCustomElementsFromResources(def, uri, antProject, loader); } } } } }
loadDefinitionsFromAntlib
5,497
void (DomElement element) { }
visitDomElement
5,498
void (AntDomElement element) { for (Iterator<AntDomElement> iterator = element.getAntChildrenIterator(); iterator.hasNext();) { AntDomElement child = iterator.next(); child.accept(this); } }
visitAntDomElement
5,499
void (AntDomCustomElement custom) { visitAntDomElement(custom); }
visitAntDomCustomElement