本文整理匯總了Java中org.eclipse.jdt.internal.corext.util.SearchUtils.getCompilationUnit方法的典型用法代碼示例。如果您正苦於以下問題:Java SearchUtils.getCompilationUnit方法的具體用法?Java SearchUtils.getCompilationUnit怎麽用?Java SearchUtils.getCompilationUnit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jdt.internal.corext.util.SearchUtils
的用法示例。
在下文中一共展示了SearchUtils.getCompilationUnit方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: acceptSearchMatch
import org.eclipse.jdt.internal.corext.util.SearchUtils; //導入方法依賴的package包/類
/**
* This is an internal method. Do not call from subclasses! Use {@link #collectMatch(SearchMatch)}
* instead.
*
* @param match
* @throws CoreException
* @deprecated
*/
@Override
public final void acceptSearchMatch(SearchMatch match) throws CoreException {
if (filterMatch(match)) return;
ICompilationUnit unit = SearchUtils.getCompilationUnit(match);
if (unit != null) {
acceptSearchMatch(unit, match);
}
}
示例2: getNormalizedTypeReference
import org.eclipse.jdt.internal.corext.util.SearchUtils; //導入方法依賴的package包/類
private static String getNormalizedTypeReference(SearchMatch searchResult)
throws JavaModelException {
ICompilationUnit cu = SearchUtils.getCompilationUnit(searchResult);
String reference = cu.getBuffer().getText(searchResult.getOffset(), searchResult.getLength());
// reference may be package-qualified -> normalize (remove comments, etc.):
return CommentAnalyzer.normalizeReference(reference);
}
示例3: isWithinMemberToMove
import org.eclipse.jdt.internal.corext.util.SearchUtils; //導入方法依賴的package包/類
private boolean isWithinMemberToMove(SearchMatch result) throws JavaModelException {
ICompilationUnit referenceCU= SearchUtils.getCompilationUnit(result);
if (! referenceCU.equals(fSource.getCu()))
return false;
int referenceStart= result.getOffset();
for (int i= 0; i < fMembersToMove.length; i++) {
ISourceRange range= fMembersToMove[i].getSourceRange();
if (range.getOffset() <= referenceStart && range.getOffset() + range.getLength() >= referenceStart)
return true;
}
return false;
}
示例4: acceptSearchMatch
import org.eclipse.jdt.internal.corext.util.SearchUtils; //導入方法依賴的package包/類
/**
* This is an internal method. Do not call from subclasses!
* Use {@link #collectMatch(SearchMatch)} instead.
* @param match
* @throws CoreException
* @deprecated
*/
@Override
public final void acceptSearchMatch(SearchMatch match) throws CoreException {
if (filterMatch(match))
return;
ICompilationUnit unit= SearchUtils.getCompilationUnit(match);
if (unit != null) {
acceptSearchMatch(unit, match);
}
}
示例5: getAffectedCompilationUnits
import org.eclipse.jdt.internal.corext.util.SearchUtils; //導入方法依賴的package包/類
@Override
public ICompilationUnit[] getAffectedCompilationUnits(final RefactoringStatus status, ReferencesInBinaryContext binaryRefs, IProgressMonitor pm) throws CoreException {
IMethod method= (IMethod)fMethodBinding.getJavaElement();
Assert.isTrue(method != null);
SearchPattern pattern= SearchPattern.createPattern(method, IJavaSearchConstants.REFERENCES, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE);
IJavaSearchScope scope= RefactoringScopeFactory.create(method, true, false);
final HashSet<ICompilationUnit> affectedCompilationUnits= new HashSet<ICompilationUnit>();
CollectingSearchRequestor requestor= new CollectingSearchRequestor(binaryRefs) {
private ICompilationUnit fLastCU;
@Override
public void acceptSearchMatch(SearchMatch match) throws CoreException {
if (filterMatch(match))
return;
if (match.isInsideDocComment())
return; // TODO: should warn user (with something like a ReferencesInBinaryContext)
ICompilationUnit unit= SearchUtils.getCompilationUnit(match);
if (match.getAccuracy() == SearchMatch.A_INACCURATE) {
if (unit != null) {
status.addError(RefactoringCoreMessages.TargetProvider_inaccurate_match,
JavaStatusContext.create(unit, new SourceRange(match.getOffset(), match.getLength())));
} else {
status.addError(RefactoringCoreMessages.TargetProvider_inaccurate_match);
}
} else if (unit != null) {
if (! unit.equals(fLastCU)) {
fLastCU= unit;
affectedCompilationUnits.add(unit);
}
}
}
};
new SearchEngine().search(pattern, SearchUtils.getDefaultSearchParticipants(), scope, requestor, new SubProgressMonitor(pm, 1));
return affectedCompilationUnits.toArray(new ICompilationUnit[affectedCompilationUnits.size()]);
}
示例6: getTextChange
import org.eclipse.jdt.internal.corext.util.SearchUtils; //導入方法依賴的package包/類
private static TextChange getTextChange(SearchMatch searchResult, TextChangeManager manager) {
ICompilationUnit cu = SearchUtils.getCompilationUnit(searchResult);
if (cu == null) return null;
return manager.get(cu);
}
示例7: getAffectedCompilationUnits
import org.eclipse.jdt.internal.corext.util.SearchUtils; //導入方法依賴的package包/類
@Override
public ICompilationUnit[] getAffectedCompilationUnits(
final RefactoringStatus status, ReferencesInBinaryContext binaryRefs, IProgressMonitor pm)
throws CoreException {
IMethod method = (IMethod) fMethodBinding.getJavaElement();
Assert.isTrue(method != null);
SearchPattern pattern =
SearchPattern.createPattern(
method, IJavaSearchConstants.REFERENCES, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE);
IJavaSearchScope scope = RefactoringScopeFactory.create(method, true, false);
final HashSet<ICompilationUnit> affectedCompilationUnits = new HashSet<ICompilationUnit>();
CollectingSearchRequestor requestor =
new CollectingSearchRequestor(binaryRefs) {
private ICompilationUnit fLastCU;
@Override
public void acceptSearchMatch(SearchMatch match) throws CoreException {
if (filterMatch(match)) return;
if (match.isInsideDocComment())
return; // TODO: should warn user (with something like a ReferencesInBinaryContext)
ICompilationUnit unit = SearchUtils.getCompilationUnit(match);
if (match.getAccuracy() == SearchMatch.A_INACCURATE) {
if (unit != null) {
status.addError(
RefactoringCoreMessages.TargetProvider_inaccurate_match,
JavaStatusContext.create(
unit, new SourceRange(match.getOffset(), match.getLength())));
} else {
status.addError(RefactoringCoreMessages.TargetProvider_inaccurate_match);
}
} else if (unit != null) {
if (!unit.equals(fLastCU)) {
fLastCU = unit;
affectedCompilationUnits.add(unit);
}
}
}
};
new SearchEngine()
.search(
pattern,
SearchUtils.getDefaultSearchParticipants(),
scope,
requestor,
new SubProgressMonitor(pm, 1));
return affectedCompilationUnits.toArray(
new ICompilationUnit[affectedCompilationUnits.size()]);
}
示例8: getCompilationUnit
import org.eclipse.jdt.internal.corext.util.SearchUtils; //導入方法依賴的package包/類
public ICompilationUnit getCompilationUnit() {
if (getSearchResults() == null || getSearchResults().length == 0) return null;
return SearchUtils.getCompilationUnit(getSearchResults()[0]);
}
示例9: getTextChange
import org.eclipse.jdt.internal.corext.util.SearchUtils; //導入方法依賴的package包/類
private static TextChange getTextChange(SearchMatch searchResult, TextChangeManager manager) {
ICompilationUnit cu= SearchUtils.getCompilationUnit(searchResult);
if (cu == null)
return null;
return manager.get(cu);
}
示例10: getNormalizedTypeReference
import org.eclipse.jdt.internal.corext.util.SearchUtils; //導入方法依賴的package包/類
private static String getNormalizedTypeReference(SearchMatch searchResult) throws JavaModelException {
ICompilationUnit cu= SearchUtils.getCompilationUnit(searchResult);
String reference= cu.getBuffer().getText(searchResult.getOffset(), searchResult.getLength());
//reference may be package-qualified -> normalize (remove comments, etc.):
return CommentAnalyzer.normalizeReference(reference);
}
示例11: getCompilationUnit
import org.eclipse.jdt.internal.corext.util.SearchUtils; //導入方法依賴的package包/類
public ICompilationUnit getCompilationUnit(){
if (getSearchResults() == null || getSearchResults().length == 0)
return null;
return SearchUtils.getCompilationUnit(getSearchResults()[0]);
}