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


Java SearchPattern.R_EXACT_MATCH属性代码示例

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


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

示例1: findType

/**
 * Find type
 * 
 * @param className
 * @param monitor
 * @return type or <code>null</code>
 */
public IType findType(String className, IProgressMonitor monitor) {
	final IType[] result = { null };
	TypeNameMatchRequestor nameMatchRequestor = new TypeNameMatchRequestor() {
		@Override
		public void acceptTypeNameMatch(TypeNameMatch match) {
			result[0] = match.getType();
		}
	};
	int lastDot = className.lastIndexOf('.');
	char[] packageName = lastDot >= 0 ? className.substring(0, lastDot).toCharArray() : null;
	char[] typeName = (lastDot >= 0 ? className.substring(lastDot + 1) : className).toCharArray();
	SearchEngine engine = new SearchEngine();
	int packageMatchRule = SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE;
	try {
		engine.searchAllTypeNames(packageName, packageMatchRule, typeName, packageMatchRule, IJavaSearchConstants.TYPE,
				SearchEngine.createWorkspaceScope(), nameMatchRequestor,
				IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, monitor);
	} catch (JavaModelException e) {
		EditorUtil.INSTANCE.logError("Was not able to search all type names",e);
	}
	return result[0];
}
 
开发者ID:de-jcup,项目名称:egradle,代码行数:29,代码来源:JDTDataAccess.java

示例2: findTypeInfos

private static List<TypeNameMatch> findTypeInfos(String typeName, IType contextType, IProgressMonitor pm) throws JavaModelException {
	IJavaSearchScope scope= SearchEngine.createJavaSearchScope(new IJavaProject[]{contextType.getJavaProject()}, true);
	IPackageFragment currPackage= contextType.getPackageFragment();
	ArrayList<TypeNameMatch> collectedInfos= new ArrayList<TypeNameMatch>();
	TypeNameMatchCollector requestor= new TypeNameMatchCollector(collectedInfos);
	int matchMode= SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE;
	new SearchEngine().searchAllTypeNames(null, matchMode, typeName.toCharArray(), matchMode, IJavaSearchConstants.TYPE, scope, requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, pm);

	List<TypeNameMatch> result= new ArrayList<TypeNameMatch>();
	for (Iterator<TypeNameMatch> iter= collectedInfos.iterator(); iter.hasNext();) {
		TypeNameMatch curr= iter.next();
		IType type= curr.getType();
		if (type != null) {
			boolean visible=true;
			try {
				visible= JavaModelUtil.isVisible(type, currPackage);
			} catch (JavaModelException e) {
				//Assume visibile if not available
			}
			if (visible) {
				result.add(curr);
			}
		}
	}
	return result;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:26,代码来源:TypeContextChecker.java

示例3: findAllTypes

private TypeNameMatch[] findAllTypes(String simpleTypeName, IJavaSearchScope searchScope, SimpleName nameNode, IProgressMonitor monitor) throws JavaModelException {
	boolean is50OrHigher= JavaModelUtil.is50OrHigher(fCompilationUnit.getJavaProject());

	int typeKinds= SimilarElementsRequestor.ALL_TYPES;
	if (nameNode != null) {
		typeKinds= ASTResolving.getPossibleTypeKinds(nameNode, is50OrHigher);
	}

	ArrayList<TypeNameMatch> typeInfos= new ArrayList<TypeNameMatch>();
	TypeNameMatchCollector requestor= new TypeNameMatchCollector(typeInfos);
	int matchMode= SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE;
	new SearchEngine().searchAllTypeNames(null, matchMode, simpleTypeName.toCharArray(), matchMode, getSearchForConstant(typeKinds), searchScope, requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, monitor);

	ArrayList<TypeNameMatch> typeRefsFound= new ArrayList<TypeNameMatch>(typeInfos.size());
	for (int i= 0, len= typeInfos.size(); i < len; i++) {
		TypeNameMatch curr= typeInfos.get(i);
		if (curr.getPackageName().length() > 0) { // do not suggest imports from the default package
			if (isOfKind(curr, typeKinds, is50OrHigher) && isVisible(curr)) {
				typeRefsFound.add(curr);
			}
		}
	}
	return typeRefsFound.toArray(new TypeNameMatch[typeRefsFound.size()]);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:24,代码来源:AddImportsOperation.java

示例4: matches

public boolean matches(String text) {
	switch (fMatchKind) {
		case SearchPattern.R_PATTERN_MATCH:
			return fStringMatcher.match(text);
		case SearchPattern.R_EXACT_MATCH:
			return fPattern.equalsIgnoreCase(text);
		case SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH:
			return SearchPattern.camelCaseMatch(fPattern, text, true);
		case SearchPattern.R_CAMELCASE_MATCH:
			if (SearchPattern.camelCaseMatch(fPattern, text)) {
				return true;
			}
			// fall back to prefix match if camel case failed (bug 137244)
			return Strings.startsWithIgnoreCase(text, fPattern);
		default:
			return Strings.startsWithIgnoreCase(text, fPattern);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:PatternMatcher.java

示例5: findAllTypes

private TypeNameMatch[] findAllTypes(
    String simpleTypeName,
    IJavaSearchScope searchScope,
    SimpleName nameNode,
    IProgressMonitor monitor)
    throws JavaModelException {
  boolean is50OrHigher = JavaModelUtil.is50OrHigher(fCompilationUnit.getJavaProject());

  int typeKinds = SimilarElementsRequestor.ALL_TYPES;
  if (nameNode != null) {
    typeKinds = ASTResolving.getPossibleTypeKinds(nameNode, is50OrHigher);
  }

  ArrayList<TypeNameMatch> typeInfos = new ArrayList<TypeNameMatch>();
  TypeNameMatchCollector requestor = new TypeNameMatchCollector(typeInfos);
  int matchMode = SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE;
  new SearchEngine()
      .searchAllTypeNames(
          null,
          matchMode,
          simpleTypeName.toCharArray(),
          matchMode,
          getSearchForConstant(typeKinds),
          searchScope,
          requestor,
          IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
          monitor);

  ArrayList<TypeNameMatch> typeRefsFound = new ArrayList<TypeNameMatch>(typeInfos.size());
  for (int i = 0, len = typeInfos.size(); i < len; i++) {
    TypeNameMatch curr = typeInfos.get(i);
    if (curr.getPackageName().length() > 0) { // do not suggest imports from the default package
      if (isOfKind(curr, typeKinds, is50OrHigher) && isVisible(curr)) {
        typeRefsFound.add(curr);
      }
    }
  }
  return typeRefsFound.toArray(new TypeNameMatch[typeRefsFound.size()]);
}
 
开发者ID:eclipse,项目名称:che,代码行数:39,代码来源:AddImportsOperation.java

示例6: findTypeInfos

private static List<TypeNameMatch> findTypeInfos(
    String typeName, IType contextType, IProgressMonitor pm) throws JavaModelException {
  IJavaSearchScope scope =
      SearchEngine.createJavaSearchScope(
          new IJavaProject[] {contextType.getJavaProject()}, true);
  IPackageFragment currPackage = contextType.getPackageFragment();
  ArrayList<TypeNameMatch> collectedInfos = new ArrayList<TypeNameMatch>();
  TypeNameMatchCollector requestor = new TypeNameMatchCollector(collectedInfos);
  int matchMode = SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE;
  new SearchEngine()
      .searchAllTypeNames(
          null,
          matchMode,
          typeName.toCharArray(),
          matchMode,
          IJavaSearchConstants.TYPE,
          scope,
          requestor,
          IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
          pm);

  List<TypeNameMatch> result = new ArrayList<TypeNameMatch>();
  for (Iterator<TypeNameMatch> iter = collectedInfos.iterator(); iter.hasNext(); ) {
    TypeNameMatch curr = iter.next();
    IType type = curr.getType();
    if (type != null) {
      boolean visible = true;
      try {
        visible = JavaModelUtil.isVisible(type, currPackage);
      } catch (JavaModelException e) {
        // Assume visibile if not available
      }
      if (visible) {
        result.add(curr);
      }
    }
  }
  return result;
}
 
开发者ID:eclipse,项目名称:che,代码行数:39,代码来源:TypeContextChecker.java

示例7: getMatchMode

private int getMatchMode(String pattern) {
  if (pattern.indexOf('*') != -1 || pattern.indexOf('?') != -1) {
    return SearchPattern.R_PATTERN_MATCH;
  } else if (SearchUtils.isCamelCasePattern(pattern)) {
    return SearchPattern.R_CAMELCASE_MATCH;
  }
  return SearchPattern.R_EXACT_MATCH;
}
 
开发者ID:eclipse,项目名称:che,代码行数:8,代码来源:JavaSearchQuery.java

示例8: getExistingCategories

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,代码行数:35,代码来源:FunctionsLibraryInformationPage.java

示例9: getMatchMode

private int getMatchMode(String pattern) {
	if (pattern.indexOf('*') != -1 || pattern.indexOf('?') != -1) {
		return SearchPattern.R_PATTERN_MATCH;
	} else if (SearchUtils.isCamelCasePattern(pattern)) {
		return SearchPattern.R_CAMELCASE_MATCH;
	}
	return SearchPattern.R_EXACT_MATCH;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:8,代码来源:JavaSearchQuery.java

示例10: getFixImportProposals

@Override
public ClasspathFixProposal[] getFixImportProposals(final IJavaProject project, String name) throws CoreException
{
	IProject requestedProject = project.getProject();
	if( !requestedProject.hasNature(JPFProjectNature.NATURE_ID) )
	{
		return null;
	}
	ArrayList<ClasspathFixProposal> props = new ArrayList<ClasspathFixProposal>();

	IWorkspace workspace = ResourcesPlugin.getWorkspace();
	int idx = name.lastIndexOf('.');
	char[] packageName = idx != -1 ? name.substring(0, idx).toCharArray() : null;
	char[] typeName = name.substring(idx + 1).toCharArray();

	if( typeName.length == 1 && typeName[0] == '*' )
	{
		typeName = null;
	}

	ArrayList<TypeNameMatch> res = new ArrayList<TypeNameMatch>();
	TypeNameMatchCollector requestor = new TypeNameMatchCollector(res);

	IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
	int matchMode = SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE;
	new SearchEngine().searchAllTypeNames(packageName, matchMode, typeName, matchMode, IJavaSearchConstants.TYPE,
		scope, requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null);

	if( res.isEmpty() )
	{
		return null;
	}
	JPFPluginModelManager service = JPFPluginModelManager.instance();
	for( TypeNameMatch curr : res )
	{
		IType type = curr.getType();
		if( type != null )
		{
			IPackageFragmentRoot root = (IPackageFragmentRoot) type.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
			IPluginModel model = null;
			if( root.isArchive() )
			{
				model = service.findModel((IFile) root.getResource());
			}
			else if( !root.isExternal() )
			{
				model = service.findModel(root.getResource().getProject());
			}
			if( model != null )
			{
				System.err.println("Found in " + model.getParsedManifest().getId());
				props.add(new JPFClasspathFixProposal(project, JPFProject.getManifest(requestedProject), model));
			}
		}
	}
	return props.toArray(new ClasspathFixProposal[props.size()]);
}
 
开发者ID:equella,项目名称:Equella,代码行数:57,代码来源:JPFClasspathFixProcessor.java

示例11: getPackageFlags

public int getPackageFlags() {
	if (fPackageMatcher == null)
		return SearchPattern.R_EXACT_MATCH;

	return fPackageMatcher.getMatchKind();
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:6,代码来源:TypeInfoFilter.java

示例12: PatternMatcher

public PatternMatcher(String pattern) {
	this(pattern, SearchPattern.R_EXACT_MATCH | SearchPattern.R_PREFIX_MATCH |
		SearchPattern.R_PATTERN_MATCH | SearchPattern.R_CAMELCASE_MATCH | SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:4,代码来源:PatternMatcher.java

示例13: initializePatternAndMatchKind

private void initializePatternAndMatchKind(String pattern) {
	int length= pattern.length();
	if (length == 0) {
		fMatchKind= SearchPattern.R_EXACT_MATCH;
		fPattern= pattern;
		return;
	}
	char last= pattern.charAt(length - 1);

	if (pattern.indexOf('*') != -1 || pattern.indexOf('?') != -1) {
		fMatchKind= SearchPattern.R_PATTERN_MATCH;
		switch (last) {
			case END_SYMBOL:
			case BLANK:
				fPattern= pattern.substring(0, length - 1);
				break;
			case ANY_STRING:
				fPattern= pattern;
				break;
			default:
				fPattern= pattern + ANY_STRING;
		}
		return;
	}

	if (last == END_SYMBOL || last == BLANK) {
		fPattern= pattern.substring(0, length - 1);
		if (SearchPattern.validateMatchRule(fPattern,SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH)
				== SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH) {
			fMatchKind= SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH;
		} else {
			fMatchKind= SearchPattern.R_EXACT_MATCH;
		}
		return;
	}

	if (SearchUtils.isCamelCasePattern(pattern)) {
		fMatchKind= SearchPattern.R_CAMELCASE_MATCH;
		fPattern= pattern;
		return;
	}

	fMatchKind= SearchPattern.R_PREFIX_MATCH;
	fPattern= pattern;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:45,代码来源:PatternMatcher.java

示例14: matchLevelForTokens

protected int matchLevelForTokens(char[][] tokens) {
	if (this.pattern.pkgName == null) return ACCURATE_MATCH;

	switch (this.matchMode) {
		case SearchPattern.R_EXACT_MATCH:
		case SearchPattern.R_PREFIX_MATCH:
			if (CharOperation.prefixEquals(this.pattern.pkgName, CharOperation.concatWith(tokens, '.'), this.isCaseSensitive)) {
				return POSSIBLE_MATCH;
			}
			break;

		case SearchPattern.R_PATTERN_MATCH:
			char[] patternName = this.pattern.pkgName[this.pattern.pkgName.length - 1] == '*'
				? this.pattern.pkgName
				: CharOperation.concat(this.pattern.pkgName, ".*".toCharArray()); //$NON-NLS-1$
			if (CharOperation.match(patternName, CharOperation.concatWith(tokens, '.'), this.isCaseSensitive)) {
				return POSSIBLE_MATCH;
			}
			break;

		case SearchPattern.R_REGEXP_MATCH :
			// TODO (frederic) implement regular expression match
			break;

		case SearchPattern.R_CAMELCASE_MATCH:
			char[] packageName = CharOperation.concatWith(tokens, '.');
			if (CharOperation.camelCaseMatch(this.pattern.pkgName, packageName, false)) {
				return POSSIBLE_MATCH;
			}
			// only test case insensitive as CamelCase already verified prefix case sensitive
			if (!this.isCaseSensitive && CharOperation.prefixEquals(this.pattern.pkgName, packageName, false)) {
				return POSSIBLE_MATCH;
			}
			break;

		case SearchPattern.R_CAMELCASE_SAME_PART_COUNT_MATCH:
			if (CharOperation.camelCaseMatch(this.pattern.pkgName, CharOperation.concatWith(tokens, '.'), true)) {
				return POSSIBLE_MATCH;
			}
			break;
	}
	return IMPOSSIBLE_MATCH;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:43,代码来源:PackageReferenceLocator.java


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