當前位置: 首頁>>代碼示例>>Java>>正文


Java SearchUtils.getCompilationUnit方法代碼示例

本文整理匯總了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);
  }
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:18,代碼來源:CuCollectingSearchRequestor.java

示例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);
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:8,代碼來源:RenamePackageProcessor.java

示例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;
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:13,代碼來源:MoveStaticMembersProcessor.java

示例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);
	}
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:18,代碼來源:CuCollectingSearchRequestor.java

示例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()]);
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:37,代碼來源:TargetProvider.java

示例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);
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:6,代碼來源:RenameAnalyzeUtil.java

示例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()]);
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:51,代碼來源:TargetProvider.java

示例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]);
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:5,代碼來源:SearchResultGroup.java

示例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);
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:7,代碼來源:RenameAnalyzeUtil.java

示例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);
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:7,代碼來源:RenamePackageProcessor.java

示例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]);
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:6,代碼來源:SearchResultGroup.java


注:本文中的org.eclipse.jdt.internal.corext.util.SearchUtils.getCompilationUnit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。