当前位置: 首页>>代码示例>>Java>>正文


Java SearchPattern.createOrPattern方法代码示例

本文整理汇总了Java中org.eclipse.jdt.core.search.SearchPattern.createOrPattern方法的典型用法代码示例。如果您正苦于以下问题:Java SearchPattern.createOrPattern方法的具体用法?Java SearchPattern.createOrPattern怎么用?Java SearchPattern.createOrPattern使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.core.search.SearchPattern的用法示例。


在下文中一共展示了SearchPattern.createOrPattern方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createOccurrenceSearchPattern

import org.eclipse.jdt.core.search.SearchPattern; //导入方法依赖的package包/类
protected SearchPattern createOccurrenceSearchPattern(IJavaElement[] elements) throws CoreException {
	if (elements == null || elements.length == 0) {
		return null;
	}
	Set<IJavaElement> set = new HashSet<>(Arrays.asList(elements));
	Iterator<IJavaElement> iter = set.iterator();
	IJavaElement first = iter.next();
	SearchPattern pattern = SearchPattern.createPattern(first, IJavaSearchConstants.ALL_OCCURRENCES);
	if (pattern == null) {
		throw new CoreException(Status.CANCEL_STATUS);
	}
	while (iter.hasNext()) {
		IJavaElement each = iter.next();
		SearchPattern nextPattern = SearchPattern.createPattern(each, IJavaSearchConstants.ALL_OCCURRENCES);
		if (nextPattern == null) {
			throw new CoreException(Status.CANCEL_STATUS);
		}
		pattern = SearchPattern.createOrPattern(pattern, nextPattern);
	}
	return pattern;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:22,代码来源:RenameProcessor.java

示例2: setPattern

import org.eclipse.jdt.core.search.SearchPattern; //导入方法依赖的package包/类
/**
 * Sets the search pattern to be used during search.
 *
 * <p>This method must be called before {@link
 * RefactoringSearchEngine2#searchPattern(IProgressMonitor)}
 *
 * @param elements the set of elements
 * @param limitTo determines the nature of the expected matches. This is a combination of {@link
 *     org.eclipse.jdt.core.search .IJavaSearchConstants}.
 */
public final void setPattern(final IJavaElement[] elements, final int limitTo) {
  Assert.isNotNull(elements);
  Assert.isTrue(elements.length > 0);
  SearchPattern pattern =
      SearchPattern.createPattern(elements[0], limitTo, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE);
  IJavaElement element = null;
  for (int index = 1; index < elements.length; index++) {
    element = elements[index];
    pattern =
        SearchPattern.createOrPattern(
            pattern,
            SearchPattern.createPattern(
                element, limitTo, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE));
  }
  setPattern(pattern);
}
 
开发者ID:eclipse,项目名称:che,代码行数:27,代码来源:RefactoringSearchEngine2.java

示例3: createAnyFieldPattern

import org.eclipse.jdt.core.search.SearchPattern; //导入方法依赖的package包/类
private static SearchPattern createAnyFieldPattern(IType[] types) {
    if (types.length == 0) {
        return createAnyFieldPattern();
    }
    SearchPattern result = null;
    for (IType type : types) {
        SearchPattern searchPattern = SearchPattern.createPattern(type.getFullyQualifiedName()
                + ".*", IJavaSearchConstants.FIELD, IJavaSearchConstants.DECLARATIONS,
                SearchPattern.R_PATTERN_MATCH | SearchPattern.R_CASE_SENSITIVE);
        if(result == null){
            result = searchPattern;
        } else {
            result = SearchPattern.createOrPattern(result, searchPattern);
        }
    }
    return result;
}
 
开发者ID:iloveeclipse,项目名称:datahierarchy,代码行数:18,代码来源:SearchHelper.java

示例4: createOrPattern

import org.eclipse.jdt.core.search.SearchPattern; //导入方法依赖的package包/类
public static SearchPattern createOrPattern(IJavaElement[] elements, int limitTo) {
	if (elements == null || elements.length == 0)
		return null;
	Set<IJavaElement> set= new HashSet<IJavaElement>(Arrays.asList(elements));
	Iterator<IJavaElement> iter= set.iterator();
	IJavaElement first= iter.next();
	SearchPattern pattern= SearchPattern.createPattern(first, limitTo, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE);
	if (pattern == null) // check for bug 90138
		throw new IllegalArgumentException("Invalid java element: " + first.getHandleIdentifier() + "\n" + first.toString()); //$NON-NLS-1$ //$NON-NLS-2$
	while(iter.hasNext()){
		IJavaElement each= iter.next();
		SearchPattern nextPattern= SearchPattern.createPattern(each, limitTo, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE);
		if (nextPattern == null) // check for bug 90138
			throw new IllegalArgumentException("Invalid java element: " + each.getHandleIdentifier() + "\n" + each.toString()); //$NON-NLS-1$ //$NON-NLS-2$
		pattern= SearchPattern.createOrPattern(pattern, nextPattern);
	}
	return pattern;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:19,代码来源:RefactoringSearchEngine.java

示例5: createSearchPattern

import org.eclipse.jdt.core.search.SearchPattern; //导入方法依赖的package包/类
private static SearchPattern createSearchPattern(IType type) throws JavaModelException {
  SearchPattern pattern =
      SearchPattern.createPattern(
          type, IJavaSearchConstants.ALL_OCCURRENCES, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE);
  IMethod[] constructors = JavaElementUtil.getAllConstructors(type);
  if (constructors.length == 0) return pattern;
  SearchPattern constructorDeclarationPattern =
      RefactoringSearchEngine.createOrPattern(constructors, IJavaSearchConstants.DECLARATIONS);
  return SearchPattern.createOrPattern(pattern, constructorDeclarationPattern);
}
 
开发者ID:eclipse,项目名称:che,代码行数:11,代码来源:CreateCopyOfCompilationUnitChange.java

示例6: createOrPattern

import org.eclipse.jdt.core.search.SearchPattern; //导入方法依赖的package包/类
public static SearchPattern createOrPattern(IJavaElement[] elements, int limitTo) {
  if (elements == null || elements.length == 0) return null;
  Set<IJavaElement> set = new HashSet<IJavaElement>(Arrays.asList(elements));
  Iterator<IJavaElement> iter = set.iterator();
  IJavaElement first = iter.next();
  SearchPattern pattern =
      SearchPattern.createPattern(first, limitTo, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE);
  if (pattern == null) // check for bug 90138
  throw new IllegalArgumentException(
        "Invalid java element: "
            + first.getHandleIdentifier()
            + "\n"
            + first.toString()); // $NON-NLS-1$ //$NON-NLS-2$
  while (iter.hasNext()) {
    IJavaElement each = iter.next();
    SearchPattern nextPattern =
        SearchPattern.createPattern(each, limitTo, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE);
    if (nextPattern == null) // check for bug 90138
    throw new IllegalArgumentException(
          "Invalid java element: "
              + each.getHandleIdentifier()
              + "\n"
              + each.toString()); // $NON-NLS-1$ //$NON-NLS-2$
    pattern = SearchPattern.createOrPattern(pattern, nextPattern);
  }
  return pattern;
}
 
开发者ID:eclipse,项目名称:che,代码行数:28,代码来源:RefactoringSearchEngine.java

示例7: getExistingCategories

import org.eclipse.jdt.core.search.SearchPattern; //导入方法依赖的package包/类
private List<String> getExistingCategories() {
	if(existingCategories==null) {
		final Set<String> categories = new TreeSet<String>();		
		if(selectedJavaProject!=null) {
			SearchRequestor requestor = new SearchRequestor() {
				@Override
				public void acceptSearchMatch(SearchMatch match) throws CoreException {
					if(match.getElement() instanceof IType) {
						String fqn = ((IType) match.getElement()).getFullyQualifiedName();
						if(!fqn.startsWith("net.sf.jasperreports.functions.standard")) {
							// avoid to propose standard functions categories
							categories.add(fqn);
						}
					}
				}
			};
			IJavaElement[] elements= new IJavaElement[] { selectedJavaProject };
			IJavaSearchScope scope= SearchEngine.createJavaSearchScope(elements);
			int matchRule= SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE;
			SearchPattern fullAnnotationPattern= SearchPattern.createPattern(
					"net.sf.jasperreports.functions.annotations.FunctionCategory", IJavaSearchConstants.ANNOTATION_TYPE, IJavaSearchConstants.ANNOTATION_TYPE_REFERENCE, matchRule);
			SearchPattern simpleNamePattern= SearchPattern.createPattern(
					"FunctionCategory", IJavaSearchConstants.ANNOTATION_TYPE, IJavaSearchConstants.ANNOTATION_TYPE_REFERENCE, matchRule);
			SearchPattern annotationsPattern= SearchPattern.createOrPattern(fullAnnotationPattern, simpleNamePattern);
			SearchParticipant[] searchParticipants= new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() };
			try {
				new SearchEngine().search(annotationsPattern, searchParticipants, scope, requestor,new NullProgressMonitor());
			} catch (CoreException e) {
			}
		}
		existingCategories = new ArrayList<String>(categories);
		((NewFunctionsLibraryWizard)getWizard()).setAvailableCategories(existingCategories);
	}
	return existingCategories;
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:36,代码来源:FunctionsLibraryInformationPage.java

示例8: setPattern

import org.eclipse.jdt.core.search.SearchPattern; //导入方法依赖的package包/类
/**
 * Sets the search pattern to be used during search.
 * <p>
 * This method must be called before {@link RefactoringSearchEngine2#searchPattern(IProgressMonitor)}
 *
 * @param elements the set of elements
 * @param limitTo determines the nature of the expected matches. This is a combination of {@link org.eclipse.jdt.core.search.IJavaSearchConstants}.
 */
public final void setPattern(final IJavaElement[] elements, final int limitTo) {
	Assert.isNotNull(elements);
	Assert.isTrue(elements.length > 0);
	SearchPattern pattern= SearchPattern.createPattern(elements[0], limitTo, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE);
	IJavaElement element= null;
	for (int index= 1; index < elements.length; index++) {
		element= elements[index];
		pattern= SearchPattern.createOrPattern(pattern, SearchPattern.createPattern(element, limitTo, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE));
	}
	setPattern(pattern);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:20,代码来源:RefactoringSearchEngine2.java

示例9: createSearchPattern

import org.eclipse.jdt.core.search.SearchPattern; //导入方法依赖的package包/类
private static SearchPattern createSearchPattern(IType type) throws JavaModelException {
	SearchPattern pattern= SearchPattern.createPattern(type, IJavaSearchConstants.ALL_OCCURRENCES, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE);
	IMethod[] constructors= JavaElementUtil.getAllConstructors(type);
	if (constructors.length == 0)
		return pattern;
	SearchPattern constructorDeclarationPattern= RefactoringSearchEngine.createOrPattern(constructors, IJavaSearchConstants.DECLARATIONS);
	return SearchPattern.createOrPattern(pattern, constructorDeclarationPattern);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:9,代码来源:CreateCopyOfCompilationUnitChange.java

示例10: findClassesInContainer

import org.eclipse.jdt.core.search.SearchPattern; //导入方法依赖的package包/类
private List<String> findClassesInContainer(
    IJavaElement container, String testMethodAnnotation, String testClassAnnotation) {
  List<String> result = new LinkedList<>();
  IRegion region = getRegion(container);
  try {
    ITypeHierarchy hierarchy = JavaCore.newTypeHierarchy(region, null, null);
    IType[] allClasses = hierarchy.getAllClasses();

    // search for all types with references to RunWith and Test and all subclasses
    HashSet<IType> candidates = new HashSet<>(allClasses.length);
    SearchRequestor requestor = new AnnotationSearchRequestor(hierarchy, candidates);

    IJavaSearchScope scope =
        SearchEngine.createJavaSearchScope(allClasses, IJavaSearchScope.SOURCES);
    int matchRule = SearchPattern.R_CASE_SENSITIVE;

    SearchPattern testPattern =
        SearchPattern.createPattern(
            testMethodAnnotation,
            IJavaSearchConstants.ANNOTATION_TYPE,
            IJavaSearchConstants.ANNOTATION_TYPE_REFERENCE,
            matchRule);

    SearchPattern runWithPattern =
        isNullOrEmpty(testClassAnnotation)
            ? testPattern
            : SearchPattern.createPattern(
                testClassAnnotation,
                IJavaSearchConstants.ANNOTATION_TYPE,
                IJavaSearchConstants.ANNOTATION_TYPE_REFERENCE,
                matchRule);

    SearchPattern annotationsPattern = SearchPattern.createOrPattern(runWithPattern, testPattern);
    SearchParticipant[] searchParticipants =
        new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()};
    new SearchEngine().search(annotationsPattern, searchParticipants, scope, requestor, null);

    // find all classes in the region
    for (IType candidate : candidates) {
      if (isAccessibleClass(candidate)
          && !Flags.isAbstract(candidate.getFlags())
          && region.contains(candidate)) {
        result.add(candidate.getFullyQualifiedName());
      }
    }
  } catch (CoreException e) {

    LOG.info("Can't build project hierarchy.", e);
  }

  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:53,代码来源:JavaTestFinder.java

示例11: setOrPattern

import org.eclipse.jdt.core.search.SearchPattern; //导入方法依赖的package包/类
/**
 * Sets the disjunction of search patterns to be used during search.
 *
 * <p>This method must be called before {@link
 * RefactoringSearchEngine2#searchPattern(IProgressMonitor)}
 *
 * @param first the first search pattern to set
 * @param second the second search pattern to set
 */
public final void setOrPattern(final SearchPattern first, final SearchPattern second) {
  Assert.isNotNull(first);
  Assert.isNotNull(second);
  fPattern = SearchPattern.createOrPattern(first, second);
}
 
开发者ID:eclipse,项目名称:che,代码行数:15,代码来源:RefactoringSearchEngine2.java

示例12: setOrPattern

import org.eclipse.jdt.core.search.SearchPattern; //导入方法依赖的package包/类
/**
 * Sets the disjunction of search patterns to be used during search.
 * <p>
 * This method must be called before {@link RefactoringSearchEngine2#searchPattern(IProgressMonitor)}
 *
 * @param first the first search pattern to set
 * @param second the second search pattern to set
 */
public final void setOrPattern(final SearchPattern first, final SearchPattern second) {
	Assert.isNotNull(first);
	Assert.isNotNull(second);
	fPattern= SearchPattern.createOrPattern(first, second);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:14,代码来源:RefactoringSearchEngine2.java


注:本文中的org.eclipse.jdt.core.search.SearchPattern.createOrPattern方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。