本文整理汇总了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]);
}