]> git.uio.no Git - ifi-stolz-refaktor.git/blob - case-study/jdt-before/core refactoring/org/eclipse/jdt/internal/corext/refactoring/base/ReferencesInBinaryContext.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-before / core refactoring / org / eclipse / jdt / internal / corext / refactoring / base / ReferencesInBinaryContext.java
1 /*******************************************************************************
2  * Copyright (c) 2008, 2011 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package org.eclipse.jdt.internal.corext.refactoring.base;
12
13 import java.util.ArrayList;
14 import java.util.List;
15
16 import org.eclipse.ltk.core.refactoring.RefactoringStatus;
17 import org.eclipse.ltk.core.refactoring.RefactoringStatusContext;
18
19 import org.eclipse.jdt.core.search.SearchMatch;
20
21 import org.eclipse.jdt.internal.corext.refactoring.RefactoringCoreMessages;
22
23 public class ReferencesInBinaryContext extends RefactoringStatusContext {
24
25         private List<SearchMatch> fMatches= new ArrayList<SearchMatch>();
26
27         private final String fDescription;
28
29         public ReferencesInBinaryContext(String description) {
30                 fDescription= description;
31         }
32
33         public String getDescription() {
34                 return fDescription;
35         }
36
37
38         public void add(SearchMatch match) {
39                 fMatches.add(match);
40         }
41
42         public List<SearchMatch> getMatches() {
43                 return fMatches;
44         }
45
46         /*
47          * @see org.eclipse.ltk.core.refactoring.RefactoringStatusContext#getCorrespondingElement()
48          */
49         @Override
50         public Object getCorrespondingElement() {
51                 return null;
52         }
53
54         public void addErrorIfNecessary(RefactoringStatus status) {
55                 if (getMatches().size() != 0) {
56                         status.addError(RefactoringCoreMessages.ReferencesInBinaryContext_binaryRefsNotUpdated, this);
57                 }
58         }
59
60         @Override
61         public String toString() {
62                 return fDescription + " (" + fMatches.size() + " matches)"; //$NON-NLS-1$ //$NON-NLS-2$
63         }
64
65 }