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

The following examples show how to use org.eclipse.jdt.core.search.IJavaSearchConstants#READ_ACCESSES . 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: SelectFieldModeAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public SelectFieldModeAction(CallHierarchyViewPart v, int mode) {
        super(null, AS_RADIO_BUTTON);
        if (mode == IJavaSearchConstants.REFERENCES) {
            setText(CallHierarchyMessages.SelectFieldModeAction_all_references_label);
            setDescription(CallHierarchyMessages.SelectFieldModeAction_all_references_description);
        } else if (mode == IJavaSearchConstants.READ_ACCESSES) {
            setText(CallHierarchyMessages.SelectFieldModeAction_read_accesses_label);
            setDescription(CallHierarchyMessages.SelectFieldModeAction_read_accesses_description);
        } else if (mode == IJavaSearchConstants.WRITE_ACCESSES) {
            setText(CallHierarchyMessages.SelectFieldModeAction_write_accesses_label);
            setDescription(CallHierarchyMessages.SelectFieldModeAction_write_accesses_description);
        } else {
            Assert.isTrue(false);
        }
        fView= v;
        fMode= mode;
        // FIXME(stephan) adjust/create new help context
//        PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_TOGGLE_CALL_MODE_ACTION);
    }
 
Example 2
Source File: CallHierarchyViewPart.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void initFieldMode() {
    int mode;

    try {
        mode = fDialogSettings.getInt(DIALOGSTORE_FIELD_MODE);

        switch (mode) {
        	case IJavaSearchConstants.REFERENCES:
        	case IJavaSearchConstants.READ_ACCESSES:
        	case IJavaSearchConstants.WRITE_ACCESSES:
        		break; // OK
        default:
        	mode = IJavaSearchConstants.REFERENCES;
        }
    } catch (NumberFormatException e) {
        mode = IJavaSearchConstants.REFERENCES;
    }

    // force the update
    fCurrentFieldMode = -1;

    // will fill the main tool bar
    setFieldMode(mode);
}
 
Example 3
Source File: CallerMethodWrapper.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean canHaveChildren() {
	IMember member= getMember();
	if (member instanceof IField) {
		if (getLevel() == 1)
			return true;
		int mode= getFieldSearchMode();
		return mode == IJavaSearchConstants.REFERENCES || mode == IJavaSearchConstants.READ_ACCESSES;
	}
	return member instanceof IMethod || member instanceof IType;
}
 
Example 4
Source File: VariablePattern.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public VariablePattern(int patternKind, char[] name, int limitTo, int matchRule) {
	super(patternKind, matchRule);

    this.fineGrain = limitTo & FINE_GRAIN_MASK;
    if (this.fineGrain == 0) {
		switch (limitTo & 0xF) {
			case IJavaSearchConstants.DECLARATIONS :
				this.findDeclarations = true;
				break;
			case IJavaSearchConstants.REFERENCES :
				this.readAccess = true;
				this.writeAccess = true;
				break;
			case IJavaSearchConstants.READ_ACCESSES :
				this.readAccess = true;
				break;
			case IJavaSearchConstants.WRITE_ACCESSES :
				this.writeAccess = true;
				break;
			case IJavaSearchConstants.ALL_OCCURRENCES :
				this.findDeclarations = true;
				this.readAccess = true;
				this.writeAccess = true;
				break;
		}
		this.findReferences = this.readAccess || this.writeAccess;
    }

	this.name = (this.isCaseSensitive || this.isCamelCase) ? name : CharOperation.toLowerCase(name);
}
 
Example 5
Source File: JavaQueryParticipant.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 4 votes vote down vote up
public void search(ISearchRequestor requestor, QuerySpecification query,
    IProgressMonitor monitor) throws CoreException {
  try {
    monitor.subTask("Locating GWT matches...");

    // Make sure we're searching for Java references
    switch (query.getLimitTo()) {
      case IJavaSearchConstants.REFERENCES:
      case IJavaSearchConstants.ALL_OCCURRENCES:
        // These we handle as expected
        break;
      case IJavaSearchConstants.READ_ACCESSES:
      case IJavaSearchConstants.WRITE_ACCESSES:
        // We don't actually check field references to see if they're read or
        // write accesses; we just treat this as a generic references search
        break;
      default:
        // Anything else (e.g., Declarations), we don't support
        return;
    }

    Set<IIndexedJavaRef> matchingJavaRefs = null;

    // Find all matching Java references in the index. The search algorithm
    // differs depending on whether we're doing an element query
    // (Ctrl-Shift-G) or a pattern query (Java Search dialog box)
    if (query instanceof ElementQuerySpecification) {
      ElementQuerySpecification elementQuery = (ElementQuerySpecification) query;
      matchingJavaRefs = findMatches(elementQuery, true);
    } else {
      assert (query instanceof PatternQuerySpecification);
      PatternQuerySpecification patternQuery = (PatternQuerySpecification) query;
      matchingJavaRefs = findMatches(patternQuery);
    }

    for (IIndexedJavaRef javaRef : matchingJavaRefs) {
      Match match = createMatch(javaRef, query);
      if (match != null) {
        // Report the match location to the Java Search engine
        requestor.reportMatch(match);
      }
    }
  } catch (Exception e) {
    // If we allow any exceptions to escape, the JDT will disable us
    GWTPluginLog.logError("Error finding Java Search matches", e);
  }
}
 
Example 6
Source File: FindReadReferencesInHierarchyAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
int getLimitTo() {
	return IJavaSearchConstants.READ_ACCESSES;
}
 
Example 7
Source File: FindReadReferencesInWorkingSetAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
int getLimitTo() {
	return IJavaSearchConstants.READ_ACCESSES;
}
 
Example 8
Source File: FindReadReferencesAction.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
int getLimitTo() {
	return IJavaSearchConstants.READ_ACCESSES;
}
 
Example 9
Source File: CallHierarchyViewPart.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private void makeActions() {
      fRefreshViewAction = new RefreshViewAction(this);
      fRefreshSingleElementAction= new RefreshElementAction(fCallHierarchyViewer);

new CallHierarchyOpenEditorHelper(fLocationViewer);
new CallHierarchyOpenEditorHelper(fCallHierarchyViewer);

fOpenLocationAction= new OpenLocationAction(this, getSite());
fLocationCopyAction= fLocationViewer.initCopyAction(getViewSite(), fClipboard);
      fFocusOnSelectionAction = new FocusOnSelectionAction(this);
      fCopyAction= new CopyCallHierarchyAction(this, fClipboard, fCallHierarchyViewer);
      fSearchScopeActions = new SearchScopeActionGroup(this, fDialogSettings);
      fShowSearchInDialogAction= new ShowSearchInDialogAction(this, fCallHierarchyViewer);
      fFiltersActionGroup = new CallHierarchyFiltersActionGroup(this,
              fCallHierarchyViewer);
      fHistoryDropDownAction = new HistoryDropDownAction(this);
      fHistoryDropDownAction.setEnabled(false);
      fCancelSearchAction = new CancelSearchAction(this);
      setCancelEnabled(false);
      fExpandWithConstructorsAction= new ExpandWithConstructorsAction(this, fCallHierarchyViewer);
      fRemoveFromViewAction= new RemoveFromViewAction(this, fCallHierarchyViewer);
      fPinViewAction= new PinCallHierarchyViewAction(this);
      fToggleOrientationActions = new ToggleOrientationAction[] {
              new ToggleOrientationAction(this, VIEW_ORIENTATION_VERTICAL),
              new ToggleOrientationAction(this, VIEW_ORIENTATION_HORIZONTAL),
              new ToggleOrientationAction(this, VIEW_ORIENTATION_AUTOMATIC),
              new ToggleOrientationAction(this, VIEW_ORIENTATION_SINGLE)
          };
fRemoveFromViewAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_DELETE);
      fToggleCallModeActions = new ToggleCallModeAction[] {
              new ToggleCallModeAction(this, CALL_MODE_CALLERS),
              new ToggleCallModeAction(this, CALL_MODE_CALLEES)
          };
      fToggleFieldModeActions = new SelectFieldModeAction[] {
              new SelectFieldModeAction(this, IJavaSearchConstants.REFERENCES),
              new SelectFieldModeAction(this, IJavaSearchConstants.READ_ACCESSES),
              new SelectFieldModeAction(this, IJavaSearchConstants.WRITE_ACCESSES)
          };
      fActionGroups = new CompositeActionGroup(new ActionGroup[] {
                  new OpenEditorActionGroup(this),
                  new OpenViewActionGroup(this),
			new CCPActionGroup(this, true),
                  new GenerateActionGroup(this),
                  new RefactorActionGroup(this),
                  new JavaSearchActionGroup(this),
                  fSearchScopeActions, fFiltersActionGroup
              });
  }
 
Example 10
Source File: CallHierarchyViewPart.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Computes the content description for the call hierarchy computation.
 * 
 * @param includeMask the include mask
 * @return the content description
 * @since 3.7
 */
private String computeContentDescription(int includeMask) {
	// see also HistoryAction.getElementLabel(IMember[])
	String scopeDescription= fSearchScopeActions.getFullDescription(includeMask);

	if (fInputElements.length == 1) {
		IMember element= fInputElements[0];
		String elementName= JavaElementLabels.getElementLabel(element, JavaElementLabels.ALL_DEFAULT);
		String[] args= new String[] { elementName, scopeDescription };
		if (fCurrentCallMode == CALL_MODE_CALLERS) {
			switch (element.getElementType()) {
				case IJavaElement.TYPE:
					return Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsToConstructors, args);
				case IJavaElement.FIELD:
					switch (this.fCurrentFieldMode) {
			            case IJavaSearchConstants.READ_ACCESSES:
							return Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsToFieldRead, args);
			            case IJavaSearchConstants.WRITE_ACCESSES:
							return Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsToFieldWrite, args);
						default: // all references
							return Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsToField, args);
					}
				case IJavaElement.METHOD:
				case IJavaElement.INITIALIZER:
				default:
					return Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsToMethod, args);
			}
		} else {
			switch (element.getElementType()) {
				case IJavaElement.TYPE:
					return Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsFromConstructors, args);
				case IJavaElement.FIELD:
				case IJavaElement.METHOD:
				case IJavaElement.INITIALIZER:
				default:
					return Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsFromMethod, args);
			}
		}

	} else {
		if (fCurrentCallMode == CALL_MODE_CALLERS) {
			switch (fInputElements.length) {
	        	case 0:
	        		Assert.isTrue(false);
	        		return null;
	        	case 2:
	        		return Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsToMembers_2,
	        				new String[] { getShortLabel(fInputElements[0]), getShortLabel(fInputElements[1]), scopeDescription });

	        	default:
	        		return Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsToMembers_more,
	        				new String[] { getShortLabel(fInputElements[0]), getShortLabel(fInputElements[1]), scopeDescription });
			}
		} else {
			switch (fInputElements.length) {
				case 0:
					Assert.isTrue(false);
					return null;
				case 2:
					return Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsFromMembers_2,
							new String[] { getShortLabel(fInputElements[0]), getShortLabel(fInputElements[1]), scopeDescription });

				default:
					return Messages.format(CallHierarchyMessages.CallHierarchyViewPart_callsFromMembers_more,
							new String[] { getShortLabel(fInputElements[0]), getShortLabel(fInputElements[1]), scopeDescription });
			}
		}
	}
}