简体   繁体   English

蚀日光中代码的识别

[英]Identification of code in eclipse helios

How is possible to identify if a selected code is a method, a function, a variable...??? 如何确定所选代码是方法,函数,变量...?

public class Modifiers implements IObjectActionDelegate{
private Shell shell;

public void run(IAction action) {
    SelectedText selectedText;      
    IEditorPart editor = getActiveEditor();

    if (editor instanceof AbstractTextEditor) {
        selectedText = getSelectedText(editor);

        //HOW TO IDENTIFY THE SELECTED CODE         
    }
}

public void selectionChanged(IAction action, ISelection selection) {        
}

public void setActivePart(IAction action, IWorkbenchPart targetPart) {
    shell = targetPart.getSite().getShell();
}

private IEditorPart getActiveEditor() {
    return Activator.getDefault().getWorkbench().getActiveWorkbenchWindow()
            .getActivePage().getActiveEditor();
}

private SelectedText getSelectedText(IEditorPart editor) {
    SelectedText selectedText;

    try {
        final ISelection selection = editor.getEditorSite().getSelectionProvider().getSelection();
        final ITextSelection textSelection = (ITextSelection) selection;
        selectedText = new SelectedText(textSelection.getText(), textSelection.getOffset(), textSelection.getLength());
    } catch (Exception e) {
        selectedText = new SelectedText("", 0, 0);
    }
    return selectedText;
}

} }

As you can see I have the selected code in selectedText . 正如你可以看到我有选择的代码selectedText Now I want to know is how can I identify if the code in that variable is a method, a variable or whatever it contains. 现在,我想知道如何识别该变量中的代码是方法,变量还是其中的任何内容。

When doing Refactors with eclipse it shows the code information you have selected. 使用Eclipse进行重构时,它会显示您选择的代码信息。 The idea is to do something like that. 想法是做类似的事情。

Thanks for your help. 谢谢你的帮助。

If i am correct,you need to simply move your mouse pointer on the code about which you want to get details, it will display a pop up window containing the details with specific symbol such as for static variable it will display 's' in that symbol or icon. 如果我是正确的,您只需在要获取详细信息的代码上移动鼠标指针,它将显示一个弹出窗口,其中包含带有特定符号的详细信息,例如静态变量,它将在其中显示“ s”符号或图标。

See carefully each symbol containing the different 2 letter and color has its own meaning. 仔细查看每个包含不同2个字母和颜色的符号都有其自身的含义。 ie green for public , red for private and gray for local etc. 例如, 绿色代表公共红色代表私有灰色代表本地等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM