本文整理汇总了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);
}
示例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;
}
示例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();
}
}
示例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;
}
示例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);
}
示例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) {
}
}
示例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());
}
示例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();
}
示例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();
}
}
示例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);
}
示例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();
}