代码之家  ›  专栏  ›  技术社区  ›  fastcodejava

指定的元素类型不支持操作

  •  1
  • fastcodejava  · 技术社区  · 15 年前

    我在一个eclipse插件中得到这个错误。代码如下:

    ICompilationUnit testCU = findTestUnit(type);
    // add some stuff to testCU
    testCU.commitWorkingCopy(false, null);    // error happens here.
    
    1 回复  |  直到 15 年前
        1
  •  1
  •   duffymo    15 年前

    我猜你在用 this interface

    void commitWorkingCopy(boolean force, IProgressMonitor monitor) throws JavaModelException;
    

    也许你可以试试 null IProgressMonitor .

    另一个想法是查看该方法调用返回的类型,并确保它实现了正确的接口。也许这是不对的。