当前位置: 首页>>代码示例>>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;未经允许,请勿转载。