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


Java IJavaSearchScope类代码示例

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


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

示例1: doBrowseTypes

import org.eclipse.jdt.core.search.IJavaSearchScope; //导入依赖的package包/类
private void doBrowseTypes(StringButtonDialogField dialogField) {
	IRunnableContext context= new BusyIndicatorRunnableContext();
	IJavaSearchScope scope= SearchEngine.createWorkspaceScope();
	int style= IJavaElementSearchConstants.CONSIDER_ANNOTATION_TYPES;
	try {
		SelectionDialog dialog= JavaUI.createTypeDialog(getShell(), context, scope, style, false, dialogField.getText());
		dialog.setTitle(PreferencesMessages.NullAnnotationsConfigurationDialog_browse_title);
		dialog.setMessage(PreferencesMessages.NullAnnotationsConfigurationDialog_choose_annotation);
		if (dialog.open() == Window.OK) {
			IType res= (IType) dialog.getResult()[0];
			dialogField.setText(res.getFullyQualifiedName('.'));
		}
	} catch (JavaModelException e) {
		ExceptionHandler.handle(e, getShell(), PreferencesMessages.NullAnnotationsConfigurationDialog_error_title, PreferencesMessages.NullAnnotationsConfigurationDialog_error_message);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:17,代码来源:ProblemSeveritiesConfigurationBlock.java

示例2: getITypeMainByWorkspaceScope

import org.eclipse.jdt.core.search.IJavaSearchScope; //导入依赖的package包/类
/**
 * search the bundle that contains the Main class. The search is done in the
 * workspace scope (ie. if it is defined in the current workspace it will
 * find it
 * 
 * @return the name of the bundle containing the Main class or null if not
 *         found
 */
private IType getITypeMainByWorkspaceScope(String className) {
	SearchPattern pattern = SearchPattern.createPattern(className, IJavaSearchConstants.CLASS,
			IJavaSearchConstants.DECLARATIONS, SearchPattern.R_EXACT_MATCH);
	IJavaSearchScope scope = SearchEngine.createWorkspaceScope();

	final List<IType> binaryType = new ArrayList<IType>();

	SearchRequestor requestor = new SearchRequestor() {
		@Override
		public void acceptSearchMatch(SearchMatch match) throws CoreException {
			binaryType.add((IType) match.getElement());
		}
	};
	SearchEngine engine = new SearchEngine();

	try {
		engine.search(pattern, new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }, scope,
				requestor, null);
	} catch (CoreException e1) {
		throw new RuntimeException("Error while searching the bundle: " + e1.getMessage());
		// return new Status(IStatus.ERROR, Activator.PLUGIN_ID, );
	}

	return binaryType.isEmpty() ? null : binaryType.get(0);
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:34,代码来源:PlainK3ExecutionEngine.java

示例3: performSearch

import org.eclipse.jdt.core.search.IJavaSearchScope; //导入依赖的package包/类
/**
 * Searches for a class that matches a pattern.
 */
@VisibleForTesting
static boolean performSearch(SearchPattern pattern, IJavaSearchScope scope,
    IProgressMonitor monitor) {
  try {
    SearchEngine searchEngine = new SearchEngine();
    TypeSearchRequestor requestor = new TypeSearchRequestor();
    searchEngine.search(pattern,
        new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() },
        scope, requestor, monitor);
    return requestor.foundMatch();
  } catch (CoreException ex) {
    logger.log(Level.SEVERE, ex.getMessage());
    return false;
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:19,代码来源:WebXmlValidator.java

示例4: searchType

import org.eclipse.jdt.core.search.IJavaSearchScope; //导入依赖的package包/类
private List<IType> searchType(String classFQN, IProgressMonitor monitor) {
	classFQN = classFQN.replace('$', '.');
	final List<IType> types = new ArrayList<IType>();

	IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
	SearchEngine engine = new SearchEngine();
	SearchPattern pattern = SearchPattern.createPattern(classFQN, IJavaSearchConstants.TYPE,
			IJavaSearchConstants.DECLARATIONS, SearchPattern.R_EXACT_MATCH);

	SearchRequestor requestor = new SearchRequestor() {
		public void acceptSearchMatch(final SearchMatch match) throws CoreException {
			TypeDeclarationMatch typeMatch = (TypeDeclarationMatch) match;
			IType type = (IType) typeMatch.getElement();
			types.add(type);
		}
	};
	try {
		engine.search(pattern, new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() }, scope,
				requestor, monitor);
	} catch (final CoreException e) {
		return types;
	}

	return types;
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:26,代码来源:JavaTypeMemberBookmarkLocationProvider.java

示例5: getMainTypes

import org.eclipse.jdt.core.search.IJavaSearchScope; //导入依赖的package包/类
public IType[] getMainTypes(IProgressMonitor monitor) {
	IJavaProject javaProject = getJavaProject();

	if (javaProject != null) {
		// Returns main method types
		boolean includeSubtypes = true;
		MainMethodSearchEngine engine = new MainMethodSearchEngine();
		int constraints = IJavaSearchScope.SOURCES;
		constraints |= IJavaSearchScope.APPLICATION_LIBRARIES;
		IJavaSearchScope scope = SearchEngine.createJavaSearchScope(
				new IJavaElement[] { javaProject }, constraints);
		return engine.searchMainMethods(monitor, scope, includeSubtypes);
	}
	return new IType[] {};

}
 
开发者ID:eclipse,项目名称:cft,代码行数:17,代码来源:JavaTypeResolver.java

示例6: handleManifestmainclassBrowse

import org.eclipse.jdt.core.search.IJavaSearchScope; //导入依赖的package包/类
/**
 * Uses the standard container selection dialog to
 * choose the new value for the container field.
 */

private void handleManifestmainclassBrowse() {

    String mainClass = getManifestmainclass();
    
    ILabelProvider lp= new WorkbenchLabelProvider();
    ITreeContentProvider cp= new WorkbenchContentProvider();

    IResource[] res=jproject.getResource();
    IJavaSearchScope searchScope= JavaSearchScopeFactory.getInstance().createJavaSearchScope(res, true);
    SelectionDialog dialog = JavaUI.createMainTypeDialog(getShell(), getContainer(), searchScope, 0, false);
    dialog.setMessage("Select Main-Class for JAR file");
    dialog.setTitle("Fat Jar Config");
    
    if (dialog.open() == SelectionDialog.OK) {
        Object[] elements= dialog.getResult();
        if (elements.length == 1) {
            SourceType mainElement = (SourceType)elements[0];
            mainClass = mainElement.getFullyQualifiedName();
            manifestmainclassText.setText(mainClass);
        }
    }
}
 
开发者ID:thahn0720,项目名称:agui_eclipse_plugin,代码行数:28,代码来源:ConfigPage.java

示例7: search

import org.eclipse.jdt.core.search.IJavaSearchScope; //导入依赖的package包/类
private static List<Controller> search(IJavaProject project, SearchPattern namePattern) throws JavaModelException, CoreException {
    List<Controller> controllers = new ArrayList<Controller>();

    IJavaSearchScope scope = SearchEngine.createJavaSearchScope(project.getPackageFragments());

    SearchRequestor requestor = new SearchRequestor() {

        @Override
        public void acceptSearchMatch(SearchMatch match) {
            if (match.getElement() instanceof IJavaElement) {
                IJavaElement element = (IJavaElement) match.getElement();
                controllers.add(new Controller((IType) element));
            }
        }

    };

    SearchEngine searchEngine = new SearchEngine();
    searchEngine.search(namePattern, new SearchParticipant[] {SearchEngine
                    .getDefaultSearchParticipant()}, scope, requestor,
                    null);

    return controllers;
}
 
开发者ID:abnervr,项目名称:VRaptorEclipsePlugin,代码行数:25,代码来源:SearchHelper.java

示例8: MemberVisibilityAdjustor

import org.eclipse.jdt.core.search.IJavaSearchScope; //导入依赖的package包/类
/**
 * Creates a new java element visibility adjustor.
 *
 * @param referencing the referencing element used to compute the visibility
 * @param referenced the referenced member which causes the visibility changes
 */
public MemberVisibilityAdjustor(final IJavaElement referencing, final IMember referenced) {
  Assert.isTrue(!(referenced instanceof IInitializer));
  Assert.isTrue(
      referencing instanceof ICompilationUnit
          || referencing instanceof IType
          || referencing instanceof IPackageFragment);
  fScope =
      RefactoringScopeFactory.createReferencedScope(
          new IJavaElement[] {referenced},
          IJavaSearchScope.REFERENCED_PROJECTS
              | IJavaSearchScope.SOURCES
              | IJavaSearchScope.APPLICATION_LIBRARIES);
  fReferencing = referencing;
  fReferenced = referenced;
}
 
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:MemberVisibilityAdjustor.java

示例9: TextMatchUpdater

import org.eclipse.jdt.core.search.IJavaSearchScope; //导入依赖的package包/类
private TextMatchUpdater(
    TextChangeManager manager,
    IJavaSearchScope scope,
    String currentName,
    String currentQualifier,
    String newName,
    SearchResultGroup[] references,
    boolean onlyQualified) {
  Assert.isNotNull(manager);
  Assert.isNotNull(scope);
  Assert.isNotNull(references);
  fManager = manager;
  fScope = scope;
  fReferences = references;
  fOnlyQualified = onlyQualified;

  fNewName = newName;
  fCurrentNameLength = currentName.length();
  fScanner = new RefactoringScanner(currentName, currentQualifier);
}
 
开发者ID:eclipse,项目名称:che,代码行数:21,代码来源:TextMatchUpdater.java

示例10: perform

import org.eclipse.jdt.core.search.IJavaSearchScope; //导入依赖的package包/类
static void perform(
    IProgressMonitor pm,
    IJavaSearchScope scope,
    ITextUpdating processor,
    TextChangeManager manager,
    SearchResultGroup[] references)
    throws JavaModelException {
  new TextMatchUpdater(
          manager,
          scope,
          processor.getCurrentElementName(),
          processor.getCurrentElementQualifier(),
          processor.getNewElementName(),
          references,
          false)
      .updateTextMatches(pm);
}
 
开发者ID:eclipse,项目名称:che,代码行数:18,代码来源:TextMatchUpdater.java

示例11: searchForOuterTypesOfReferences

import org.eclipse.jdt.core.search.IJavaSearchScope; //导入依赖的package包/类
private IType[] searchForOuterTypesOfReferences(IMethod[] newNameMethods, IProgressMonitor pm)
    throws CoreException {
  final Set<IType> outerTypesOfReferences = new HashSet<IType>();
  SearchPattern pattern =
      RefactoringSearchEngine.createOrPattern(newNameMethods, IJavaSearchConstants.REFERENCES);
  IJavaSearchScope scope = createRefactoringScope(getMethod());
  SearchRequestor requestor =
      new SearchRequestor() {
        @Override
        public void acceptSearchMatch(SearchMatch match) throws CoreException {
          Object element = match.getElement();
          if (!(element instanceof IMember))
            return; // e.g. an IImportDeclaration for a static method import
          IMember member = (IMember) element;
          IType declaring = member.getDeclaringType();
          if (declaring == null) return;
          IType outer = declaring.getDeclaringType();
          if (outer != null) outerTypesOfReferences.add(declaring);
        }
      };
  new SearchEngine()
      .search(pattern, SearchUtils.getDefaultSearchParticipants(), scope, requestor, pm);
  return outerTypesOfReferences.toArray(new IType[outerTypesOfReferences.size()]);
}
 
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:RenameMethodProcessor.java

示例12: searchForDeclarationsOfClashingMethods

import org.eclipse.jdt.core.search.IJavaSearchScope; //导入依赖的package包/类
private IMethod[] searchForDeclarationsOfClashingMethods(IProgressMonitor pm)
    throws CoreException {
  final List<IMethod> results = new ArrayList<IMethod>();
  SearchPattern pattern = createNewMethodPattern();
  IJavaSearchScope scope = RefactoringScopeFactory.create(getMethod().getJavaProject());
  SearchRequestor requestor =
      new SearchRequestor() {
        @Override
        public void acceptSearchMatch(SearchMatch match) throws CoreException {
          Object method = match.getElement();
          if (method
              instanceof
              IMethod) // check for bug 90138: [refactoring] [rename] Renaming method throws
            // internal exception
            results.add((IMethod) method);
          else
            JavaPlugin.logErrorMessage(
                "Unexpected element in search match: " + match.toString()); // $NON-NLS-1$
        }
      };
  new SearchEngine()
      .search(pattern, SearchUtils.getDefaultSearchParticipants(), scope, requestor, pm);
  return results.toArray(new IMethod[results.size()]);
}
 
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:RenameMethodProcessor.java

示例13: getReferences

import org.eclipse.jdt.core.search.IJavaSearchScope; //导入依赖的package包/类
private static SearchResultGroup[] getReferences(
    ICompilationUnit unit, IProgressMonitor pm, RefactoringStatus status) throws CoreException {
  final SearchPattern pattern =
      RefactoringSearchEngine.createOrPattern(unit.getTypes(), IJavaSearchConstants.REFERENCES);
  if (pattern != null) {
    String binaryRefsDescription =
        Messages.format(
            RefactoringCoreMessages.ReferencesInBinaryContext_ref_in_binaries_description,
            BasicElementLabels.getFileName(unit));
    ReferencesInBinaryContext binaryRefs = new ReferencesInBinaryContext(binaryRefsDescription);
    Collector requestor = new Collector(((IPackageFragment) unit.getParent()), binaryRefs);
    IJavaSearchScope scope = RefactoringScopeFactory.create(unit, true, false);

    SearchResultGroup[] result =
        RefactoringSearchEngine.search(
            pattern, scope, requestor, new SubProgressMonitor(pm, 1), status);
    binaryRefs.addErrorIfNecessary(status);
    return result;
  }
  return new SearchResultGroup[] {};
}
 
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:MoveCuUpdateCreator.java

示例14: create

import org.eclipse.jdt.core.search.IJavaSearchScope; //导入依赖的package包/类
/**
 * Creates a new search scope with all compilation units possibly referencing <code>javaElement
 * </code>.
 *
 * @param javaElement the java element
 * @param considerVisibility consider visibility of javaElement iff <code>true</code>
 * @param sourceReferencesOnly consider references in source only (no references in binary)
 * @return the search scope
 * @throws JavaModelException if an error occurs
 */
public static IJavaSearchScope create(
    IJavaElement javaElement, boolean considerVisibility, boolean sourceReferencesOnly)
    throws JavaModelException {
  if (considerVisibility & javaElement instanceof IMember) {
    IMember member = (IMember) javaElement;
    if (JdtFlags.isPrivate(member)) {
      if (member.getCompilationUnit() != null)
        return SearchEngine.createJavaSearchScope(
            new IJavaElement[] {member.getCompilationUnit()});
      else return SearchEngine.createJavaSearchScope(new IJavaElement[] {member});
    }
    // Removed code that does some optimizations regarding package visible members. The problem is
    // that
    // there can be a package fragment with the same name in a different source folder or project.
    // So we
    // have to treat package visible members like public or protected members.
  }

  IJavaProject javaProject = javaElement.getJavaProject();
  return SearchEngine.createJavaSearchScope(
      getAllScopeElements(javaProject, sourceReferencesOnly), false);
}
 
开发者ID:eclipse,项目名称:che,代码行数:33,代码来源:RefactoringScopeFactory.java

示例15: search

import org.eclipse.jdt.core.search.IJavaSearchScope; //导入依赖的package包/类
public static SearchResultGroup[] search(
    SearchPattern pattern,
    WorkingCopyOwner owner,
    IJavaSearchScope scope,
    CollectingSearchRequestor requestor,
    IProgressMonitor monitor,
    RefactoringStatus status)
    throws JavaModelException {
  return internalSearch(
      owner != null ? new SearchEngine(owner) : new SearchEngine(),
      pattern,
      scope,
      requestor,
      monitor,
      status);
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:RefactoringSearchEngine.java


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