2010-02-03 58 views
1

我想从acceptsearchmatch method.For EX-说,在一个有趣的FOO()发生在比赛的简单函数的名字,我怎么能retreive刚刚从匹配对象foo?帮助 感谢导出功能名称

+0

说什么?!你能否详细说明一下? – 2010-02-03 08:59:20

+0

searchMatch.getElement会为您返回什么? – willcodejavaforfood 2010-02-03 09:15:30

回答

1

如果我查看same method in RefactoringSearchEngine2 class,你能否做类似的事情,以检查它是否是IMethod,并且如果是,请获取它的名字?

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); 

对于IJavaElement,你可以检查它是否是一个IMethod,这应该给你访问它的名称。

public String getElementName() 

返回此方法的简单名称。对于构造函数,这将返回声明类型的简单名称。

+0

谢谢....你能给我一个链接到Eclipse中的搜索按钮的源代码 – Steven 2010-02-03 10:16:34