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


Java SearchEngine.createWorkspaceScope方法代碼示例

本文整理匯總了Java中org.eclipse.jdt.core.search.SearchEngine.createWorkspaceScope方法的典型用法代碼示例。如果您正苦於以下問題:Java SearchEngine.createWorkspaceScope方法的具體用法?Java SearchEngine.createWorkspaceScope怎麽用?Java SearchEngine.createWorkspaceScope使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jdt.core.search.SearchEngine的用法示例。


在下文中一共展示了SearchEngine.createWorkspaceScope方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getITypeMainByWorkspaceScope

import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的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

示例2: searchType

import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的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

示例3: browseForAccessorClass

import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的package包/類
protected void browseForAccessorClass() {
	IProgressService service= PlatformUI.getWorkbench().getProgressService();
	IPackageFragmentRoot root= fAccessorPackage.getSelectedFragmentRoot();

	IJavaSearchScope scope= root != null ? SearchEngine.createJavaSearchScope(new IJavaElement[] { root }) : SearchEngine.createWorkspaceScope();

	FilteredTypesSelectionDialog  dialog= new FilteredTypesSelectionDialog (getShell(), false,
		service, scope, IJavaSearchConstants.CLASS);
	dialog.setTitle(NLSUIMessages.NLSAccessorConfigurationDialog_Accessor_Selection);
	dialog.setMessage(NLSUIMessages.NLSAccessorConfigurationDialog_Choose_the_accessor_file);
	dialog.setInitialPattern("*Messages"); //$NON-NLS-1$
	if (dialog.open() == Window.OK) {
		IType selectedType= (IType) dialog.getFirstResult();
		if (selectedType != null) {
			fAccessorClassName.setText(selectedType.getElementName());
			fAccessorPackage.setSelected(selectedType.getPackageFragment());
		}
	}


}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:22,代碼來源:NLSAccessorConfigurationDialog.java

示例4: find

import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的package包/類
@Override
public void find() {
	
       SearchEngine engine = new SearchEngine();
       IJavaSearchScope workspaceScope = null;
       
       if(getProject() != null) {
       	workspaceScope = SearchEngine.createJavaSearchScope(createSearchScope());
       } else {
       	workspaceScope = SearchEngine.createWorkspaceScope();
       }
       
       SearchPattern pattern = SearchPattern.createPattern(
               		getElement().getPrimaryElement().getElementName().replace(Constants.JAVA_EXTENSION, Constants.EMPTY_STRING),
                       IJavaSearchConstants.TYPE,
                       IJavaSearchConstants.REFERENCES,
                       SearchPattern.R_EXACT_MATCH);
       SearchParticipant[] participant = new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() };
       try {
		engine.search(pattern, participant, workspaceScope, createSearchRequestor(), new NullProgressMonitor());
	} catch (CoreException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
開發者ID:SEMERU-WM,項目名稱:ChangeScribe,代碼行數:26,代碼來源:TypeDependencySummary.java

示例5: run

import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的package包/類
@Override
public void run() {
	Shell parent= JavaPlugin.getActiveWorkbenchShell();
	OpenTypeSelectionDialog dialog= new OpenTypeSelectionDialog(parent, false,
		PlatformUI.getWorkbench().getProgressService(),
		SearchEngine.createWorkspaceScope(), IJavaSearchConstants.TYPE);

	dialog.setTitle(ActionMessages.OpenTypeInHierarchyAction_dialogTitle);
	dialog.setMessage(ActionMessages.OpenTypeInHierarchyAction_dialogMessage);
	int result= dialog.open();
	if (result != IDialogConstants.OK_ID)
		return;

	Object[] types= dialog.getResult();
	if (types != null && types.length > 0) {
		IType type= (IType)types[0];
		OpenTypeHierarchyUtil.open(new IType[] { type }, fWindow);
	}
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion-Juno38,代碼行數:20,代碼來源:OpenTypeInHierarchyAction.java

示例6: doBrowseTypes

import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的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-Juno38,代碼行數:17,代碼來源:ProblemSeveritiesConfigurationBlock.java

示例7: choosePackage

import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的package包/類
private String[] choosePackage() {
	IJavaSearchScope scope= SearchEngine.createWorkspaceScope();
	BusyIndicatorRunnableContext context= new BusyIndicatorRunnableContext();
	int flags= PackageSelectionDialog.F_SHOW_PARENTS | PackageSelectionDialog.F_HIDE_DEFAULT_PACKAGE | PackageSelectionDialog.F_REMOVE_DUPLICATES;
	PackageSelectionDialog dialog = new PackageSelectionDialog(getShell(), context, flags , scope);
	dialog.setTitle(PreferencesMessages.TypeFilterPreferencePage_choosepackage_label);
	dialog.setMessage(PreferencesMessages.TypeFilterPreferencePage_choosepackage_description);
	dialog.setMultipleSelection(true);
	if (dialog.open() == IDialogConstants.OK_ID) {
		Object[] fragments= dialog.getResult();
		String[] res= new String[fragments.length];
		for (int i= 0; i < res.length; i++) {
			res[i]= ((IPackageFragment) fragments[i]).getElementName() + ".*"; //$NON-NLS-1$
		}
		return res;
	}
	return null;
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:19,代碼來源:TypeFilterPreferencePage.java

示例8: doBrowseTypes

import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的package包/類
private void doBrowseTypes() {
	IRunnableContext context= new BusyIndicatorRunnableContext();
	IJavaSearchScope scope= SearchEngine.createWorkspaceScope();
	int style= IJavaElementSearchConstants.CONSIDER_ALL_TYPES;
	try {
		SelectionDialog dialog= JavaUI.createTypeDialog(getShell(), context, scope, style, false, fNameDialogField.getText());
		dialog.setTitle(PreferencesMessages.FavoriteStaticMemberInputDialog_ChooseTypeDialog_title);
		dialog.setMessage(PreferencesMessages.FavoriteStaticMemberInputDialog_ChooseTypeDialog_description);
		if (dialog.open() == Window.OK) {
			IType res= (IType) dialog.getResult()[0];
			fNameDialogField.setText(res.getFullyQualifiedName('.'));
		}
	} catch (JavaModelException e) {
		ExceptionHandler.handle(e, getShell(), PreferencesMessages.FavoriteStaticMemberInputDialog_ChooseTypeDialog_title, PreferencesMessages.FavoriteStaticMemberInputDialog_ChooseTypeDialog_error_message);
	}
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:17,代碼來源:CodeAssistFavoritesConfigurationBlock.java

示例9: createSearchScope

import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的package包/類
public static IJavaSearchScope createSearchScope(IJavaProject project) {
	if (project == null) {
		return SearchEngine.createWorkspaceScope();
	}
	return SearchEngine.createJavaSearchScope(new IJavaProject[] { project },
			IJavaSearchScope.SOURCES | IJavaSearchScope.APPLICATION_LIBRARIES | IJavaSearchScope.SYSTEM_LIBRARIES);
}
 
開發者ID:angelozerr,項目名稱:codelens-eclipse,代碼行數:8,代碼來源:JDTUtils.java

示例10: waitUntilIndexesReady

import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的package包/類
public static void waitUntilIndexesReady() {
  // dummy query for waiting until the indexes are ready
  SearchEngine engine = new SearchEngine();
  IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
  try {
    engine.searchAllTypeNames(null, SearchPattern.R_EXACT_MATCH, "[email protected]$#[email protected]".toCharArray(), SearchPattern.R_PATTERN_MATCH | SearchPattern.R_CASE_SENSITIVE,
        IJavaSearchConstants.CLASS, scope, new TypeNameRequestor() {
          public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path) {
          }
        }, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null);
  } catch (CoreException e) {
  }
}
 
開發者ID:RuiChen08,項目名稱:dacapobench,代碼行數:14,代碼來源:AbstractJavaModelTests.java

示例11: getJavaProjectFromType

import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的package包/類
/**
 * Get java project from type.
 *
 * @param fullyQualifiedTypeName
 *            fully qualified name of type
 * @return java project
 * @throws CoreException
 *             CoreException
 */
private static List<IJavaProject> getJavaProjectFromType(String fullyQualifiedTypeName) throws CoreException {
    String[] splitItems = fullyQualifiedTypeName.split("/");
    // If the main class name contains the module name, should trim the module info.
    if (splitItems.length == 2) {
        fullyQualifiedTypeName = splitItems[1];
    }
    final String moduleName = splitItems.length == 2 ? splitItems[0] : null;

    SearchPattern pattern = SearchPattern.createPattern(
            fullyQualifiedTypeName,
            IJavaSearchConstants.TYPE,
            IJavaSearchConstants.DECLARATIONS,
            SearchPattern.R_EXACT_MATCH);
    IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
    ArrayList<IJavaProject> projects = new ArrayList<>();
    SearchRequestor requestor = new SearchRequestor() {
        @Override
        public void acceptSearchMatch(SearchMatch match) {
            Object element = match.getElement();
            if (element instanceof IJavaElement) {
                IJavaProject project = ((IJavaElement) element).getJavaProject();
                if (moduleName == null || moduleName.equals(JdtUtils.getModuleName(project))) {
                    projects.add(project);
                }
            }
        }
    };
    SearchEngine searchEngine = new SearchEngine();
    searchEngine.search(pattern, new SearchParticipant[] {
        SearchEngine.getDefaultSearchParticipant() }, scope,
        requestor, null /* progress monitor */);

    return projects.stream().distinct().collect(Collectors.toList());
}
 
開發者ID:Microsoft,項目名稱:java-debug,代碼行數:44,代碼來源:ResolveClasspathsHandler.java

示例12: getSearchScope

import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的package包/類
protected IJavaSearchScope getSearchScope(ReferenceScope scope, ICompilationUnit compilationUnit) {
	if (scope == ReferenceScope.Class) {
		return SearchEngine.createJavaSearchScope(new IJavaElement[] { compilationUnit });
	}

	return SearchEngine.createWorkspaceScope();
}
 
開發者ID:CenterDevice,項目名稱:ClassCleaner,代碼行數:8,代碼來源:JavaReferenceFinder.java

示例13: openClassSelectionDialog

import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的package包/類
/**
 * Opens the class selection dialog to add services to the given {@link TemplateCustomProperties}.
 * 
 * @param customProperties
 *            the {@link TemplateCustomProperties}
 */
private void openClassSelectionDialog(final TemplateCustomProperties customProperties) {
    final IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
    final FilteredTypesSelectionDialog dialog = new FilteredTypesSelectionDialog(
            Display.getCurrent().getActiveShell(), true, PlatformUI.getWorkbench().getProgressService(), scope,
            IJavaSearchConstants.CLASS);
    if (dialog.open() == Dialog.OK && dialog.getResult() != null && dialog.getResult().length != 0) {
        for (Object object : dialog.getResult()) {
            IPath parentPath = ((IType) object).getParent().getPath();
            if (parentPath.getFileExtension().equals("jar")) {
                int indexOfUnderscore = parentPath.lastSegment().indexOf('_');
                if (indexOfUnderscore > -1) {
                    final String pluginName = parentPath.lastSegment().substring(0, indexOfUnderscore);
                    customProperties.getServiceClasses().put(((IType) object).getFullyQualifiedName(), pluginName);
                } else {
                    customProperties.getServiceClasses().put(((IType) object).getFullyQualifiedName(), "");
                }
            } else {
                final String bundleName = getBundleName((IType) object);
                if (bundleName != null) {
                    customProperties.getServiceClasses().put(((IType) object).getFullyQualifiedName(), bundleName);
                } else {
                    customProperties.getServiceClasses().put(((IType) object).getFullyQualifiedName(),
                            ((IType) object).getJavaProject().getProject().getName());
                }
            }
        }
        setDirty(true);
        servicesTable.refresh();
    }
}
 
開發者ID:ObeoNetwork,項目名稱:M2Doc,代碼行數:37,代碼來源:M2DocTemplateEditor.java

示例14: classExists

import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的package包/類
@VisibleForTesting
static boolean classExists(IJavaProject project, String typeName) {
  if (Strings.isNullOrEmpty(typeName)) {
    return false;
  }
  SearchPattern pattern = SearchPattern.createPattern(typeName,
      IJavaSearchConstants.CLASS,
      IJavaSearchConstants.DECLARATIONS,
      SearchPattern.R_EXACT_MATCH | SearchPattern.R_ERASURE_MATCH);
  IJavaSearchScope scope = project == null ? SearchEngine.createWorkspaceScope()
      : SearchEngine.createJavaSearchScope(new IJavaElement[] {project});
  return performSearch(pattern, scope, null);
}
 
開發者ID:GoogleCloudPlatform,項目名稱:google-cloud-eclipse,代碼行數:14,代碼來源:WebXmlValidator.java

示例15: createWorkspaceScope

import org.eclipse.jdt.core.search.SearchEngine; //導入方法依賴的package包/類
public IJavaSearchScope createWorkspaceScope(int includeMask) {
  if ((includeMask & NO_PROJ) != NO_PROJ) {
    try {
      IJavaProject[] projects =
          JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()).getJavaProjects();
      return SearchEngine.createJavaSearchScope(projects, getSearchFlags(includeMask));
    } catch (JavaModelException e) {
      // ignore, use workspace scope instead
    }
  }
  return SearchEngine.createWorkspaceScope();
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:13,代碼來源:JavaSearchScopeFactory.java


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