本文整理汇总了Java中org.eclipse.jdt.core.search.IJavaSearchConstants.TYPE属性的典型用法代码示例。如果您正苦于以下问题:Java IJavaSearchConstants.TYPE属性的具体用法?Java IJavaSearchConstants.TYPE怎么用?Java IJavaSearchConstants.TYPE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.eclipse.jdt.core.search.IJavaSearchConstants
的用法示例。
在下文中一共展示了IJavaSearchConstants.TYPE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSearchForConstant
private int getSearchForConstant(int typeKinds) {
final int CLASSES = SimilarElementsRequestor.CLASSES;
final int INTERFACES = SimilarElementsRequestor.INTERFACES;
final int ENUMS = SimilarElementsRequestor.ENUMS;
final int ANNOTATIONS = SimilarElementsRequestor.ANNOTATIONS;
switch (typeKinds & (CLASSES | INTERFACES | ENUMS | ANNOTATIONS)) {
case CLASSES:
return IJavaSearchConstants.CLASS;
case INTERFACES:
return IJavaSearchConstants.INTERFACE;
case ENUMS:
return IJavaSearchConstants.ENUM;
case ANNOTATIONS:
return IJavaSearchConstants.ANNOTATION_TYPE;
case CLASSES | INTERFACES:
return IJavaSearchConstants.CLASS_AND_INTERFACE;
case CLASSES | ENUMS:
return IJavaSearchConstants.CLASS_AND_ENUM;
default:
return IJavaSearchConstants.TYPE;
}
}
示例2: findMatches
private Set<IIndexedJavaRef> findMatches(PatternQuerySpecification query) {
// Translate the IJavaSearchConstant element type constants to IJavaElement
// type constants.
int elementType;
switch (query.getSearchFor()) {
case IJavaSearchConstants.TYPE:
elementType = IJavaElement.TYPE;
break;
case IJavaSearchConstants.FIELD:
elementType = IJavaElement.FIELD;
break;
case IJavaSearchConstants.METHOD:
case IJavaSearchConstants.CONSTRUCTOR:
// IJavaElement.METHOD represents both methods & ctors
elementType = IJavaElement.METHOD;
break;
default:
// We only support searching for types, fields, methods, and ctors
return Collections.emptySet();
}
return JavaRefIndex.getInstance().findElementReferences(query.getPattern(),
elementType, query.isCaseSensitive());
}
示例3: openTypeSelectionDialog
private void openTypeSelectionDialog(){
int elementKinds= IJavaSearchConstants.TYPE;
final IJavaSearchScope scope= createWorkspaceSourceScope();
FilteredTypesSelectionDialog dialog= new FilteredTypesSelectionDialog(getShell(), false,
getWizard().getContainer(), scope, elementKinds);
dialog.setTitle(RefactoringMessages.MoveMembersInputPage_choose_Type);
dialog.setMessage(RefactoringMessages.MoveMembersInputPage_dialogMessage);
dialog.setValidator(new ISelectionStatusValidator(){
public IStatus validate(Object[] selection) {
Assert.isTrue(selection.length <= 1);
if (selection.length == 0)
return new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, RefactoringMessages.MoveMembersInputPage_Invalid_selection, null);
Object element= selection[0];
if (! (element instanceof IType))
return new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, RefactoringMessages.MoveMembersInputPage_Invalid_selection, null);
IType type= (IType)element;
return validateDestinationType(type, type.getElementName());
}
});
dialog.setInitialPattern(createInitialFilter());
if (dialog.open() == Window.CANCEL)
return;
IType firstResult= (IType)dialog.getFirstResult();
fDestinationField.setText(firstResult.getFullyQualifiedName('.'));
}
示例4: getSearchForConstant
private int getSearchForConstant(int typeKinds) {
final int CLASSES= SimilarElementsRequestor.CLASSES;
final int INTERFACES= SimilarElementsRequestor.INTERFACES;
final int ENUMS= SimilarElementsRequestor.ENUMS;
final int ANNOTATIONS= SimilarElementsRequestor.ANNOTATIONS;
switch (typeKinds & (CLASSES | INTERFACES | ENUMS | ANNOTATIONS)) {
case CLASSES: return IJavaSearchConstants.CLASS;
case INTERFACES: return IJavaSearchConstants.INTERFACE;
case ENUMS: return IJavaSearchConstants.ENUM;
case ANNOTATIONS: return IJavaSearchConstants.ANNOTATION_TYPE;
case CLASSES | INTERFACES: return IJavaSearchConstants.CLASS_AND_INTERFACE;
case CLASSES | ENUMS: return IJavaSearchConstants.CLASS_AND_ENUM;
default: return IJavaSearchConstants.TYPE;
}
}
示例5: matchesModifiers
private boolean matchesModifiers(TypeNameMatch type) {
if (fElementKind == IJavaSearchConstants.TYPE)
return true;
int modifiers= type.getModifiers() & TYPE_MODIFIERS;
switch (fElementKind) {
case IJavaSearchConstants.CLASS:
return modifiers == 0;
case IJavaSearchConstants.ANNOTATION_TYPE:
return Flags.isAnnotation(modifiers);
case IJavaSearchConstants.INTERFACE:
return modifiers == Flags.AccInterface;
case IJavaSearchConstants.ENUM:
return Flags.isEnum(modifiers);
case IJavaSearchConstants.CLASS_AND_INTERFACE:
return modifiers == 0 || modifiers == Flags.AccInterface;
case IJavaSearchConstants.CLASS_AND_ENUM:
return modifiers == 0 || Flags.isEnum(modifiers);
case IJavaSearchConstants.INTERFACE_AND_ANNOTATION:
return Flags.isInterface(modifiers);
}
return false;
}
示例6: chooseEnclosingType
/**
* Opens a selection dialog that allows to select an enclosing type.
*
* @return returns the selected type or <code>null</code> if the dialog has been canceled.
* The caller typically sets the result to the enclosing type input field.
* <p>
* Clients can override this method if they want to offer a different dialog.
* </p>
*
* @since 3.2
*/
protected IType chooseEnclosingType() {
IPackageFragmentRoot root= getPackageFragmentRoot();
if (root == null) {
return null;
}
IJavaSearchScope scope= SearchEngine.createJavaSearchScope(new IJavaElement[] { root });
FilteredTypesSelectionDialog dialog= new FilteredTypesSelectionDialog(getShell(),
false, getWizard().getContainer(), scope, IJavaSearchConstants.TYPE);
dialog.setTitle(NewWizardMessages.NewTypeWizardPage_ChooseEnclosingTypeDialog_title);
dialog.setMessage(NewWizardMessages.NewTypeWizardPage_ChooseEnclosingTypeDialog_description);
dialog.setInitialPattern(Signature.getSimpleName(getEnclosingTypeText()));
if (dialog.open() == Window.OK) {
return (IType) dialog.getFirstResult();
}
return null;
}
示例7: run
@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);
}
}
示例8: run
@Override
public void run() {
Shell parent= fViewPart.getSite().getShell();
FilteredTypesSelectionDialog dialog= new FilteredTypesSelectionDialog(parent, false,
PlatformUI.getWorkbench().getProgressService(),
SearchEngine.createWorkspaceScope(), IJavaSearchConstants.TYPE);
dialog.setTitle(TypeHierarchyMessages.FocusOnTypeAction_dialog_title);
dialog.setMessage(TypeHierarchyMessages.FocusOnTypeAction_dialog_message);
if (dialog.open() != IDialogConstants.OK_ID) {
return;
}
Object[] types= dialog.getResult();
if (types != null && types.length > 0) {
IType type= (IType)types[0];
fViewPart.setInputElement(type);
}
}
示例9: getTotalNumberOfSettings
public static int getTotalNumberOfSettings(int searchFor) {
if (searchFor == IJavaSearchConstants.TYPE) {
return 15;
} else if (searchFor == IJavaSearchConstants.CONSTRUCTOR) {
return 1;
} else if (searchFor == IJavaSearchConstants.METHOD) {
return 5;
} else if (searchFor == IJavaSearchConstants.FIELD) {
return 4;
}
return 0;
}
示例10: isTypeSearch
private static boolean isTypeSearch(QuerySpecification query) {
if (query instanceof ElementQuerySpecification) {
return (((ElementQuerySpecification) query).getElement().getElementType() == IJavaElement.TYPE);
}
return (((PatternQuerySpecification) query).getSearchFor() == IJavaSearchConstants.TYPE);
}
示例11: getTotalNumberOfSettings
public static int getTotalNumberOfSettings(int searchFor) {
if (searchFor == IJavaSearchConstants.TYPE) {
return 15;
} else if (searchFor == IJavaSearchConstants.CONSTRUCTOR) {
return 1;
} else if (searchFor == IJavaSearchConstants.METHOD) {
return 5;
} else if (searchFor == IJavaSearchConstants.FIELD) {
return 4;
}
return 0;
}
示例12: getTotalNumberOfSettings
public static int getTotalNumberOfSettings(int searchFor) {
if (searchFor == IJavaSearchConstants.TYPE) {
return 15;
} else if (searchFor == IJavaSearchConstants.METHOD || searchFor == IJavaSearchConstants.FIELD) {
return 4;
}
return 0;
}
示例13: getSearchFor
@Override
public int getSearchFor() {
return IJavaSearchConstants.TYPE;
}
示例14: getNumberOfSelectedSettings
public static int getNumberOfSelectedSettings(int locations, int searchFor) {
int count = 0;
if (searchFor == IJavaSearchConstants.TYPE) {
if (isSet(locations, IJavaSearchConstants.IMPORT_DECLARATION_TYPE_REFERENCE)) {
count++;
}
if (isSet(locations, IJavaSearchConstants.SUPERTYPE_TYPE_REFERENCE)) {
count++;
}
if (isSet(locations, IJavaSearchConstants.ANNOTATION_TYPE_REFERENCE)) {
count++;
}
if (isSet(locations, IJavaSearchConstants.FIELD_DECLARATION_TYPE_REFERENCE)) {
count++;
}
if (isSet(locations, IJavaSearchConstants.LOCAL_VARIABLE_DECLARATION_TYPE_REFERENCE)) {
count++;
}
if (isSet(locations, IJavaSearchConstants.RETURN_TYPE_REFERENCE)) {
count++;
}
if (isSet(locations, IJavaSearchConstants.PARAMETER_DECLARATION_TYPE_REFERENCE)) {
count++;
}
if (isSet(locations, IJavaSearchConstants.THROWS_CLAUSE_TYPE_REFERENCE)) {
count++;
}
if (isSet(locations, IJavaSearchConstants.TYPE_VARIABLE_BOUND_TYPE_REFERENCE)) {
count++;
}
if (isSet(locations, IJavaSearchConstants.WILDCARD_BOUND_TYPE_REFERENCE)) {
count++;
}
if (isSet(locations, IJavaSearchConstants.INSTANCEOF_TYPE_REFERENCE)) {
count++;
}
if (isSet(locations, IJavaSearchConstants.TYPE_ARGUMENT_TYPE_REFERENCE)) {
count++;
}
if (isSet(locations, IJavaSearchConstants.CAST_TYPE_REFERENCE)) {
count++;
}
if (isSet(locations, IJavaSearchConstants.CATCH_TYPE_REFERENCE)) {
count++;
}
if (isSet(locations, IJavaSearchConstants.CLASS_INSTANCE_CREATION_TYPE_REFERENCE)) {
count++;
}
} else if (searchFor == IJavaSearchConstants.METHOD
|| searchFor == IJavaSearchConstants.FIELD) {
if (isSet(locations, IJavaSearchConstants.SUPER_REFERENCE)) {
count++;
}
if (isSet(locations, IJavaSearchConstants.QUALIFIED_REFERENCE)) {
count++;
}
if (isSet(locations, IJavaSearchConstants.THIS_REFERENCE)) {
count++;
}
if (isSet(locations, IJavaSearchConstants.IMPLICIT_THIS_REFERENCE)) {
count++;
}
}
if (searchFor == IJavaSearchConstants.METHOD || searchFor == IJavaSearchConstants.CONSTRUCTOR) {
if (isSet(locations, IJavaSearchConstants.METHOD_REFERENCE_EXPRESSION)) {
count++;
}
}
return count;
}
示例15: testPatternSearch
public void testPatternSearch() throws CoreException {
Match[] expected;
// Search for type references by simple name
expected = new Match[] {
createWindowsTestMatch(840, 50), createWindowsTestMatch(1207, 50),
createWindowsTestMatch(1419, 50)};
assertSearchMatches(expected, createQuery("InnerSub",
IJavaSearchConstants.TYPE));
// Search for type with different casing
expected = new Match[] {
createWindowsTestMatch(840, 50), createWindowsTestMatch(1207, 50),
createWindowsTestMatch(1419, 50)};
assertSearchMatches(expected, createQuery("innersub",
IJavaSearchConstants.TYPE));
// Search for type with different casing with case-sensitive enabled
QuerySpecification query = new PatternQuerySpecification("innersub",
IJavaSearchConstants.TYPE, true, IJavaSearchConstants.REFERENCES,
WORKSPACE_SCOPE, "");
assertSearchMatches(NO_MATCHES, query);
// Search for field references
assertSearchMatch(createWindowsTestMatch(990, 5), createQuery("keith",
IJavaSearchConstants.FIELD));
// Search for method references using * wildcard
expected = new Match[] {
createWindowsTestMatch(1174, 5), createWindowsTestMatch(1259, 5),
createWindowsTestMatch(1340, 8)};
assertSearchMatches(expected, createQuery("sayH*",
IJavaSearchConstants.METHOD));
// Search for method references using ? wildcard
expected = new Match[] {
createWindowsTestMatch(1174, 5), createWindowsTestMatch(1259, 5)};
assertSearchMatches(expected, createQuery("sayH?",
IJavaSearchConstants.METHOD));
// Search for constructor references with qualified type name and parameters
assertSearchMatch(createWindowsTestMatch(892, 3), createQuery(
"com.hello.client.JavaQueryParticipantTest.InnerSub.InnerSub(String)",
IJavaSearchConstants.CONSTRUCTOR));
}