Unnamed: 0
int64 0
305k
| body
stringlengths 7
52.9k
| name
stringlengths 1
185
|
|---|---|---|
16,700
|
PsiTypeVariable (final Constraint c) { return (PsiTypeVariable)c.getRight(); }
|
getVar
|
16,701
|
void (final Constraint x, final Constraint y) { reduceSideVar(x, y, new Reducer() { @Override public LinkedList<Pair<PsiType, Binding>> unify(final PsiType x, final PsiType y) { return myBindingFactory.union(x, y); } @Override public Constraint create(final PsiTypeVariable var, final PsiType type) { return new Subtype(var, type); } @Override public PsiType getType(final Constraint c) { return c.getRight(); } @Override public PsiTypeVariable getVar(final Constraint c) { return (PsiTypeVariable)c.getLeft(); } }); }
|
reduceVarType
|
16,702
|
Constraint (final PsiTypeVariable var, final PsiType type) { return new Subtype(var, type); }
|
create
|
16,703
|
PsiType (final Constraint c) { return c.getRight(); }
|
getType
|
16,704
|
PsiTypeVariable (final Constraint c) { return (PsiTypeVariable)c.getLeft(); }
|
getVar
|
16,705
|
void (final Constraint x, final Constraint y, final Reducer reducer) { final PsiTypeVariable var = reducer.getVar(x); final PsiType xType = reducer.getType(x); final PsiType yType = reducer.getType(y); final LinkedList<Pair<PsiType, Binding>> union = reducer.unify(xType, yType); if (union.isEmpty()) { return; } myConstraints.remove(x); myConstraints.remove(y); mySons = new ResolverTree[union.size()]; int i = 0; Constraint prev = null; for (final Pair<PsiType, Binding> pair : union) { if (prev != null) { myConstraints.remove(prev); } prev = reducer.create(var, pair.getFirst()); myConstraints.add(prev); mySons[i++] = applyRule(pair.getSecond()); } }
|
reduceSideVar
|
16,706
|
void () { reduce(); if (mySons.length > 0) { for (int i = 0; i < mySons.length; i++) { if (mySons[i] != null) { mySons[i].resolve(); if (!mySettings.exhaustive() && mySettings.cookToWildcards() && mySons[i].mySolutionFound) break; mySons[i] = null; } } } else { if (myConstraints.isEmpty()) { logSolution(); mySolutions.putSolution(myCurrentBinding); mySolutionFound = true; } } }
|
resolve
|
16,707
|
Binding () { return mySolutions.getBestSolution(); }
|
getBestSolution
|
16,708
|
int () { return 1; }
|
method1
|
16,709
|
int (boolean value) { return value ? 2 : 3; // will be a partially covered line }
|
method2
|
16,710
|
int () { return 3; }
|
method3
|
16,711
|
int () { return 4; }
|
method4
|
16,712
|
int () { return 5; }
|
method5
|
16,713
|
void () { }
|
uncoveredMethod1
|
16,714
|
void () { }
|
uncoveredMethod2
|
16,715
|
void () { }
|
uncoveredMethod3
|
16,716
|
void () { }
|
uncoveredMethod4
|
16,717
|
void () { new FooClass().method1(); }
|
testMethod1
|
16,718
|
void () { new FooClass().method2(true); }
|
testMethod2
|
16,719
|
void () { new BarClass().method3(); }
|
testMethod3
|
16,720
|
void (String[] args) { System.out.println(""); }
|
main
|
16,721
|
void (String[] args) { System.out.println(""); }
|
main
|
16,722
|
String (String className, String methodName) { return className + "," + sanitize(methodName, className.length()); }
|
sanitize
|
16,723
|
String (String name, int length) { StringBuilder result = new StringBuilder(); for (int i = 0; i < name.length(); i++) { final char ch = name.charAt(i); if (ch > 0 && ch < 255) { if (Character.isJavaIdentifierPart(ch) || ch == ' ' || ch == '@' || ch == '-') { result.append(ch); } else { result.append("_"); } } } int methodNameLimit = 250 - length; if (result.length() >= methodNameLimit) { String hash = String.valueOf(result.toString().hashCode()); return (methodNameLimit > hash.length() ? result.substring(0, methodNameLimit - hash.length()) : "") + hash; } return result.toString(); }
|
sanitize
|
16,724
|
Object () { try { return Class.forName("com.intellij.rt.coverage.data.ProjectData").getMethod("getProjectData", EMPTY_CLASS_ARRAY).invoke(null); } catch (Exception e) { return null; //should not happen } }
|
getData
|
16,725
|
void (final ITestResult iTestResult) { final Object data = getData(); if (data != null) { ((ProjectData)data).testStarted(getSanitizeTestName(iTestResult)); } }
|
onTestStart
|
16,726
|
String (ITestResult iTestResult) { return sanitize(iTestResult.getTestClass().getName(), iTestResult.getName()); }
|
getSanitizeTestName
|
16,727
|
void (final ITestResult iTestResult) { final Object data = getData(); if (data != null) { ((ProjectData)data).testEnded(getSanitizeTestName(iTestResult)); } }
|
onTestSuccess
|
16,728
|
void (final ITestResult iTestResult) { final Object data = getData(); if (data != null) { ((ProjectData)data).testEnded(getSanitizeTestName(iTestResult)); } }
|
onTestFailure
|
16,729
|
void (final ITestResult iTestResult) { final Object data = getData(); if (data != null) { ((ProjectData)data).testEnded(getSanitizeTestName(iTestResult)); } }
|
onTestSkipped
|
16,730
|
void (final ITestResult iTestResult) { }
|
onTestFailedButWithinSuccessPercentage
|
16,731
|
void (final ITestContext iTestContext) { }
|
onStart
|
16,732
|
void (final ITestContext iTestContext) { }
|
onFinish
|
16,733
|
void (String className, String methodName) { final Object data = getData(); ((com.intellij.rt.coverage.data.ProjectData)data).testStarted(sanitize(className, methodName)); }
|
testStarted
|
16,734
|
void (String className, String methodName) { final Object data = getData(); ((com.intellij.rt.coverage.data.ProjectData)data).testEnded(sanitize(className, methodName)); }
|
testFinished
|
16,735
|
boolean (@NotNull PsiFile sourceFile, PsiClass[] classes, Set<String> names) { return false; }
|
suggestQualifiedName
|
16,736
|
boolean (@NotNull final PsiFile srcFile, @Nullable final VirtualFile output, @Nullable final VirtualFile testoutput, @NotNull final CoverageSuitesBundle suite, @NotNull final Set<File> classFiles) { return false; }
|
collectOutputFiles
|
16,737
|
Module (@NotNull Module module) { return null; }
|
getModuleWithOutput
|
16,738
|
String (Editor editor, PsiFile file, int lineNumber, int startOffset, int endOffset, LineData lineData) { return null; }
|
generateBriefReport
|
16,739
|
boolean (RunConfigurationBase<?> runConfiguration) { return false; }
|
isSourceMapNeeded
|
16,740
|
boolean (CoverageSuitesBundle bundle, File classFile) { return false; }
|
ignoreCoverageForClass
|
16,741
|
boolean (CoverageSuitesBundle bundle, File classFile) { return false; }
|
keepCoverageInfoForClassWithoutSource
|
16,742
|
void (String @Nullable [] filters) { myIncludeFilters = filters; }
|
setIncludeFilters
|
16,743
|
void (String @Nullable [] patterns) { myExcludePatterns = patterns; }
|
setExcludePatterns
|
16,744
|
boolean () { return mySkipUnloadedClassesAnalysis; }
|
isSkipUnloadedClassesAnalysis
|
16,745
|
void (boolean skipUnloadedClassesAnalysis) { mySkipUnloadedClassesAnalysis = skipUnloadedClassesAnalysis; }
|
setSkipUnloadedClassesAnalysis
|
16,746
|
String[] (String[] filters) { if (filters == null || filters.length == 0) return ArrayUtilRt.EMPTY_STRING_ARRAY; List<String> result = new ArrayList<>(); for (String filter : filters) { if (filter.equals("*")) { result.add(""); //default package } else if (filter.endsWith(".*")) result.add(filter.substring(0, filter.length() - 2)); } return ArrayUtilRt.toStringArray(result); }
|
getPackageNames
|
16,747
|
String[] (Element element, final String tagName) { final List<Element> children = element.getChildren(tagName); List<String> filters = new ArrayList<>(); for (Element child : children) { filters.add(child.getValue()); } return filters.isEmpty() ? null : ArrayUtilRt.toStringArray(filters); }
|
readFilters
|
16,748
|
void (Element element, final String[] filters, final String tagName) { if (filters != null) { for (String filter : filters) { final Element filterElement = new Element(tagName); filterElement.setText(filter); element.addContent(filterElement); } } }
|
writeFilters
|
16,749
|
CoverageEngine () { return myCoverageEngine; }
|
getCoverageEngine
|
16,750
|
boolean (final String classFQName) { return isClassFiltered(classFQName, getFilteredClassNames()); }
|
isClassFiltered
|
16,751
|
boolean (String classFQName, String[] classPatterns) { for (String className : classPatterns) { if (className.equals(classFQName) || classFQName.startsWith(className) && classFQName.charAt(className.length()) == '$') { return true; } } return false; }
|
isClassFiltered
|
16,752
|
boolean (final String packageFQName) { for (String name : getExcludedPackageNames()) { if (packageFQName.equals(name) || packageFQName.startsWith(name + ".")) return false; } final String[] filteredPackageNames = getFilteredPackageNames(); for (final String packName : filteredPackageNames) { if (packName.isEmpty() || PsiNameHelper.isSubpackageOf(packageFQName, packName)) { return true; } } return filteredPackageNames.length == 0 && getFilteredClassNames().length == 0; }
|
isPackageFiltered
|
16,753
|
List<PsiPackage> (final Project project) { return ReadAction.compute(() -> { final List<PsiPackage> packages = new ArrayList<>(); final PsiManager psiManager = PsiManager.getInstance(project); final String[] filters = getFilteredPackageNames(); if (filters.length == 0) { if (getFilteredClassNames().length > 0) return Collections.emptyList(); final PsiPackage defaultPackage = JavaPsiFacade.getInstance(psiManager.getProject()).findPackage(""); if (defaultPackage != null) { packages.add(defaultPackage); } } else { final List<String> nonInherited = new ArrayList<>(); for (final String filter : filters) { if (!isSubPackage(filters, filter)) { nonInherited.add(filter); } } for (String filter : nonInherited) { final PsiPackage psiPackage = JavaPsiFacade.getInstance(psiManager.getProject()).findPackage(filter); if (psiPackage != null) { packages.add(psiPackage); } } } return packages; }); }
|
getCurrentSuitePackages
|
16,754
|
boolean (String[] filters, String filter) { for (String supPackageFilter : filters) { if (filter.startsWith(supPackageFilter + ".")) { return true; } } return false; }
|
isSubPackage
|
16,755
|
List<PsiClass> (final Project project) { final List<PsiClass> classes = new ArrayList<>(); final String[] classNames = getFilteredClassNames(); if (classNames.length > 0) { final DumbService dumbService = DumbService.getInstance(project); for (final String className : classNames) { ThrowableComputable<PsiClass, RuntimeException> computable = () -> { GlobalSearchScope searchScope = GlobalSearchScope.allScope(project); RunConfigurationBase<?> configuration = getConfiguration(); if (configuration instanceof ModuleBasedConfiguration) { Module module = ((ModuleBasedConfiguration<?,?>)configuration).getConfigurationModule().getModule(); if (module != null) { searchScope = GlobalSearchScope.moduleRuntimeScope(module, isTrackTestFolders()); } } return JavaPsiFacade.getInstance(project).findClass(className.replace("$", "."), searchScope); }; final PsiClass aClass = ReadAction.compute(() -> dumbService.computeWithAlternativeResolveEnabled(computable)); if (aClass != null) { classes.add(aClass); } } } return classes; }
|
getCurrentSuiteClasses
|
16,756
|
ProjectData (@NotNull final File sessionDataFile, @Nullable final CoverageSuite coverageSuite) { ProjectData projectData = ProjectDataLoader.load(sessionDataFile); File sourceMapFile = new File(JavaCoverageEnabledConfiguration.getSourceMapPath(sessionDataFile.getPath())); if (sourceMapFile.exists()) { try { CoverageReport.loadAndApplySourceMap(projectData, sourceMapFile); } catch (IOException e) { LOG.warn("Error reading source map associated with coverage data", e); } } if (coverageSuite instanceof JavaCoverageSuite javaSuite) { // Do not overwrite existing patterns if present, as they are written in the format expected by IDEA, // while the patterns passed to the agent are converted to the regex format. if (ArrayUtil.isEmpty(javaSuite.getIncludeFilters())) { String[] includeFilters = extractPatterns(projectData.getIncudePatterns()); javaSuite.setIncludeFilters(includeFilters); } if (ArrayUtil.isEmpty(javaSuite.getExcludePatterns())) { String[] excludePatterns = extractPatterns(projectData.getExcludePatterns()); javaSuite.setExcludePatterns(excludePatterns); } } return projectData; }
|
loadCoverageData
|
16,757
|
void (String sessionDataFilePath, String @Nullable [] patterns, SimpleJavaParameters parameters, boolean testTracking, boolean branchCoverage) { appendCoverageArgument(sessionDataFilePath, patterns, null, parameters, testTracking, branchCoverage, null, null); }
|
appendCoverageArgument
|
16,758
|
void (final String sessionDataFilePath, final String[] patterns, final String[] excludePatterns, final SimpleJavaParameters javaParameters, final boolean testTracking, final boolean branchCoverage, @Nullable String sourceMapPath, @Nullable final Project project) { final String agentPath = getAgentPath(); if (agentPath == null) return; final String[] excludeAnnotations = getExcludeAnnotations(project); List<Function<? super TargetEnvironmentRequest, ? extends JavaTargetParameter>> targetParameters = javaParameters.getTargetDependentParameters().asTargetParameters(); targetParameters.add(request -> createArgumentTargetParameter(agentPath, sessionDataFilePath, patterns, excludePatterns, excludeAnnotations, testTracking, branchCoverage, sourceMapPath)); if (!Registry.is("idea.coverage.new.tracing.enabled")) { targetParameters.add(request -> JavaTargetParameter.fixed("-Didea.new.tracing.coverage=false")); } if (branchCoverage && testTracking && !Registry.is("idea.coverage.new.test.tracking.enabled")) { targetParameters.add(request -> JavaTargetParameter.fixed("-Didea.new.test.tracking.coverage=false")); } }
|
appendCoverageArgument
|
16,759
|
String () { final String userDefinedAgentPath = System.getProperty(COVERAGE_AGENT_PATH_PROPERTY); final String bundledAgentPath = PathUtil.getJarPathForClass(ProjectData.class); final String agentPath = userDefinedAgentPath != null ? userDefinedAgentPath : bundledAgentPath; return handleSpacesInAgentPath(agentPath); }
|
getAgentPath
|
16,760
|
JavaTargetParameter (String agentPath, String sessionDataFilePath, String @Nullable [] patterns, String[] excludePatterns, String[] excludeAnnotations, boolean testTracking, boolean branchCoverage, String sourceMapPath) { try { final File tempFile = createTempFile(); tempFile.deleteOnExit(); Ref<Boolean> writeOnceRef = new Ref<>(false); String tempFilePath = tempFile.getAbsolutePath(); TargetPaths targetPaths = TargetPaths.ordered(builder -> { builder .download(sessionDataFilePath, __ -> { createFileOrClearExisting(sessionDataFilePath); return Unit.INSTANCE; }, targetSessionDataPath -> { if (!writeOnceRef.get()) { try { writeOptionsToFile(tempFile, targetSessionDataPath, patterns, excludePatterns, excludeAnnotations, testTracking, branchCoverage, sourceMapPath); } catch (IOException e) { throw new RuntimeException(e); } finally { writeOnceRef.set(true); } } return Unit.INSTANCE; }) .upload(agentPath, __ -> Unit.INSTANCE, __ -> Unit.INSTANCE) .upload(tempFilePath, __ -> Unit.INSTANCE, __ -> Unit.INSTANCE); return Unit.INSTANCE; }); return new JavaTargetParameter.Builder(targetPaths) .fixed("-javaagent:") .resolved(agentPath) .fixed("=") .resolved(tempFilePath) .build(); } catch (IOException e) { LOG.info("Coverage was not enabled", e); return null; } }
|
createArgumentTargetParameter
|
16,761
|
void (@NotNull String sessionDataFilePath) { File file = new File(sessionDataFilePath); FileUtil.createIfDoesntExist(file); try { new FileOutputStream(file).close(); } catch (IOException e) { LOG.error(e); } }
|
createFileOrClearExisting
|
16,762
|
String[] (@Nullable Project project) { if (project == null) return null; final JavaCoverageOptionsProvider optionsProvider = JavaCoverageOptionsProvider.getInstance(project); return ArrayUtil.toStringArray(optionsProvider.getExcludeAnnotationPatterns()); }
|
getExcludeAnnotations
|
16,763
|
String () { return "IntelliJ IDEA"; }
|
getPresentableName
|
16,764
|
String () { return "idea"; }
|
getId
|
16,765
|
String () { return "ic"; }
|
getDataFileExtension
|
16,766
|
boolean () { return true; }
|
isCoverageByTestApplicable
|
16,767
|
void (Project project, ProjectData projectData) { final JavaCoverageOptionsProvider optionsProvider = JavaCoverageOptionsProvider.getInstance(project); try { final String[] patterns = ArrayUtil.toStringArray(optionsProvider.getExcludeAnnotationPatterns()); final String[] regexps = convertToPatterns(patterns); projectData.setAnnotationsToIgnore(Stream.of(regexps).map((s) -> Pattern.compile(s)).toList()); } catch (PatternSyntaxException e) { LOG.info("Failed to collect exclude annotation patterns", e); } }
|
setExcludeAnnotations
|
16,768
|
List<Pattern> (CoverageSuitesBundle currentSuiteBundle) { final List<Pattern> includePatterns = new ArrayList<>(); for (CoverageSuite currentSuite : currentSuiteBundle.getSuites()) { for (String pattern : ((JavaCoverageSuite)currentSuite).getFilteredPackageNames()) { includePatterns.add(Pattern.compile(pattern + ".*")); } for (String pattern : ((JavaCoverageSuite)currentSuite).getFilteredClassNames()) { includePatterns.add(Pattern.compile(pattern)); } } return includePatterns; }
|
obtainPatternsFromSuite
|
16,769
|
Collection<ClassPathEntry> () { final Collection<ClassPathEntry> entries = new HashSet<>(); final Module[] modules = ModuleManager.getInstance(myProject).getModules(); final CoverageDataManager coverageManager = CoverageDataManager.getInstance(myProject); for (Module module : modules) { final VirtualFile[] roots = JavaCoverageClassesEnumerator.getRoots(coverageManager, module, myCurrentSuite.isTrackTestFolders()); for (VirtualFile root : roots) { entries.add(new ClassPathEntry(root.getPath())); } } return entries; }
|
getClassPathEntries
|
16,770
|
CoverageNotifications (Project project) { return project.getService(CoverageNotifications.class); }
|
getInstance
|
16,771
|
void () { replaceAndExpireNotification(null); }
|
beforeSuiteChosen
|
16,772
|
void (Notification newNotification) { replaceAndExpireNotification(newNotification); }
|
addNotification
|
16,773
|
void (Notification newNotification) { final Notification notification = myProjectOutOfDateNotification.getAndSet(newNotification); if (notification != null) { notification.expire(); notification.hideBalloon(); } }
|
replaceAndExpireNotification
|
16,774
|
void () { }
|
dispose
|
16,775
|
ProjectData (@NotNull File sessionDataFile, @Nullable CoverageSuite baseCoverageSuite) { final ProjectData data = new ProjectData(); try { final Project project = baseCoverageSuite instanceof BaseCoverageSuite ? baseCoverageSuite.getProject() : null; if (project != null) { var configuration = ((BaseCoverageSuite)baseCoverageSuite).getConfiguration(); Module mainModule = configuration instanceof ModuleBasedConfiguration ? ((ModuleBasedConfiguration<?, ?>)configuration).getConfigurationModule().getModule() : null; loadExecutionData(sessionDataFile, data, mainModule, project, baseCoverageSuite); } } catch (IOException e) { processError(sessionDataFile, e); return data; } catch (Exception e) { if (e instanceof ControlFlowException) throw e; LOG.error(e); return data; } return data; }
|
loadCoverageData
|
16,776
|
void (@NotNull File sessionDataFile, IOException e) { final String path = sessionDataFile.getAbsolutePath(); if ("Invalid execution data file.".equals(e.getMessage())) { Notifications.Bus.notify(new Notification("Coverage", CoverageBundle.message("coverage.error.loading.report"), JavaCoverageBundle.message("coverage.error.jacoco.report.format", path), NotificationType.ERROR)); LOG.info(e); } else if (e.getMessage() != null && e.getMessage().startsWith("Unknown block type")) { Notifications.Bus.notify(new Notification("Coverage", CoverageBundle.message("coverage.error.loading.report"), JavaCoverageBundle.message("coverage.error.jacoco.report.corrupted", path), NotificationType.ERROR)); LOG.info(e); } else { LOG.error(e); } }
|
processError
|
16,777
|
FileVisitResult (Path path, BasicFileAttributes attrs) { String internalName = StringUtil.trimEnd(rootPath.relativize(path).toString(), ".class"); String fqn = AnalysisUtils.internalNameToFqn(internalName); if (JavaCoverageSuite.isClassFiltered(fqn, suite.getExcludedClassNames()) || (!suite.isClassFiltered(fqn) && !suite.isPackageFiltered(StringUtil.getPackageName(fqn)))) { return FileVisitResult.CONTINUE; } File file = path.toFile(); try { analyzer.analyzeAll(file); } catch (Exception e) { LOG.info(e); } return FileVisitResult.CONTINUE; }
|
visitFile
|
16,778
|
Module[] (@Nullable Module mainModule, @NotNull Project project) { final Module[] modules; if (mainModule != null) { HashSet<Module> mainModuleWithDependencies = new HashSet<>(); ReadAction.run(() -> ModuleUtilCore.getDependencies(mainModule, mainModuleWithDependencies)); modules = mainModuleWithDependencies.toArray(Module.EMPTY_ARRAY); } else { modules = ModuleManager.getInstance(project).getModules(); } return modules; }
|
getModules
|
16,779
|
void (String sessionDataFilePath, String @Nullable [] patterns, SimpleJavaParameters parameters, boolean testTracking, boolean branchCoverage) { appendCoverageArgument(sessionDataFilePath, patterns, null, parameters, testTracking, branchCoverage, null, null); }
|
appendCoverageArgument
|
16,780
|
void (String sessionDataFilePath, String @Nullable [] patterns, String[] excludePatterns, SimpleJavaParameters javaParameters, boolean testTracking, boolean branchCoverage, String sourceMapPath, @Nullable Project project) { String path; try { path = AgentJar.extractToTempLocation().getAbsolutePath(); } catch (IOException e) { return; } final String agentPath = handleSpacesInAgentPath(path); if (agentPath == null) return; javaParameters.getTargetDependentParameters().asTargetParameters().add(request -> { return createArgumentTargetValue(agentPath, sessionDataFilePath, patterns, excludePatterns); }); }
|
appendCoverageArgument
|
16,781
|
JavaTargetParameter (String agentPath, String sessionDataFilePath, String @Nullable [] patterns, String[] excludePatterns) { HashSet<String> uploadPaths = ContainerUtil.newHashSet(agentPath); HashSet<String> downloadPaths = ContainerUtil.newHashSet(sessionDataFilePath); var builder = new JavaTargetParameter.Builder(uploadPaths, downloadPaths); return doCreateCoverageArgument(builder, patterns, excludePatterns, sessionDataFilePath, agentPath); }
|
createArgumentTargetValue
|
16,782
|
JavaTargetParameter (@NotNull JavaTargetParameter.Builder builder, String @Nullable [] patterns, String[] excludePatterns, String sessionDataFilePath, String agentPath) { builder .fixed("-javaagent:") .resolved(agentPath) .fixed("=destfile=") .resolved(sessionDataFilePath) .fixed(",append=false"); if (!ArrayUtil.isEmpty(patterns)) { builder.fixed(",includes=").fixed(StringUtil.join(patterns, ":")); } if (!ArrayUtil.isEmpty(excludePatterns)) { builder.fixed(",excludes=").fixed(StringUtil.join(excludePatterns, ":")); } return builder.build(); }
|
doCreateCoverageArgument
|
16,783
|
boolean (boolean branchCoverage) { return true; }
|
isBranchInfoAvailable
|
16,784
|
String () { return "JaCoCo"; }
|
getPresentableName
|
16,785
|
String () { return "jacoco"; }
|
getId
|
16,786
|
String () { return "exec"; }
|
getDataFileExtension
|
16,787
|
void (ProjectViewNode node, PresentationData data) { final Project project = node.getProject(); if (project == null) { return; } final CoverageDataManager coverageDataManager = getCoverageDataManager(project); CoverageSuitesBundle javaSuite = getJavaSuite(coverageDataManager, project); // This decorator is applicable only to java suites if (javaSuite == null) return; final JavaCoverageAnnotator javaCovAnnotator = (JavaCoverageAnnotator) javaSuite.getAnnotator(project); final Object value = node.getValue(); PsiElement element = null; if (value instanceof PsiElement psiElement) { element = psiElement; } else if (value instanceof SmartPsiElementPointer<?> smartPointer) { element = smartPointer.getElement(); } else if (value instanceof PackageElement packageElement) { final String coverageString = javaCovAnnotator.getPackageCoverageInformationString(packageElement.getPackage(), packageElement.getModule(), coverageDataManager); data.setLocationString(coverageString); } if (element instanceof PsiClass) { final GlobalSearchScope searchScope = javaSuite.getSearchScope(project); final VirtualFile vFile = PsiUtilCore.getVirtualFile(element); if (vFile != null && searchScope.contains(vFile)) { final String qName = ((PsiClass)element).getQualifiedName(); if (qName != null) { data.setLocationString(javaCovAnnotator.getClassCoverageInformationString(qName, coverageDataManager)); } } } else if (element instanceof PsiNamedElement namedElement && // handled in CoverageProjectViewDirectoryNodeDecorator !(element instanceof PsiFile || element instanceof PsiDirectory)) { for (JavaCoverageEngineExtension extension : JavaCoverageEngineExtension.EP_NAME.getExtensions()) { final PackageAnnotator.ClassCoverageInfo info = extension.getSummaryCoverageInfo(javaCovAnnotator, namedElement); if (info != null) { data.setLocationString(JavaCoverageAnnotator.getClassCoverageInformationString(info, coverageDataManager)); break; } } } }
|
decorate
|
16,788
|
CoverageSuitesBundle (@Nullable CoverageDataManager dataManager, @NotNull Project project) { if (dataManager == null) { return null; } for (CoverageSuitesBundle bundle : dataManager.activeSuites()) { final CoverageAnnotator coverageAnnotator = bundle.getAnnotator(project); if (coverageAnnotator instanceof JavaCoverageAnnotator) { return bundle; } } return null; }
|
getJavaSuite
|
16,789
|
JavaCoverageEngine () { return EP_NAME.findExtensionOrFail(JavaCoverageEngine.class); }
|
getInstance
|
16,790
|
boolean (@NotNull final RunConfigurationBase conf) { if (conf instanceof CommonJavaRunConfigurationParameters) { return true; } if (RunTargetsEnabled.get() && conf instanceof TargetEnvironmentAwareRunProfile && willRunOnTarget((TargetEnvironmentAwareRunProfile)conf)) { return false; } for (JavaCoverageEngineExtension extension : JavaCoverageEngineExtension.EP_NAME.getExtensionList()) { if (extension.isApplicableTo(conf)) { return true; } } return false; }
|
isApplicableTo
|
16,791
|
boolean (@NotNull final TargetEnvironmentAwareRunProfile configuration) { Project project = ((RunConfigurationBase<?>)configuration).getProject(); return TargetEnvironmentConfigurations.getEffectiveTargetName(configuration, project) != null || isProjectUnderWsl(project); }
|
willRunOnTarget
|
16,792
|
boolean (@NotNull Project project) { Sdk projectSdk = ProjectRootManager.getInstance(project).getProjectSdk(); if (projectSdk == null) { return false; } String projectSdkHomePath = projectSdk.getHomePath(); return projectSdkHomePath != null && WslPath.isWslUncPath(projectSdkHomePath); }
|
isProjectUnderWsl
|
16,793
|
boolean (@NotNull RunConfigurationBase conf) { return !(conf instanceof ApplicationConfiguration) && conf instanceof CommonJavaRunConfigurationParameters; }
|
canHavePerTestCoverage
|
16,794
|
Set<String> (Project project, CoverageSuitesBundle bundle, String classFQName, int lineNumber) { return extractTracedTests(bundle, classFQName, lineNumber); }
|
getTestsForLine
|
16,795
|
boolean (Project project, CoverageSuitesBundle bundle) { File[] files = getTraceFiles(bundle); return files != null && files.length > 0; }
|
wasTestDataCollected
|
16,796
|
Set<String> (CoverageSuitesBundle bundle, final String classFQName, final int lineNumber) { Set<String> tests = new HashSet<>(); final File[] traceFiles = getTraceFiles(bundle); if (traceFiles == null) return tests; for (File traceFile : traceFiles) { DataInputStream in = null; try { in = new DataInputStream(new FileInputStream(traceFile)); extractTests(traceFile, in, tests, classFQName, lineNumber); } catch (Exception ex) { LOG.error(traceFile.getName(), ex); } finally { try { if (in != null) { in.close(); } } catch (IOException ex) { LOG.error(ex); } } } return tests; }
|
extractTracedTests
|
16,797
|
File (CoverageSuite coverageSuite) { final String filePath = coverageSuite.getCoverageDataFileName(); final String dirName = FileUtilRt.getNameWithoutExtension(new File(filePath).getName()); final File parentDir = new File(filePath).getParentFile(); return new File(parentDir, dirName); }
|
getTracesDirectory
|
16,798
|
void (List<String> sanitizedTestNames, CoverageSuite suite, Map<String, Set<Integer>> executionTrace) { final File tracesDir = getTracesDirectory(suite); for (String testName : sanitizedTestNames) { final File file = new File(tracesDir, testName + ".tr"); if (file.exists()) { try (DataInputStream in = new DataInputStream(new FileInputStream(file))) { int traceSize = in.readInt(); for (int i = 0; i < traceSize; i++) { final String className = in.readUTF(); final int linesSize = in.readInt(); final Set<Integer> lines = executionTrace.computeIfAbsent(className, k -> new HashSet<>()); for(int l = 0; l < linesSize; l++) { lines.add(in.readInt()); } } } catch (Exception e) { LOG.error(e); } } } }
|
collectTestLines
|
16,799
|
void (CoverageSuite suite) { if (suite.isBranchCoverage()) { File tracesDirectory = getTracesDirectory(suite); if (tracesDirectory.exists()) { FileUtil.delete(tracesDirectory); } } }
|
deleteAssociatedTraces
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.