2

我有一个扩展的类型DeleteResourceAction。Eclipse 给了我以下警告:

An anonymous type defined in mishanesterenko.changevisualizer.command.handler.DeleteResourceCommandHandler.execute(ExecutionEvent) illegally extends DeleteResourceAction

这个警告的原因是什么?

UPD

我有以下生成警告的代码:

DeleteResourceAction deleteAction = new org.eclipse.ui.actions.DeleteResourceAction(new CustomShellProvider(activeWindow)) {
            @Override
            public IStructuredSelection getStructuredSelection() {
                IStructuredSelection selection = (IStructuredSelection) selectionService.getSelection();
                Object element = selection.getFirstElement();
                if (element instanceof CustomProject) {
                    return new StructuredSelection(((CustomProject) element).getProject());
                }
                return selection;
            }
        };
4

2 回答 2

2

看一下API就会发现这DeleteResourceAction并不意味着要被子类化。匿名类是子类。

于 2012-05-01T23:13:05.110 回答
2

在 DeleteResourceAction javadoc 中有一个明确的请求不要扩展该类。

http://download.eclipse.org/eclipse/downloads/drops/S-3.8M3-201110271800/testresults/reports/org.eclipse.ui.ide_3.8.0.v20111007-1312/org.eclipse.ui.ide/org .eclipse.ui.actions/DeleteResourceAction.java.html

于 2012-05-01T23:13:20.830 回答