views:

45

answers:

1

hi,

i want to get the simple function name from the acceptsearchmatch method.For ex- say the match occurs in a fun foo(),how can i retreive just foo from match object?help thanks

+1  A: 

If I look at the same method in RefactoringSearchEngine2 class, could you do something similar, in order to check if it is a IMethod, and, if it is, get its name?

public final void acceptSearchMatch(final SearchMatch  match) throws CoreException  {
  final SearchMatch accepted= fRequestor.acceptSearchMatch(match);
  if (accepted != null) {
    fCollectedMatches.add(accepted);
    final IResource resource= accepted.getResource();
    if (!resource.equals(fLastResource)) {
      if (fBinary) {
        final IJavaElement element= JavaCore.create(resource);

For a IJavaElement, you can check if it is a IMethod, which should give you access to its name.

public String getElementName()

Returns the simple name of this method. For a constructor, this returns the simple name of the declaring type.

VonC
thanks....can you give me a link to the source code of search button in eclipse
Steven