Java Code Examples for org.eclipse.jdt.core.search.IJavaSearchConstants#FIELD

The following examples show how to use org.eclipse.jdt.core.search.IJavaSearchConstants#FIELD . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavaQueryParticipant.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
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());
}
 
Example 2
Source File: MatchLocations.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void createMethodFieldMatchLocationsControls(Composite contents) {

			Composite composite= new Composite(contents, SWT.NONE);
			GridData gd= new GridData(SWT.LEFT, SWT.BEGINNING, true, true, 2, 1);
			gd.minimumWidth= convertHorizontalDLUsToPixels(200);
			composite.setLayoutData(gd);
			GridLayout blayout= new GridLayout(1, false);
			blayout.marginWidth= 0;
			blayout.marginHeight= 0;
			composite.setLayout(blayout);

			if (fSearchFor == IJavaSearchConstants.METHOD || fSearchFor == IJavaSearchConstants.FIELD) {
				createButton(composite, SearchMessages.MatchLocations_this_label, IJavaSearchConstants.THIS_REFERENCE);
				createButton(composite, SearchMessages.MatchLocations_implicit_this_label, IJavaSearchConstants.IMPLICIT_THIS_REFERENCE);
	
				createButton(composite, SearchMessages.MatchLocations_super_label, IJavaSearchConstants.SUPER_REFERENCE);
				createButton(composite, SearchMessages.MatchLocations_qualified_label, IJavaSearchConstants.QUALIFIED_REFERENCE);
			}
			
			if (fSearchFor == IJavaSearchConstants.METHOD || fSearchFor == IJavaSearchConstants.CONSTRUCTOR) {
				createButton(composite, SearchMessages.MatchLocations_method_reference_label, IJavaSearchConstants.METHOD_REFERENCE_EXPRESSION);
			}
		}
 
Example 3
Source File: JavaMatchFilter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean isApplicable(JavaSearchQuery query) {
	QuerySpecification spec= query.getSpecification();
	if (spec instanceof ElementQuerySpecification) {
		ElementQuerySpecification elementSpec= (ElementQuerySpecification) spec;
		IJavaElement element= elementSpec.getElement();
		return element instanceof IField || element instanceof ILocalVariable;
	} else if (spec instanceof PatternQuerySpecification) {
		PatternQuerySpecification patternSpec= (PatternQuerySpecification) spec;
		return patternSpec.getSearchFor() == IJavaSearchConstants.FIELD;
	}
	return false;
}
 
Example 4
Source File: MatchLocations.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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;
}
 
Example 5
Source File: MatchLocations.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
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;
}