There are 80 code examples for java.util.Set.
The API names are highlighted below.
You can use
button
to vote the code example(s) you like. The best code example will be ranked first next time. Thanks a lot for your feedback.
Project Name: codecover Package: org.codecover.eclipse
Source Code: InstrumentableItemsManager.java (Click to view .java file)
Method Code:
/**
* Checks for every project in {@link #markedJavaElements}, if any element
* doesn't exist (was deleted) and removes unneccessary entries from the
* map.
*/
private void reconcileElementMap(){
Set<IJavaProject> projectsToCheck=CollectionUtil.copy(this.markedJavaElements.keySet());
for ( IJavaProject javaProject : projectsToCheck) {
Map<IPackageFragment,Set<ICompilationUnit>> map;
map=this.markedJavaElements.get(javaProject);
if (map == null || map.isEmpty()) {
this.markedJavaElements.remove(javaProject);
continue;
}
Set<IPackageFragment> packageFragments=CollectionUtil.copy(map.keySet());
for ( IPackageFragment packageFragment : packageFragments) {
Set<ICompilationUnit> subEntries=map.get(packageFragment);
if (!packageFragment.exists()) {
map.remove(packageFragment);
continue;
}
Set<ICompilationUnit> compilationUnits=CollectionUtil.copy(subEntries);
for ( ICompilationUnit compilationUnit : compilationUnits) {
if (!compilationUnit.exists()) {
subEntries.remove(compilationUnit);
continue;
}
}
}
}
}
Project Name: codecover Package: org.codecover.eclipse
Source Code: InstrumentableItemsManager.java (Click to view .java file)
Method Code:
/**
* Checks for every project in {@link #markedJavaElements}, if any element
* doesn't exist (was deleted) and removes unneccessary entries from the
* map.
*/
private void reconcileElementMap(){
Set<IJavaProject> projectsToCheck=CollectionUtil.copy(this.markedJavaElements.keySet());
for ( IJavaProject javaProject : projectsToCheck) {
Map<IPackageFragment,Set<ICompilationUnit>> map;
map=this.markedJavaElements.get(javaProject);
if (map == null || map.isEmpty()) {
this.markedJavaElements.remove(javaProject);
continue;
}
Set<IPackageFragment> packageFragments=CollectionUtil.copy(map.keySet());
for ( IPackageFragment packageFragment : packageFragments) {
Set<ICompilationUnit> subEntries=map.get(packageFragment);
if (!packageFragment.exists()) {
map.remove(packageFragment);
continue;
}
Set<ICompilationUnit> compilationUnits=CollectionUtil.copy(subEntries);
for ( ICompilationUnit compilationUnit : compilationUnits) {
if (!compilationUnit.exists()) {
subEntries.remove(compilationUnit);
continue;
}
}
}
}
}
Project Name: codecover Package: org.codecover.eclipse
Source Code: InstrumentableItemsManager.java (Click to view .java file)
Method Code:
private void saveInstrumentableItems(XMLMemento memento){
for ( Map.Entry<IJavaProject,Map<IPackageFragment,Set<ICompilationUnit>>> entry : this.markedJavaElements.entrySet()) {
Map<IPackageFragment,Set<ICompilationUnit>> subMap=entry.getValue();
IJavaProject javaProject=entry.getKey();
if (subMap.isEmpty() || !javaProject.exists()) {
continue;
}
IMemento projectNode=memento.createChild(TAG_I_JAVA_PROJECT);
projectNode.putString(TAG_INFO,getIJavaElementInfo(javaProject));
for ( Map.Entry<IPackageFragment,Set<ICompilationUnit>> subEntry : subMap.entrySet()) {
Set<ICompilationUnit> set=subEntry.getValue();
IPackageFragment packageFragment=subEntry.getKey();
if (set.isEmpty() || !packageFragment.exists()) {
continue;
}
IMemento packageNode=projectNode.createChild(TAG_I_PACKAGE_FRAGMENT);
packageNode.putString(TAG_INFO,getIJavaElementInfo(packageFragment));
for ( ICompilationUnit compilationUnit : set) {
if (!compilationUnit.exists()) {
continue;
}
IMemento compilationUnitNode=packageNode.createChild(TAG_I_COMPILATION_UNIT);
compilationUnitNode.putString(TAG_INFO,getIJavaElementInfo(compilationUnit));
}
}
}
}
Project Name: codecover Package: org.codecover.eclipse.actions
Source Code: UseForCoverageMeasurementActionDelegate.java (Click to view .java file)
Method Code:
/**
* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
public void run(IAction action){
if (!(this.selection instanceof IStructuredSelection)) {
return;
}
Set<IProject> projects=new HashSet<IProject>();
for (Iterator<?> i=((IStructuredSelection)this.selection).iterator(); i.hasNext(); ) {
Object o=i.next();
if (o instanceof IPackageFragment) {
IPackageFragment element=(IPackageFragment)o;
for ( Map.Entry<IPackageFragment,Set<ICompilationUnit>> entry : getChildren(element).entrySet()) {
for ( ICompilationUnit compilationUnit : entry.getValue()) {
if (action.isChecked()) {
getContainerManager().addICompilationUnit(compilationUnit);
}
else {
getContainerManager().removeICompilationUnit(compilationUnit);
}
}
}
projects.add(element.getResource().getProject());
}
else if (o instanceof ICompilationUnit) {
ICompilationUnit element=(ICompilationUnit)o;
if (element.getParent() instanceof IPackageFragment) {
if (action.isChecked()) {
getContainerManager().addICompilationUnit(element);
}
else {
getContainerManager().removeICompilationUnit(element);
}
}
projects.add(element.getResource().getProject());
}
}
PlatformUI.getWorkbench().getDecoratorManager().update(UseForCoverageMeasurementDecorator.ID);
for ( IProject project : projects) {
CodeCoverPlugin.build(project);
}
}
Project Name: codecover Package: org.codecover.eclipse.actions
Source Code: UseForCoverageMeasurementActionDelegate.java (Click to view .java file)
Method Code:
private Map<IPackageFragment,Set<ICompilationUnit>> getChildren(IPackageFragment element){
Map<IPackageFragment,Set<ICompilationUnit>> elements=new HashMap<IPackageFragment,Set<ICompilationUnit>>();
Set<IPackageFragment> packageFragments=new HashSet<IPackageFragment>();
packageFragments.add(element);
final String packageName=element.getElementName();
try {
if (element.getParent() instanceof IPackageFragmentRoot) {
IPackageFragmentRoot parent=(IPackageFragmentRoot)element.getParent();
for ( IJavaElement javaElement : parent.getChildren()) {
if (javaElement instanceof IPackageFragment) {
IPackageFragment packageFragment=(IPackageFragment)javaElement;
String fragmentName=packageFragment.getElementName();
if (fragmentName.startsWith(packageName)) {
packageFragments.add(packageFragment);
}
}
}
}
for ( IPackageFragment packageFragment : packageFragments) {
Set<ICompilationUnit> compilationUnits=new HashSet<ICompilationUnit>();
elements.put(packageFragment,compilationUnits);
for ( ICompilationUnit compilationUnit : packageFragment.getCompilationUnits()) {
compilationUnits.add(compilationUnit);
}
}
}
catch ( JavaModelException e) {
CodeCoverPlugin.getDefault().getLogger().fatal("A JavaModelException occured",e);
}
return elements;
}
Project Name: codecover Package: org.codecover.eclipse.actions
Source Code: UseForCoverageMeasurementActionDelegate.java (Click to view .java file)
Method Code:
private Map<IPackageFragment,Set<ICompilationUnit>> getChildren(IPackageFragment element){
Map<IPackageFragment,Set<ICompilationUnit>> elements=new HashMap<IPackageFragment,Set<ICompilationUnit>>();
Set<IPackageFragment> packageFragments=new HashSet<IPackageFragment>();
packageFragments.add(element);
final String packageName=element.getElementName();
try {
if (element.getParent() instanceof IPackageFragmentRoot) {
IPackageFragmentRoot parent=(IPackageFragmentRoot)element.getParent();
for ( IJavaElement javaElement : parent.getChildren()) {
if (javaElement instanceof IPackageFragment) {
IPackageFragment packageFragment=(IPackageFragment)javaElement;
String fragmentName=packageFragment.getElementName();
if (fragmentName.startsWith(packageName)) {
packageFragments.add(packageFragment);
}
}
}
}
for ( IPackageFragment packageFragment : packageFragments) {
Set<ICompilationUnit> compilationUnits=new HashSet<ICompilationUnit>();
elements.put(packageFragment,compilationUnits);
for ( ICompilationUnit compilationUnit : packageFragment.getCompilationUnits()) {
compilationUnits.add(compilationUnit);
}
}
}
catch ( JavaModelException e) {
CodeCoverPlugin.getDefault().getLogger().fatal("A JavaModelException occured",e);
}
return elements;
}
Project Name: codecover Package: org.codecover.eclipse.livenotification
Source Code: LiveNotificationClient.java (Click to view .java file)
Method Code:
/**
* Connects this {@link LiveNotificationClient} with the given server
* through the given port
* @param hostthe host to connect to
* @param portthe port to be used
* @throws LiveNotificationExceptionWraps an {@link IOException} occurred while communicating
* with the server.
*/
public void connect(String host,int port) throws LiveNotificationException {
try {
Registry registry=LocateRegistry.getRegistry(host,port);
RMIServer server=(RMIServer)registry.lookup(LOOKUP_JMXRMI);
this.connector=new RMIConnector(server,null);
this.connector.connect();
this.serverConnection=this.connector.getMBeanServerConnection();
Set<?> nameSet=this.serverConnection.queryNames(this.mbeanName,null);
if (nameSet.isEmpty()) {
this.clientState=ConnectionState.CONNECTED_NO_MBEAN;
}
else {
this.clientState=ConnectionState.CONNECTED_WITH_MBEAN;
}
sendStateChangeEvent();
Set<?> delegateSet=this.serverConnection.queryNames(new ObjectName(SERVER_DELEGATE_NAME),null);
for ( Object serverDelegateName : delegateSet) {
this.listener=new RegistrationListener();
this.serverDelegateObjectName=(ObjectName)serverDelegateName;
this.serverConnection.addNotificationListener(this.serverDelegateObjectName,this.listener,null,null);
}
}
catch ( RemoteException e) {
throw new LiveNotificationRemoteException(ERROR_ESTABLISHING_THE_CONNECTION,e);
}
catch ( NotBoundException e) {
throw new LiveNotificationNotBoundException(ERROR_LOOKUP_REGISTRY,e);
}
catch ( IOException e) {
disconnect();
throw new LiveNotificationIOException(ERROR_WITH_THE_CONNECTION,e);
}
catch ( MalformedObjectNameException e) {
throw new Error(e);
}
catch ( InstanceNotFoundException e) {
throw new Error(e);
}
}
Project Name: codecover Package: org.codecover.eclipse.preferences
Source Code: RGBWithBoundariesEditor.java (Click to view .java file)
Method Code:
private void notifyRefreshListeners(){
for ( RefreshListener listener : this.refreshListeners) {
listener.contentChanged(this);
}
}
Project Name: codecover Package: org.codecover.eclipse.tscmanager
Source Code: TSContainerManager.java (Click to view .java file)
Method Code:
/**
* Sets the redundant <code>TestCase</code>s of the active <code>TestSessionContainer</code> which are
* visualized in the plugin's views.
* @param testCases the redundant <code>TestCase</code>s or an empty <code>Set</code> if none are
* redundant
* @throws NullPointerException if <code>testCases</code> is <code>null</code> (pass an empty set to
* deactivate all test cases)
* @throws IllegalStateException if there is no redundant test session container
* @throws TSContainerManagerModifyException if the <code>TSContainerManager</code> is locked (because of
* a change event which is currently propagated)
*/
public void setRedundantTestCases(Set<TestCase> testCases,Set<TestCase> redundantTestCases){
ActiveTSContainerInfo newActiveTSCInfo;
if (testCases == null) {
throw new NullPointerException("testCases mustn't be null");
}
if (redundantTestCases == null) {
throw new NullPointerException("testCases mustn't be null");
}
synchronized (this.getWriteLock()) {
if (this.isLocked()) {
throw new TSContainerManagerModifyException("TSContainerManager is locked for" + " modifications during change event");
}
if (this.activeTSCInfo == null) {
throw new IllegalStateException("Active test cases can't be set if there" + " is no active test session container.");
}
for ( TestCase testCase : testCases) {
if (testCase.getTestSession().getTestSessionContainer() != this.activeTSCInfo.getTestSessionContainer()) {
throw new IllegalArgumentException("Test case to activate doesn't" + " belong to the active test session" + " container.");
}
}
newActiveTSCInfo=new ActiveTSContainerInfo(this.activeTSCInfo.getTSContainerInfo(),this.activeTSCInfo.getTestSessionContainer(),testCases,redundantTestCases);
synchronized (this.getReadLock()) {
this.activeTSCInfo=newActiveTSCInfo;
}
this.listenerHandler.fireTestCasesActivated(this.activeTSCInfo);
}
}
Project Name: codecover Package: org.codecover.eclipse.tscmanager
Source Code: TSContainerManagerListenerHandler.java (Click to view .java file)
Method Code:
public void changed(ChangeType ct,TestCase ctc){
ActiveTSContainerInfo activeTSCInfo;
synchronized (TSContainerManagerListenerHandler.this.tscManager.getWriteLock()) {
activeTSCInfo=TSContainerManagerListenerHandler.this.tscManager.getActiveTSContainer();
if (TSContainerManagerListenerHandler.this.tscManager.isLocked()) {
throw new TSContainerManagerModifyException("TSContainerManager is locked" + " for modifications during" + " change event");
}
if (activeTSCInfo == null || ctc.getTestSession().getTestSessionContainer() != activeTSCInfo.getTestSessionContainer()) {
logger.warning("Irrelevant TSC change event" + " received (and ignored)");
return;
}
activeTSCInfo.getTSContainerInfo().setSynchronized(false);
if (ct == ChangeType.REMOVE && activeTSCInfo.getActiveTestCases().contains(ctc)) {
Set<TestCase> newActiveTestCases=new HashSet<TestCase>(activeTSCInfo.getActiveTestCases());
newActiveTestCases.remove(ctc);
TSContainerManagerListenerHandler.this.tscManager.setActiveTestCases(newActiveTestCases);
}
}
TSContainerManagerListenerHandler.this.fireTestCaseChanged(activeTSCInfo,ct,ctc);
}
Project Name: codecover Package: org.codecover.eclipse.tscmanager
Source Code: TSContainerSaveQueue.java (Click to view .java file)
Method Code:
/**
* Locking of <code>TSContainerManager</code> must be done by the calling context.
*/
boolean saveQueued(IProject project,IProgressMonitor monitor) throws TSCQueuedSaveException {
Set<TSContainerInfo> queuedTSCInfos;
List<Throwable> exceptions=new ArrayList<Throwable>();
boolean performedSave=false;
final int monitorScale=1000;
monitor=(monitor != null) ? monitor : new NullProgressMonitor();
synchronized (this.queue) {
queuedTSCInfos=CollectionUtil.copy(this.queue.keySet());
}
try {
monitor.beginTask(MONITOR_SAVING_QUEUED_TEST_SESSION_CONTAINER,queuedTSCInfos.size() * 1 * monitorScale);
for ( TSContainerInfo tscInfo : queuedTSCInfos) {
if (tscInfo.getFile().getProject().equals(project)) {
try {
this.saveQueued(tscInfo,new SubProgressMonitor(monitor,1 * monitorScale));
}
catch ( Throwable t) {
exceptions.add(t);
logger.error("Error while performing queued" + " save of test session container: " + tscInfo.getFile().getFullPath().toString(),new InvocationTargetException(t));
}
performedSave=true;
}
else {
monitor.worked(1 * monitorScale);
}
}
if (!exceptions.isEmpty()) {
throw new TSCQueuedSaveException(exceptions);
}
}
finally {
monitor.done();
}
return performedSave;
}
Project Name: codecover Package: org.codecover.eclipse.tscmanager
Source Code: TSContainerInfo.java (Click to view .java file)
Method Code:
/**
* Stores the given (redundant) test cases represented as a list of <code>TestCaseInfo</code>s.
* @param testCases the test cases to save
*/
void setRedundantTestCases(Set<TestCase> RedundantTestCases){
this.setRedundantTestCases(TestCaseInfo.generateTestCaseInfos(RedundantTestCases));
}
Project Name: codecover Package: org.codecover.eclipse.tscmanager
Source Code: ActiveTSContainerInfo.java (Click to view .java file)
Method Code:
/**
* Returns an immutable copy of the set of redundant <code>TestCase</code>s of the represented test
* session container.
* @return an immutable copy of the set of redundant <code>TestCase</code>s of the represented test
* session container or an (immutable) empty set if none are redundant.
*/
public Set<TestCase> getRedundantTestCases(){
return this.RedundantTestCases;
}
Project Name: codecover Package: org.codecover.eclipse.tscmanager
Source Code: TestCaseInfo.java (Click to view .java file)
Method Code:
/**
* Generates <code>TestCaseInfo</code>-representations of the given <code>TestCase</code>s.
* @param testCases the <code>TestCase</code>s the <code>TestCaseInfo</code>-representations will be
* generated for
* @return <code>TestCaseInfo</code>-representations of the given <code>TestCase</code>s.
*/
public static List<TestCaseInfo> generateTestCaseInfos(Set<TestCase> testCases){
List<TestCaseInfo> testCaseInfos=new LinkedList<TestCaseInfo>();
for ( TestCase testCase : testCases) {
testCaseInfos.add(new TestCaseInfo(testCase.getName(),testCase.getTestSession().getName()));
}
return testCaseInfos;
}
Project Name: codecover Package: org.codecover.eclipse.utils
Source Code: EclipseMASTLinkage.java (Click to view .java file)
Method Code:
/**
* Find a type by its name.
* @param fQNamefully qualified name of the type
* @returnlist of matching compilation units
*/
public static Set<ICompilationUnit> findCompilationUnit(String fQName){
final Set<ICompilationUnit> result=new HashSet<ICompilationUnit>(1);
SearchPattern pattern=SearchPattern.createPattern(fQName,IJavaSearchConstants.TYPE,IJavaSearchConstants.DECLARATIONS,SearchPattern.R_CASE_SENSITIVE | SearchPattern.R_EXACT_MATCH);
IJavaSearchScope scope=SearchEngine.createWorkspaceScope();
SearchRequestor requestor=new SearchRequestor(){
@Override public void acceptSearchMatch( SearchMatch match) throws CoreException {
if (match.getAccuracy() == SearchMatch.A_ACCURATE) {
addMatch(match.getResource());
addMatch(match.getElement());
}
}
private void addMatch( Object match){
ICompilationUnit cu=null;
if (match instanceof SourceType) {
SourceType sf=(SourceType)match;
cu=sf.getCompilationUnit();
}
if (cu == null && match instanceof IJavaElement) {
IJavaElement adaptable=(IJavaElement)match;
cu=(ICompilationUnit)adaptable.getAdapter(ICompilationUnit.class);
}
if (cu != null) {
synchronized (result) {
result.add(cu);
}
}
}
}
;
SearchEngine searchEngine=new SearchEngine();
try {
searchEngine.search(pattern,new SearchParticipant[]{SearchEngine.getDefaultSearchParticipant()},scope,requestor,null);
}
catch ( CoreException e) {
CodeCoverPlugin.getDefault().getLogger().warning("Ignoring failed search for: " + fQName,e);
}
return result;
}
Project Name: codecover Package: org.codecover.eclipse.utils.recommendationgenerator
Source Code: ToResourceConverter.java (Click to view .java file)
Method Code:
/**
* Gibt ne IResource zurück. Class ist ein fully-qualified class name.
* Beispielsweise de.bundesregierung.Bundestrojaner
* @param path
* @return
*/
public static IResource getResourceFromClass(String clazz){
if (classToResourceMap.containsKey(clazz) && classToResourceMap.get(clazz) != null) {
return classToResourceMap.get(clazz);
}
Set<ICompilationUnit> cuSet=EclipseMASTLinkage.Eclipse.findCompilationUnit(clazz);
IResource resource=null;
for ( ICompilationUnit cu : cuSet) {
resource=cu.getResource();
break;
}
classToResourceMap.put(clazz,resource);
return resource;
}
Project Name: codecover Package: org.codecover.eclipse.utils.recommendationgenerator
Source Code: RecommendationGenerator.java (Click to view .java file)
Method Code:
private IResource getIResourceOfBranch(UncoveredBranch ub){
long a=new Date().getTime();
HierarchyLevel hLev=MAST.getTopLevelClass(ub.m_branchInfo.m_hierarchyLevel,this.testSessionContainer);
if (Cache.hLevToFileCache.containsKey(hLev)) {
return Cache.hLevToFileCache.get(hLev);
}
String fqn=MAST.getFQName(hLev,this.testSessionContainer);
Set<ICompilationUnit> cuSet;
cuSet=EclipseMASTLinkage.Eclipse.findCompilationUnit(fqn);
IResource resource=null;
for ( ICompilationUnit cu : cuSet) {
resource=cu.getResource();
Cache.hLevToCompUnitCache.put(hLev,cu);
Cache.fileToTestCaseMap.put(resource,ub.m_testCaseList);
if (resource != null) {
Cache.hLevToFileCache.put(hLev,resource);
}
break;
}
long b=new Date().getTime();
return resource;
}
Project Name: codecover Package: org.codecover.eclipse.utils.recommendationgenerator
Source Code: ErrorDataSource.java (Click to view .java file)
Method Code:
public void setRelevantFiles(Set<IResource> relevantFiles){
this.relevantFiles=relevantFiles;
}
Project Name: codecover Package: org.codecover.eclipse.utils.recommendationgenerator
Source Code: DataCollector.java (Click to view .java file)
Method Code:
public Set<IResource> getRelevantFiles(){
return this.relevantFiles;
}
Project Name: codecover Package: org.codecover.eclipse.utils.recommendationgenerator
Source Code: ErrorIndicator.java (Click to view .java file)
Method Code:
public void setRelevantFiles(Set<IResource> relevantFiles){
this.relevantFiles=relevantFiles;
}
Project Name: codecover Package: org.codecover.eclipse.views
Source Code: TestSessionsView.java (Click to view .java file)
Method Code:
/**
* Returns the <code>TestCase</code>s which are currently visualized in the
* viewer as being active (by checked checkboxes).
* @return the <code>TestCase</code>s which are currently visualized in the
* viewer as being active (by checked checkboxes).
*/
private Set<TestCase> getVisTestCases(){
return this.testCases;
}
Project Name: codecover Package: org.codecover.eclipse.views
Source Code: TestSessionsView.java (Click to view .java file)
Method Code:
private static Object[] fetchTestSessions(Set<String> testSessionNames,TestSessionContainer tsc){
Set<TestSession> testSessions=new HashSet<TestSession>();
TestSession testSession;
if (testSessionNames != null) {
for ( String testSessionName : testSessionNames) {
testSession=tsc.getTestSessionWithName(testSessionName);
if (testSession != null) {
testSessions.add(testSession);
}
}
}
return testSessions.toArray();
}
Project Name: codecover Package: org.codecover.eclipse.views
Source Code: TestSessionsView.java (Click to view .java file)
Method Code:
private static Object[] fetchTestSessions(Set<String> testSessionNames,TestSessionContainer tsc){
Set<TestSession> testSessions=new HashSet<TestSession>();
TestSession testSession;
if (testSessionNames != null) {
for ( String testSessionName : testSessionNames) {
testSession=tsc.getTestSessionWithName(testSessionName);
if (testSession != null) {
testSessions.add(testSession);
}
}
}
return testSessions.toArray();
}
Project Name: codecover Package: org.codecover.eclipse.views
Source Code: BooleanAnalyzer.java (Click to view .java file)
Method Code:
/**
* Handles the change of active status of the {@link TestCase}s in the
* current {@link TestSessionContainer}
* @param activeTestCasesthe {@link Set} of active {@link TestCase}s
*/
private final void onActiveTestCasesChanged(Set<TestCase> activeTestCases){
fillTable(new LinkedList<TestCase>(activeTestCases),getSelectedRootTerm());
}
Project Name: codecover Package: org.codecover.eclipse.views
Source Code: RecommendationsView.java (Click to view .java file)
Method Code:
@Override public void run(){
List<String> classes=new ArrayList<String>();
TestSessionContainer tsc=RecommendationsView.this.getVisTSC();
for ( HierarchyLevel lev : getClasses(tsc.getCode())) {
ICompilationUnit iCompilationUnit=Cache.hLevToCompUnitCache.get(lev);
if (iCompilationUnit == null) {
String fqn=MAST.getFQName(lev,getVisTSC());
Set<ICompilationUnit> cuSet;
cuSet=EclipseMASTLinkage.Eclipse.findCompilationUnit(fqn);
if (cuSet.size() > 0) {
iCompilationUnit=cuSet.iterator().next();
if (iCompilationUnit != null) {
Cache.hLevToCompUnitCache.put(lev,iCompilationUnit);
}
}
}
if (iCompilationUnit == null) {
continue;
}
String name=lev.getName();
String packagge="";
try {
IPackageDeclaration[] packageDeclarations=iCompilationUnit.getPackageDeclarations();
for ( IPackageDeclaration ipd : packageDeclarations) {
packagge=ipd.getElementName();
}
}
catch ( JavaModelException e) {
e.printStackTrace();
}
if (name.length() > 0 && packagge.length() > 0) {
String ganz=packagge + "." + name;
System.out.println("ADD: " + ganz);
classes.add(ganz);
}
}
for ( String c : classes) {
System.out.println(c);
}
new CreateErrorInfoFileDialog(new Shell(),classes);
}
Project Name: codecover Package: org.codecover.eclipse.views
Source Code: CoverageGraphView.java (Click to view .java file)
Method Code:
private final void onActiveTestCasesChanged(Set<TestCase> activetestCases){
refreshActiveTestCaseList(activetestCases);
org.eclipse.swt.graphics.Point size=graphComposite.getSize();
graphComposite.dispose();
graphComposite=new GraphComposite(this.sashForm,SWT.NONE,size,createGraph(ActiveCriterion,ActiveSUTLevel,ActiveTestLevel,SelectedOnlyCovered,CompleteName),SelectedMouseStyle);
graphComposite.setLayout(new GridLayout(2,false));
graphComposite.setLayout(new FillLayout());
graphComposite.setSize(size);
graphComposite.setRedraw(true);
}
Project Name: codecover Package: org.codecover.eclipse.views
Source Code: ManualRedundancyView.java (Click to view .java file)
Method Code:
/**
* Returns the <code>TestCase</code>s which are currently visualized in the viewer as being active (by
* checked checkboxes).
* @return the <code>TestCase</code>s which are currently visualized in the viewer as being active (by
* checked checkboxes).
*/
private Set<TestCase> getVisTestCases(){
return this.RedundanttestCases;
}
Project Name: codecover Package: org.codecover.eclipse.views
Source Code: ManualRedundancyView.java (Click to view .java file)
Method Code:
private static Object[] fetchTestSessions(Set<String> testSessionNames,TestSessionContainer tsc){
Set<TestSession> testSessions=new HashSet<TestSession>();
TestSession testSession;
if (testSessionNames != null) {
for ( String testSessionName : testSessionNames) {
testSession=tsc.getTestSessionWithName(testSessionName);
if (testSession != null) {
testSessions.add(testSession);
}
}
}
return testSessions.toArray();
}
Project Name: codecover Package: org.codecover.eclipse.views
Source Code: ManualRedundancyView.java (Click to view .java file)
Method Code:
private static Object[] fetchTestSessions(Set<String> testSessionNames,TestSessionContainer tsc){
Set<TestSession> testSessions=new HashSet<TestSession>();
TestSession testSession;
if (testSessionNames != null) {
for ( String testSessionName : testSessionNames) {
testSession=tsc.getTestSessionWithName(testSessionName);
if (testSession != null) {
testSessions.add(testSession);
}
}
}
return testSessions.toArray();
}
Project Name: codecover Package: org.codecover.eclipse.views
Source Code: PickTestCaseView.java (Click to view .java file)
Method Code:
/**
* Pick the test cases that fully cover the current selection of
* <code>editor</code>. Uses the currently active test cases.
* @param editor
* @return The covering test cases.
* <p>
* null if no test session container is active. An empty set if
* nothing can be found at current selection.
*/
private Set<PickedTestCase> pickTestCase(ITextEditor editor){
CodeCoverPlugin plugin=CodeCoverPlugin.getDefault();
ActiveTSContainerInfo activeTSCI=plugin.getTSContainerManager().getActiveTSContainer();
if (activeTSCI == null) {
}
else {
Collection<TestCase> activeTestCases=activeTSCI.getActiveTestCases();
TestSessionContainer tsc=activeTSCI.getTestSessionContainer();
Set<PickedTestCase> pickedTestCases;
if (activeTestCases.isEmpty()) {
pickedTestCases=Collections.emptySet();
}
else {
SourceFile file=PickCodeActionDelegate.getSourceFile(editor,tsc);
if (file == null) {
pickedTestCases=Collections.emptySet();
}
else {
Location selection=EclipseMASTLinkage.getSelection(editor,file);
MetaDataObject selectedElement;
selectedElement=new PickTestCaseActionDelegate().findSurroundingElement(selection,tsc);
if (selectedElement == null) {
pickedTestCases=Collections.emptySet();
}
else {
pickedTestCases=PickTestCaseActionDelegate.pickTestCases(activeTestCases,tsc,selectedElement);
}
}
}
return pickedTestCases;
}
return null;
}
Project Name: codecover Package: org.codecover.eclipse.views
Source Code: CorrelationView.java (Click to view .java file)
Method Code:
private final void calculateCorrelation(){
ActiveTSContainerInfo activeTSContainer=CodeCoverPlugin.getDefault().getTSContainerManager().getActiveTSContainer();
if (activeTSContainer == null) {
return;
}
TestSessionContainer testSessionContainer=activeTSContainer.getTestSessionContainer();
List<TestCase> testCases=new Vector<TestCase>();
for ( TestSession testSession : testSessionContainer.getTestSessions()) {
testCases.addAll(testSession.getTestCases());
}
if (testCases.isEmpty()) {
return;
}
Set<TestCase> allTestCases=new HashSet<TestCase>(testCases);
Set<TestCase> lastUsed=new HashSet<TestCase>(this.activeTestCases);
lastUsed.retainAll(allTestCases);
refreshLastUsedTestCases(lastUsed);
this.resultMap.clear();
Set<Criterion> availableCriteria=testSessionContainer.getCriteria();
for ( CorrelationMetric correlationMetric : this.correlationMetrics) {
if (availableCriteria.containsAll(correlationMetric.getRequiredCriteria())) {
CorrelationResult result=correlationMetric.calculateCorrelation(testCases);
this.resultMap.put(correlationMetric,result);
}
}
}
Project Name: codecover Package: org.codecover.eclipse.views
Source Code: CorrelationView.java (Click to view .java file)
Method Code:
public boolean hasChildren(Object element){
if (element instanceof GraphElement) {
if (((GraphElement)element).children.isEmpty()) {
return false;
}
else {
List<GraphElement> list=new LinkedList<GraphElement>();
for ( GraphElement graphElement : ((GraphElement)element).children) {
return list.addAll(rec(graphElement));
}
return !list.isEmpty();
}
}
return false;
}
Project Name: codecover Package: org.codecover.eclipse.views
Source Code: CorrelationView.java (Click to view .java file)
Method Code:
public String getText(Object element){
if (element instanceof GraphElement) {
StringBuilder sb=new StringBuilder();
boolean firstElement=true;
for ( TestCase testCase : ((GraphElement)element).testCases) {
if (!isTestCaseActive(testCase)) {
continue;
}
String name=testCase.getName();
String sessionName=testCase.getTestSession().getName();
if (firstElement) {
firstElement=false;
}
else {
sb.append(", ");
}
sb.append(String.format(TREE_LABEL_FORMAT,name,sessionName));
}
return sb.toString();
}
return null;
}
Project Name: codecover Package: org.codecover.eclipse.views
Source Code: CoverageView.java (Click to view .java file)
Method Code:
private void restoreExpandedElements(ActiveTSContainerInfo tscInfo){
Set<Object> expandedHLevs=new HashSet<Object>();
FindIDVisitor findIDVisitor=new FindIDVisitor();
Set<String> expHLevIDs;
synchronized (this.updateLock) {
expHLevIDs=this.expandedHLevIDs.get(tscInfo.getTSContainerInfo());
if (expHLevIDs != null) {
for ( String hLevID : expHLevIDs) {
findIDVisitor.setID(hLevID);
tscInfo.getTestSessionContainer().getCode().accept(findIDVisitor,null,null,null,null,null,null,null,null);
if (findIDVisitor.getHierarchyLevel() != null) {
expandedHLevs.add(findIDVisitor.getHierarchyLevel());
}
}
}
this.viewer.setExpandedElements(expandedHLevs.toArray());
}
}
Project Name: codecover Package: org.codecover.eclipse.views
Source Code: CoverageView.java (Click to view .java file)
Method Code:
private void restoreExpandedElements(ActiveTSContainerInfo tscInfo){
Set<Object> expandedHLevs=new HashSet<Object>();
FindIDVisitor findIDVisitor=new FindIDVisitor();
Set<String> expHLevIDs;
synchronized (this.updateLock) {
expHLevIDs=this.expandedHLevIDs.get(tscInfo.getTSContainerInfo());
if (expHLevIDs != null) {
for ( String hLevID : expHLevIDs) {
findIDVisitor.setID(hLevID);
tscInfo.getTestSessionContainer().getCode().accept(findIDVisitor,null,null,null,null,null,null,null,null);
if (findIDVisitor.getHierarchyLevel() != null) {
expandedHLevs.add(findIDVisitor.getHierarchyLevel());
}
}
}
this.viewer.setExpandedElements(expandedHLevs.toArray());
}
}
Project Name: codecover Package: org.codecover.eclipse.views
Source Code: RedundancyGraphView.java (Click to view .java file)
Method Code:
private final void onActiveTestCasesChanged(Set<TestCase> selectedtestCases,Set<TestCase> redundanttestCases){
refreshActiveTestCaseList(selectedtestCases,redundanttestCases);
org.eclipse.swt.graphics.Point size=this.graphComposite.getSize();
this.graphComposite.dispose();
this.graphComposite=new GraphComposite(this.sashForm,SWT.NONE,size,null,"");
this.graphComposite.setLayout(new GridLayout(2,false));
this.graphComposite.setLayout(new FillLayout());
this.graphComposite.setSize(size);
this.graphComposite.setRedraw(true);
this.SuiteRedundancy.clear();
this.PairRedundancy.clear();
calculateSuiteRedundancy(this.ActiveCriterion);
calculatePairRedundancy(this.ActiveCriterion);
}
Project Name: codecover Package: org.codecover.eclipse.views.controls
Source Code: MergeWizardPage.java (Click to view .java file)
Method Code:
private void applySelection(){
if (this.preSelection != null) {
Object[] sel=this.preSelection.toArray();
boolean selectionContainsTestSession=false;
boolean selectionContainsTestCase=false;
Set<TestSession> expandedElements=new HashSet<TestSession>();
for ( Object o : sel) {
if (o instanceof TestCase) {
expandedElements.add(((TestCase)o).getTestSession());
this.selectedTestCases.add((TestCase)o);
selectionContainsTestCase=true;
}
else if (o instanceof TestSession) {
this.selectedTestSessions.add((TestSession)o);
selectionContainsTestSession=true;
}
}
if (selectionContainsTestCase && !selectionContainsTestSession) {
this.bttTestCase.setSelection(true);
this.bttTestSession.setSelection(false);
}
this.viewer.setExpandedElements(expandedElements.toArray());
this.viewer.setCheckedElements(sel);
this.checkElements();
}
}
Project Name: codecover Package: org.codecover.eclipse.views.controls
Source Code: DeleteTestElementsSelectDialog.java (Click to view .java file)
Method Code:
private static Set<TestCase> fetchContainedTestCasesOfTestSession(Object[] elements,TestSession testSession){
Set<TestCase> testCases=new HashSet<TestCase>();
for ( Object element : elements) {
if (element instanceof TestCase && ((TestCase)element).getTestSession() == testSession) {
testCases.add((TestCase)element);
}
}
return testCases;
}
Project Name: codecover-instrumentation Package: org.codecover.instrumentation
Source Code: DefaultInstrumenterFactory.java (Click to view .java file)
Method Code:
public void reset(){
this.descriptor=null;
this.charset=null;
this.criteria=new TreeSet<Criterion>();
}
Project Name: codecover-instrumentation Package: org.codecover.instrumentation
Source Code: InstrumenterDescriptor.java (Click to view .java file)
Method Code:
/**
* @param criterionthe supportedCriteria to set
*/
protected void addSupportedCriteria(Criterion criterion){
if (criterion == null) {
throw new NullPointerException();
}
this.supportedCriteria.add(criterion);
}
Project Name: codecover-model Package: org.codecover.model
Source Code: MASTBuilder.java (Click to view .java file)
Method Code:
/**
* Creates and returns an instance of a {@link LoopingStatement} containing
* the given data.
* @param locationthe {@link LocationList}, specifying the location of the{@link LoopingStatement} in its {@link SourceFile}
* @param coverableItemthe {@link CoverableItem} of the {@link LoopingStatement}
* @param termsthe {@link RootTerm}s associated with this{@link LoopingStatement}
* @param statementSequencethe {@link StatementSequence} contained in this{@link LoopingStatement}
* @param keywordthe {@link Location}, specifying the location of the keyword
* of the {@link LoopingStatement} in its {@link SourceFile}
* @param neverExecutedItemthe {@link CoverableItem} of the {@link LoopingStatement},
* that represents the number times the loop was not traversed
* @param onceExecutedItemthe {@link CoverableItem} of the {@link LoopingStatement},
* that represents the number times the loop was traversed only
* once
* @param multipleExecutedItemthe {@link CoverableItem} of the {@link LoopingStatement},
* that represents the number times the loop was traversed
* multiple times
* @param optionalBodyExecutionindicates, whether or not the body of the loop can be skipped
* entirely or is executed at least once, as it it the case with
* the "do ... while()" construct
* @return the created {@link LoopingStatement}
*/
public LoopingStatement createLoopingStatement(LocationList location,CoverableItem coverableItem,Set<RootTerm> terms,StatementSequence statementSequence,Location keyword,CoverableItem neverExecutedItem,CoverableItem onceExecutedItem,CoverableItem multipleExecutedItem,boolean optionalBodyExecution,Set<QuestionMarkOperator> questionMarkOperators){
LoopingStatement loopingStatement=Internal.createLoopingStatement(location,coverableItem,terms,statementSequence,keyword,neverExecutedItem,onceExecutedItem,multipleExecutedItem,optionalBodyExecution,questionMarkOperators,this.logger);
return loopingStatement;
}
Project Name: codecover-model Package: org.codecover.model
Source Code: MASTBuilder.java (Click to view .java file)
Method Code:
/**
* Creates and returns an instance of a {@link LoopingStatement} containing
* the given data.
* @param locationthe {@link LocationList}, specifying the location of the{@link LoopingStatement} in its {@link SourceFile}
* @param coverableItemthe {@link CoverableItem} of the {@link LoopingStatement}
* @param termsthe {@link RootTerm}s associated with this{@link LoopingStatement}
* @param statementSequencethe {@link StatementSequence} contained in this{@link LoopingStatement}
* @param keywordthe {@link Location}, specifying the location of the keyword
* of the {@link LoopingStatement} in its {@link SourceFile}
* @param neverExecutedItemthe {@link CoverableItem} of the {@link LoopingStatement},
* that represents the number times the loop was not traversed
* @param onceExecutedItemthe {@link CoverableItem} of the {@link LoopingStatement},
* that represents the number times the loop was traversed only
* once
* @param multipleExecutedItemthe {@link CoverableItem} of the {@link LoopingStatement},
* that represents the number times the loop was traversed
* multiple times
* @param optionalBodyExecutionindicates, whether or not the body of the loop can be skipped
* entirely or is executed at least once, as it it the case with
* the "do ... while()" construct
* @return the created {@link LoopingStatement}
*/
public LoopingStatement createLoopingStatement(LocationList location,CoverableItem coverableItem,Set<RootTerm> terms,StatementSequence statementSequence,Location keyword,CoverableItem neverExecutedItem,CoverableItem onceExecutedItem,CoverableItem multipleExecutedItem,boolean optionalBodyExecution,Set<QuestionMarkOperator> questionMarkOperators){
LoopingStatement loopingStatement=Internal.createLoopingStatement(location,coverableItem,terms,statementSequence,keyword,neverExecutedItem,onceExecutedItem,multipleExecutedItem,optionalBodyExecution,questionMarkOperators,this.logger);
return loopingStatement;
}
Project Name: codecover-model Package: org.codecover.model
Source Code: TestSessionContainer.java (Click to view .java file)
Method Code:
/**
* @return all {@link CoverableItem}s appearing in the code except those in
* a {@link RootTerm} RootTerm
*/
public Set<CoverableItem> getCoverableItems(){
return this.coverableItems;
}
Project Name: codecover-model Package: org.codecover.model
Source Code: TestSessionContainer.java (Click to view .java file)
Method Code:
/**
* @return the criteria used for instrumentation
*/
public Set<Criterion> getCriteria(){
return this.criteria;
}
Project Name: codecover-model Package: org.codecover.model
Source Code: XMLWriter1_0_Base.java (Click to view .java file)
Method Code:
/**
* Starts element for lists of {@link MetaData}
* @param metaDataMapEntriesthe given entryset containing the object used as{@link MetaData}, as well as the keys used to map them
* @throws SAXException
*/
private void createMetaDataListElement(Set<Entry<String,Object>> metaDataMapEntries) throws SAXException {
if (metaDataMapEntries == null) {
throw new NullPointerException("metaDataMapEntries == null");
}
startElement(ELEMENT_META_DATA_LIST,getEmptyAttributes());
for ( Entry<String,Object> entry : metaDataMapEntries) {
if (entry.getValue() != null) {
createMetaDataListEntryElement(entry.getKey(),entry.getValue());
}
}
endElement(ELEMENT_META_DATA_LIST);
}
Project Name: codecover-model Package: org.codecover.model
Source Code: XMLWriter1_0_Base.java (Click to view .java file)
Method Code:
/**
* Starts element for a map of {@link BooleanAssignment}s and{@link Boolean}s
* @param namethe name of the tag
* @param mapEntriesthe entries of the map
* @throws SAXException
*/
private void createBooleanAssignmentBooleanMapListElement(String name,Set<Map.Entry<BooleanAssignment,Boolean>> mapEntries) throws SAXException {
if (name == null) {
throw new NullPointerException("name == null");
}
if (mapEntries == null) {
throw new NullPointerException("mapEntries == null");
}
startElement(name,getEmptyAttributes());
for ( Map.Entry<BooleanAssignment,Boolean> entry : mapEntries) {
createBooleanAssignmentStringMapListEntryElement(entry.getKey(),entry.getValue().toString());
}
endElement(name);
}
Project Name: codecover-model Package: org.codecover.model
Source Code: XMLWriter1_0_Base.java (Click to view .java file)
Method Code:
/**
* Starts element for a map of {@link BooleanAssignment}s and {@link Long}s
* @param namethe name of the tag
* @param mapEntriesthe entries of the map
* @param atts
* @throws SAXException
*/
private void createBooleanAssignmentLongMapListElement(String name,Set<Map.Entry<BooleanAssignment,Long>> mapEntries,Map<String,String> atts) throws SAXException {
if (name == null) {
throw new NullPointerException("name == null");
}
if (mapEntries == null) {
throw new NullPointerException("mapEntries == null");
}
startElement(name,atts);
for ( Map.Entry<BooleanAssignment,Long> entry : mapEntries) {
createBooleanAssignmentStringMapListEntryElement(entry.getKey(),entry.getValue().toString());
}
endElement(name);
}
Project Name: codecover-model Package: org.codecover.model
Source Code: XMLWriter1_0_Base.java (Click to view .java file)
Method Code:
/**
* Starts element for a list of {@link Criterion}s
* @param criteriathe list of {@link Criterion}s
* @throws SAXException
*/
private void createCriteriaListElement(Set<Criterion> criteria) throws SAXException {
if (criteria == null) {
throw new NullPointerException("criteria == null");
}
startElement(ELEMENT_CRITERIA_LIST,getEmptyAttributes());
for ( Criterion criterion : criteria) {
createCriteriaListEntryElement(criterion);
}
endElement(ELEMENT_CRITERIA_LIST);
}
Project Name: codecover-model Package: org.codecover.model
Source Code: XMLWriter1_0_Base.java (Click to view .java file)
Method Code:
private Set<BooleanOperator> getAllBooleanOperators(HierarchyLevel hierarchyLevel){
if (hierarchyLevel == null) {
return Collections.emptySet();
}
final Set<BooleanOperator> set=new HashSet<BooleanOperator>();
hierarchyLevel.accept(null,null,null,null,null,null,new Visitor(){
public void visit( BasicBooleanTerm term){
}
public void visit( OperatorTerm term){
set.add(term.getOperator());
}
}
,null,null);
return set;
}
Project Name: codecover-model Package: org.codecover.model
Source Code: XMLWriter1_0_Base.java (Click to view .java file)
Method Code:
private Set<HierarchyLevelType> getAllHierarchyLevelTypes(HierarchyLevel hierarchyLevel){
if (hierarchyLevel == null) {
return Collections.emptySet();
}
final Set<HierarchyLevelType> set=new HashSet<HierarchyLevelType>();
hierarchyLevel.accept(new HierarchyLevel.Visitor(){
public void visit( HierarchyLevel level){
set.add(level.getType());
}
}
,null,null,null,null,null,null,null,null);
return set;
}
Project Name: codecover-model Package: org.codecover.model
Source Code: XMLReader1_0_SAX.java (Click to view .java file)
Method Code:
protected void handleEndElementConditionalStatement(){
ConditionalStatementStore store=this.conditionalStatementStoreStack.pop();
ConditionalStatement statement=this.builder.createConditionalStatement(store.locationList,store.coverableItem,store.terms,store.branches,store.keyword,questionMarkOperators);
this.currentLocationReciever.pop();
StatementSequenceStore sequenceStore=this.statementSequenceStoreStack.peek();
sequenceStore.statements.add(statement);
this.idMetaDataObjectMap.put(store.internalId,statement);
}
Project Name: codecover-model Package: org.codecover.model
Source Code: XMLReader1_0_SAX.java (Click to view .java file)
Method Code:
protected void handleEndElementRootTerm(){
RootTermStore termStore=this.rootTermStoreStack.pop();
RootTerm rootTerm=this.builder.createRootTerm(termStore.term,termStore.coverableItem);
this.currentLocationReciever.pop();
String currentReciever=this.currentLocationReciever.peek();
if (currentReciever.equals(ELEMENT_CONDITIONAL_STATEMENT)) {
ConditionalStatementStore store=this.conditionalStatementStoreStack.peek();
store.terms.add(rootTerm);
}
else if (currentReciever.equals(ELEMENT_LOOPING_STATEMENT)) {
LoopStatementStore store=this.loopStatementStoreStack.peek();
store.terms.add(rootTerm);
}
else if (currentReciever.equals(ELEMENT_BASIC_STATEMENT)) {
BasicStatementStore store=this.basicStatementStore;
store.terms.add(rootTerm);
}
this.idMetaDataObjectMap.put(termStore.internalId,rootTerm);
this.idRootTermMap.put(termStore.internalId,rootTerm);
}
Project Name: codecover-model Package: org.codecover.model.extensions
Source Code: PluginManager.java (Click to view .java file)
Method Code:
public Set<PluginHandle> getPluginHandles(){
final Set<PluginHandle> result=new HashSet<PluginHandle>();
synchronized (lock) {
for ( TreeMap<Integer,LoadedPlugin> map : loadedPlugins.values()) {
for ( LoadedPlugin plugin : map.values()) {
final PluginHandle handle=plugin.handle;
if (handle != null) {
result.add(handle);
}
}
}
}
return Collections.unmodifiableSet(result);
}
Project Name: codecover-model Package: org.codecover.model.extensions
Source Code: AbstractPlugin.java (Click to view .java file)
Method Code:
private static <T>Set<T> toSet(T[] ar){
final Set<T> result=new HashSet<T>();
for ( T element : ar) {
result.add(element);
}
return Collections.unmodifiableSet(result);
}
Project Name: codecover-model Package: org.codecover.model.extensions
Source Code: AbstractPlugin.java (Click to view .java file)
Method Code:
public AbstractPlugin(String name,String description,Set<Extension<?>> extensions){
if (name == null) {
throw new NullPointerException("name == null");
}
if (description == null) {
throw new NullPointerException("description == null");
}
if (extensions == null) {
throw new NullPointerException("extensions == null");
}
this.name=name;
this.description=description;
final Map<Class<?>,Map<String,Extension<?>>> myExtensionMap=new HashMap<Class<?>,Map<String,Extension<?>>>();
for ( Extension<?> extension : extensions) {
Class<?> cl=extension.getInterface();
Map<String,Extension<?>> m=myExtensionMap.get(cl);
if (m == null) {
m=new HashMap<String,Extension<?>>();
myExtensionMap.put(cl,m);
}
m.put(extension.getName(),extension);
}
extensionMap=CollectionUtil.copyDeep(myExtensionMap);
}
Project Name: codecover-model Package: org.codecover.model.extensions
Source Code: AbstractPlugin.java (Click to view .java file)
Method Code:
public <T>Set<Extension<T>> getExtensions(Class<T> interfaceType){
final Map<String,Extension<?>> map=extensionMap.get(interfaceType);
if (map == null) {
return Collections.<Extension<T>>emptySet();
}
final Set<Extension<T>> result=new HashSet<Extension<T>>();
for ( Extension<?> extension : map.values()) {
result.add(cast(interfaceType,extension));
}
return Collections.unmodifiableSet(result);
}
Project Name: codecover-model Package: org.codecover.model.extensions
Source Code: PluginHandle.java (Click to view .java file)
Method Code:
private static Set<Extension<?>> myGetExtensions(){
final Extension<?>[] ar=(new Extension<?>[]{new AbstractExtension<Criterion>(Criterion.class,"org.codecover.model.utils.criteria.StatementCoverage"){
public Criterion getObject(){
return StatementCoverage.getInstance();
}
}
,new AbstractExtension<Criterion>(Criterion.class,"org.codecover.model.utils.criteria.BranchCoverage"){
public Criterion getObject(){
return BranchCoverage.getInstance();
}
}
,new AbstractExtension<Criterion>(Criterion.class,"org.codecover.model.utils.criteria.LoopCoverage"){
public Criterion getObject(){
return LoopCoverage.getInstance();
}
}
,new AbstractExtension<Criterion>(Criterion.class,"org.codecover.model.utils.criteria.ConditionCoverage"){
public Criterion getObject(){
return ConditionCoverage.getInstance();
}
}
,new AbstractExtension<Criterion>(Criterion.class,"org.codecover.model.utils.criteria.SynchronizedStatementCoverage"){
public Criterion getObject(){
return SynchronizedStatementCoverage.getInstance();
}
}
,new AbstractExtension<Criterion>(Criterion.class,"org.codecover.model.utils.criteria.QMOCoverage"){
public Criterion getObject(){
return QMOCoverage.getInstance();
}
}
});
final Set<Extension<?>> result=new HashSet<Extension<?>>();
for ( Extension<?> element : ar) {
result.add(element);
}
for ( String s : new String[]{"org.codecover.metrics.coverage.StatementCoverage","org.codecover.metrics.coverage.TermCoverage","org.codecover.metrics.coverage.LoopCoverage","org.codecover.metrics.coverage.BranchCoverage","org.codecover.metrics.coverage.QMOCoverage","org.codecover.metrics.coverage.SynchronizedCoverage","org.codecover.metrics.correlation.StatementCorrelation","org.codecover.metrics.correlation.ConditionCorrelation","org.codecover.metrics.correlation.LoopCorrelation","org.codecover.metrics.correlation.BranchCorrelation"}) {
try {
result.add(new DynamicReferencedExtension("org.codecover.metrics.Metric",s));
}
catch ( Exception e) {
}
}
return result;
}
Project Name: codecover-model Package: org.codecover.model.extensions
Source Code: PluginUtils.java (Click to view .java file)
Method Code:
public static <T>Set<T> getExtensionObjects(PluginManager manager,Logger logger,Class<T> interfaceType){
if (manager == null) {
throw new NullPointerException("manager == null");
}
if (logger == null) {
throw new NullPointerException("logger == null");
}
if (interfaceType == null) {
throw new NullPointerException("interfaceType == null");
}
final Set<T> result=new HashSet<T>();
for ( final Extension<T> extension : getExtensions(manager,logger,interfaceType)) {
try {
result.add(extension.getObject());
}
catch ( Exception e) {
logger.error("Error creating object for extension " + extension.getClass(),e);
}
}
return Collections.unmodifiableSet(result);
}
Project Name: codecover-model Package: org.codecover.model.extensions
Source Code: PluginUtils.java (Click to view .java file)
Method Code:
public static <T>Set<Extension<T>> getExtensions(PluginManager manager,Logger logger,Class<T> interfaceType){
if (manager == null) {
throw new NullPointerException("manager == null");
}
if (logger == null) {
throw new NullPointerException("logger == null");
}
if (interfaceType == null) {
throw new NullPointerException("interfaceType == null");
}
final Set<Extension<T>> result=new HashSet<Extension<T>>();
for ( final PluginHandle handle : manager.getPluginHandles()) {
try {
result.addAll(handle.getPlugin().getExtensions(interfaceType));
}
catch ( PluginLoadException e) {
logger.error("Error loading extensions of plugin " + handle.getPluginName() + ": "+ e.getMessage(),e);
}
}
return Collections.unmodifiableSet(result);
}
Project Name: codecover-model Package: org.codecover.model.mast
Source Code: LoopingStatement.java (Click to view .java file)
Method Code:
LoopingStatement(LocationList location,CoverableItem coverableItem,Set<RootTerm> terms,StatementSequence body,Location keyword,CoverableItem neverExecutedItem,CoverableItem onceExecutedItem,CoverableItem multipleExecutedItem,boolean optionalBodyExecution,Set<QuestionMarkOperator> questionMarkOperators){
super(location,keyword,coverableItem,terms,questionMarkOperators);
if (body == null) {
throw new NullPointerException("body == null");
}
if (neverExecutedItem == null) {
throw new NullPointerException("neverExecutedItem == null");
}
if (onceExecutedItem == null) {
throw new NullPointerException("onceExecutedItem == null");
}
if (multipleExecutedItem == null) {
throw new NullPointerException("multipleExecutedItem == null");
}
this.body=body;
this.neverExecutedItem=neverExecutedItem;
this.onceExecutedItem=onceExecutedItem;
this.multipleExecutedItem=multipleExecutedItem;
this.optionalBodyExecution=optionalBodyExecution;
}
Project Name: codecover-model Package: org.codecover.model.mast
Source Code: LoopingStatement.java (Click to view .java file)
Method Code:
LoopingStatement(LocationList location,CoverableItem coverableItem,Set<RootTerm> terms,StatementSequence body,Location keyword,CoverableItem neverExecutedItem,CoverableItem onceExecutedItem,CoverableItem multipleExecutedItem,boolean optionalBodyExecution,Set<QuestionMarkOperator> questionMarkOperators){
super(location,keyword,coverableItem,terms,questionMarkOperators);
if (body == null) {
throw new NullPointerException("body == null");
}
if (neverExecutedItem == null) {
throw new NullPointerException("neverExecutedItem == null");
}
if (onceExecutedItem == null) {
throw new NullPointerException("onceExecutedItem == null");
}
if (multipleExecutedItem == null) {
throw new NullPointerException("multipleExecutedItem == null");
}
this.body=body;
this.neverExecutedItem=neverExecutedItem;
this.onceExecutedItem=onceExecutedItem;
this.multipleExecutedItem=multipleExecutedItem;
this.optionalBodyExecution=optionalBodyExecution;
}
Project Name: codecover-model Package: org.codecover.model.mast
Source Code: Internal.java (Click to view .java file)
Method Code:
/**
* Creates and returns an instance of a {@link LoopingStatement} containing
* the given data.
* @param locationthe {@link LocationList}, specifing the location of the{@link LoopingStatement} in its {@link SourceFile}
* @param coverableItemthe {@link CoverableItem} of the {@link LoopingStatement}
* @param termsthe {@link RootTerm}s associated with this{@link LoopingStatement}
* @param statementSequencethe {@link StatementSequence} contained in this{@link LoopingStatement}
* @param keywordthe {@link Location}, specifing the location of the keyword
* of the {@link LoopingStatement} in its {@link SourceFile}
* @param neverExecutedItemthe {@link CoverableItem} of the {@link LoopingStatement},
* that represents the number times the loop was not traversed
* @param onceExecutedItemthe {@link CoverableItem} of the {@link LoopingStatement},
* that represents the number times the loop was traversed only
* once
* @param multipleExecutedItemthe {@link CoverableItem} of the {@link LoopingStatement},
* that represents the number times the loop was traversed
* multiple times
* @param optionalBodyExecutionindicates, whether or not the body of the loop can be skipped
* entirely or is executed at least once, as it it the case with
* the "do ... while()" construct
* @param loggerthe logger to be used
* @return the created {@link LoopingStatement}
*/
public static LoopingStatement createLoopingStatement(LocationList location,CoverableItem coverableItem,Set<RootTerm> terms,StatementSequence statementSequence,Location keyword,CoverableItem neverExecutedItem,CoverableItem onceExecutedItem,CoverableItem multipleExecutedItem,boolean optionalBodyExecution,Set<QuestionMarkOperator> questionMarkOperators,Logger logger){
LoopingStatement loopingStatement=new LoopingStatement(location,coverableItem,terms,statementSequence,keyword,neverExecutedItem,onceExecutedItem,multipleExecutedItem,optionalBodyExecution,questionMarkOperators);
return loopingStatement;
}
Project Name: codecover-model Package: org.codecover.model.mast
Source Code: Internal.java (Click to view .java file)
Method Code:
/**
* Creates and returns an instance of a {@link LoopingStatement} containing
* the given data.
* @param locationthe {@link LocationList}, specifing the location of the{@link LoopingStatement} in its {@link SourceFile}
* @param coverableItemthe {@link CoverableItem} of the {@link LoopingStatement}
* @param termsthe {@link RootTerm}s associated with this{@link LoopingStatement}
* @param statementSequencethe {@link StatementSequence} contained in this{@link LoopingStatement}
* @param keywordthe {@link Location}, specifing the location of the keyword
* of the {@link LoopingStatement} in its {@link SourceFile}
* @param neverExecutedItemthe {@link CoverableItem} of the {@link LoopingStatement},
* that represents the number times the loop was not traversed
* @param onceExecutedItemthe {@link CoverableItem} of the {@link LoopingStatement},
* that represents the number times the loop was traversed only
* once
* @param multipleExecutedItemthe {@link CoverableItem} of the {@link LoopingStatement},
* that represents the number times the loop was traversed
* multiple times
* @param optionalBodyExecutionindicates, whether or not the body of the loop can be skipped
* entirely or is executed at least once, as it it the case with
* the "do ... while()" construct
* @param loggerthe logger to be used
* @return the created {@link LoopingStatement}
*/
public static LoopingStatement createLoopingStatement(LocationList location,CoverableItem coverableItem,Set<RootTerm> terms,StatementSequence statementSequence,Location keyword,CoverableItem neverExecutedItem,CoverableItem onceExecutedItem,CoverableItem multipleExecutedItem,boolean optionalBodyExecution,Set<QuestionMarkOperator> questionMarkOperators,Logger logger){
LoopingStatement loopingStatement=new LoopingStatement(location,coverableItem,terms,statementSequence,keyword,neverExecutedItem,onceExecutedItem,multipleExecutedItem,optionalBodyExecution,questionMarkOperators);
return loopingStatement;
}
Project Name: codecover-model Package: org.codecover.model.mast
Source Code: ConditionalStatement.java (Click to view .java file)
Method Code:
ConditionalStatement(LocationList location,CoverableItem coverableItem,Set<RootTerm> terms,List<Branch> branches,Location keyword,Set<QuestionMarkOperator> questionMarkOperators){
super(location,keyword,coverableItem,terms,questionMarkOperators);
if (branches == null) {
throw new NullPointerException("branches == null");
}
this.branches=CollectionUtil.copy(branches);
}
Project Name: codecover-model Package: org.codecover.model.mast
Source Code: ConditionalStatement.java (Click to view .java file)
Method Code:
ConditionalStatement(LocationList location,CoverableItem coverableItem,Set<RootTerm> terms,List<Branch> branches,Location keyword,Set<QuestionMarkOperator> questionMarkOperators){
super(location,keyword,coverableItem,terms,questionMarkOperators);
if (branches == null) {
throw new NullPointerException("branches == null");
}
this.branches=CollectionUtil.copy(branches);
}
Project Name: codecover-model Package: org.codecover.model.mast
Source Code: BasicStatement.java (Click to view .java file)
Method Code:
BasicStatement(LocationList location,CoverableItem coverableItem,Set<RootTerm> terms,Set<QuestionMarkOperator> questionMarkOperators){
super(location,coverableItem,terms,questionMarkOperators);
}
Project Name: codecover-model Package: org.codecover.model.mast
Source Code: BasicStatement.java (Click to view .java file)
Method Code:
BasicStatement(LocationList location,CoverableItem coverableItem,Set<RootTerm> terms,Set<QuestionMarkOperator> questionMarkOperators){
super(location,coverableItem,terms,questionMarkOperators);
}
Project Name: codecover-model Package: org.codecover.model.mast
Source Code: Statement.java (Click to view .java file)
Method Code:
/**
* @return the terms
*/
public Set<RootTerm> getTerms(){
return this.terms;
}
Project Name: codecover-model Package: org.codecover.model.mast
Source Code: Statement.java (Click to view .java file)
Method Code:
/**
* @return the questionMarkOperators
*/
public Set<QuestionMarkOperator> getQuestionMarkOperators(){
return this.questionMarkOperators;
}
Project Name: codecover-model Package: org.codecover.model.mast
Source Code: ComplexStatement.java (Click to view .java file)
Method Code:
protected ComplexStatement(LocationList location,Location keyword,CoverableItem coverableItem,Set<RootTerm> terms,Set<QuestionMarkOperator> questionMarkOperators){
super(location,coverableItem,terms,questionMarkOperators);
if (keyword == null) {
throw new NullPointerException("keyword == null");
}
this.keyword=keyword;
}
Project Name: codecover-model Package: org.codecover.model.mast
Source Code: ComplexStatement.java (Click to view .java file)
Method Code:
protected ComplexStatement(LocationList location,Location keyword,CoverableItem coverableItem,Set<RootTerm> terms,Set<QuestionMarkOperator> questionMarkOperators){
super(location,coverableItem,terms,questionMarkOperators);
if (keyword == null) {
throw new NullPointerException("keyword == null");
}
this.keyword=keyword;
}
Project Name: codecover-model Package: org.codecover.model.mast
Source Code: SynchronizedStatement.java (Click to view .java file)
Method Code:
public SynchronizedStatement(LocationList location,CoverableItem coverableItem,Location keyword,CoverableItem coverableItem0,CoverableItem coverableItem1,CoverableItem coverableItem2,Set<QuestionMarkOperator> questionMarkOperators){
super(location,keyword,coverableItem,null,questionMarkOperators);
if (coverableItem0 == null || coverableItem1 == null || coverableItem2 == null) {
throw new NullPointerException("coverableItem == null");
}
this.coverableItem0=coverableItem0;
this.coverableItem1=coverableItem1;
this.coverableItem2=coverableItem2;
}
Project Name: codecover-model Package: org.codecover.model.utils
Source Code: CollectionUtil.java (Click to view .java file)
Method Code:
/**
* Copies the given {@link Set} into a new {@link Set}.<br>
* @param<T>
* the type of the entries of the set
* @param datathe given set
* @return If the given set was empty, a {@link Collections#emptySet()} is
* returned<br>
* If the given set contained only one element, a{@link Collections#singleton(Object)}, containing said element,
* is returned <br>
* If the given set contained more than one element, a{@link Collections#unmodifiableSet(Set)}, containing the
* elements of the given set, is returned.
*/
public static <T>Set<T> copy(Set<T> data){
final int size=data.size();
switch (size) {
case 0:
return Collections.emptySet();
case 1:
return Collections.singleton(data.iterator().next());
default :
return Collections.unmodifiableSet(new HashSet<T>(data));
}
}
Project Name: eclemma-core Package: com.mountainminds.eclemma.core
Source Code: ScopeUtils.java (Click to view .java file)
Method Code:
/**
* Remove all JRE runtime entries from the given set
* @param scopeset to filter
* @return filtered set without JRE runtime entries
*/
public static Set<IPackageFragmentRoot> filterJREEntries(Collection<IPackageFragmentRoot> scope) throws JavaModelException {
final Set<IPackageFragmentRoot> filtered=new HashSet<IPackageFragmentRoot>();
for ( final IPackageFragmentRoot root : scope) {
final IClasspathEntry entry=root.getRawClasspathEntry();
switch (entry.getEntryKind()) {
case IClasspathEntry.CPE_SOURCE:
case IClasspathEntry.CPE_LIBRARY:
case IClasspathEntry.CPE_VARIABLE:
filtered.add(root);
break;
case IClasspathEntry.CPE_CONTAINER:
IClasspathContainer container=JavaCore.getClasspathContainer(entry.getPath(),root.getJavaProject());
if (container != null && container.getKind() == IClasspathContainer.K_APPLICATION) {
filtered.add(root);
}
break;
}
}
return filtered;
}
Project Name: eclemma-core Package: com.mountainminds.eclemma.core.launching
Source Code: EclipseLauncher.java (Click to view .java file)
Method Code:
public Set<IPackageFragmentRoot> getOverallScope(ILaunchConfiguration configuration) throws CoreException {
final IJavaModel model=JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());
final Set<IPackageFragmentRoot> result=new HashSet<IPackageFragmentRoot>();
for ( final IJavaProject project : model.getJavaProjects()) {
if (project.getProject().hasNature(PLUGIN_NATURE)) {
result.addAll(Arrays.asList(project.getPackageFragmentRoots()));
}
}
return ScopeUtils.filterJREEntries(result);
}
Project Name: eclemma-core Package: com.mountainminds.eclemma.internal.core
Source Code: CoverageSession.java (Click to view .java file)
Method Code:
public Set<IPackageFragmentRoot> getScope(){
return scope;
}
Project Name: eclemma-core Package: com.mountainminds.eclemma.internal.core
Source Code: SessionImporter.java (Click to view .java file)
Method Code:
public void importSession(IProgressMonitor monitor) throws CoreException {
monitor.beginTask(CoreMessages.ImportingSession_task,1);
final CoverageSession session=new CoverageSession(description,scope,getSessionData(),null);
sessionManager.addSession(session,true,null);
monitor.done();
}
Project Name: eclemma-core Package: com.mountainminds.eclemma.internal.core
Source Code: SessionManager.java (Click to view .java file)
Method Code:
public ICoverageSession mergeSessions(Collection<ICoverageSession> sessions,String description,IProgressMonitor monitor) throws CoreException {
monitor.beginTask(CoreMessages.MergingCoverageSessions_task,sessions.size());
final Set<IPackageFragmentRoot> scope=new HashSet<IPackageFragmentRoot>();
final Set<ILaunchConfiguration> launches=new HashSet<ILaunchConfiguration>();
final MemoryExecutionDataSource memory=new MemoryExecutionDataSource();
for ( ICoverageSession session : sessions) {
scope.addAll(session.getScope());
if (session.getLaunchConfiguration() != null) {
launches.add(session.getLaunchConfiguration());
}
session.accept(memory,memory);
monitor.worked(1);
}
final IExecutionDataSource executionDataSource=executiondatafiles.newFile(memory);
final ILaunchConfiguration launchconfiguration=launches.size() == 1 ? launches.iterator().next() : null;
final ICoverageSession merged=new CoverageSession(description,scope,executionDataSource,launchconfiguration);
synchronized (lock) {
addSession(merged,true,null);
for ( ICoverageSession session : sessions) {
removeSession(session);
}
}
monitor.done();
return merged;
}
Project Name: eclemma-core Package: com.mountainminds.eclemma.internal.core
Source Code: SessionManager.java (Click to view .java file)
Method Code:
public ICoverageSession mergeSessions(Collection<ICoverageSession> sessions,String description,IProgressMonitor monitor) throws CoreException {
monitor.beginTask(CoreMessages.MergingCoverageSessions_task,sessions.size());
final Set<IPackageFragmentRoot> scope=new HashSet<IPackageFragmentRoot>();
final Set<ILaunchConfiguration> launches=new HashSet<ILaunchConfiguration>();
final MemoryExecutionDataSource memory=new MemoryExecutionDataSource();
for ( ICoverageSession session : sessions) {
scope.addAll(session.getScope());
if (session.getLaunchConfiguration() != null) {
launches.add(session.getLaunchConfiguration());
}
session.accept(memory,memory);
monitor.worked(1);
}
final IExecutionDataSource executionDataSource=executiondatafiles.newFile(memory);
final ILaunchConfiguration launchconfiguration=launches.size() == 1 ? launches.iterator().next() : null;
final ICoverageSession merged=new CoverageSession(description,scope,executionDataSource,launchconfiguration);
synchronized (lock) {
addSession(merged,true,null);
for ( ICoverageSession session : sessions) {
removeSession(session);
}
}
monitor.done();
return merged;
}
Project Name: eclemma-core Package: com.mountainminds.eclemma.internal.core
Source Code: DefaultScopeFilter.java (Click to view .java file)
Method Code:
/**
* Returns a filtered copy of the given {@link IClassFiles} set.
* @param classfiles {@link IClassFiles} to filter
* @param configurationcontext information
* @return filtered set
* @throws CoreExceptionmay occur when accessing the Java model
*/
public Set<IPackageFragmentRoot> filter(final Set<IPackageFragmentRoot> scope,final ILaunchConfiguration configuration) throws CoreException {
final Set<IPackageFragmentRoot> filtered=new HashSet<IPackageFragmentRoot>(scope);
if (preferences.getDefaultScopeSourceFoldersOnly()) {
sourceFoldersOnly(filtered);
}
if (preferences.getDefaultScopeSameProjectOnly()) {
sameProjectOnly(filtered,configuration);
}
String filter=preferences.getDefaultScopeFilter();
if (filter != null && filter.length() > 0) {
matchingPathsOnly(filtered,filter);
}
return filtered;
}