Eclipse中没有的继承方法

时间:2015-04-21 10:22:54

标签: java eclipse inheritance

我正在对java代码进行语义分析。有些课程如下:

ClassOrInterfaceDeclaration -> TypeDeclaration -> BodyDeclaration -> Node

Node类是这样的:

public abstract class Node {

private final int beginLine;

private final int beginColumn;

private Scope enclosingScope;

@Deprecated
public Node(int line, int column) {
    this.beginLine = line;
    this.beginColumn = column;
    this.endLine = line;
    this.endColumn = column;
}

public Node(int beginLine, int beginColumn, int endLine, int endColumn) {
    this.beginLine = beginLine;
    this.beginColumn = beginColumn;
    this.endLine = endLine;
    this.endColumn = endColumn;
}

public void setMyScope(Scope enclosingScope) {
    this.enclosingScope = enclosingScope;
}

public Scope getMyScope() {
    return enclosingScope;
}

public final int getBeginLine() {
    return beginLine;
}

public final int getBeginColumn() {
    return beginColumn;
} ... ...

现在,当我从ClassOrInterfaceDeclaration的实例调用这些方法时,除了setMyScope()getMyScope()之外,任何方法都可用。有点新手。不知道为什么以及如何解决它。

ClassOrInterfaceDeclaration的代码如下:

public final class ClassOrInterfaceDeclaration extends TypeDeclaration {

private final List<AnnotationExpr> annotations;

private final boolean isInterface;

private final List<TypeParameter> typeParameters;

private final List<ClassOrInterfaceType> extendsList;

private final List<ClassOrInterfaceType> implementsList;

public ClassOrInterfaceDeclaration(int line, int column, JavadocComment javaDoc, int modifiers, List<AnnotationExpr> annotations, boolean isInterface, String name, List<TypeParameter> typeParameters, List<ClassOrInterfaceType> extendsList, List<ClassOrInterfaceType> implementsList, List<BodyDeclaration> members) {
    super(line, column, javaDoc, name, modifiers, members);
    this.annotations = annotations;
    this.isInterface = isInterface;
    this.typeParameters = typeParameters;
    this.extendsList = extendsList;
    this.implementsList = implementsList;
}

public List<AnnotationExpr> getAnnotations() {
    return annotations;
}

public boolean isInterface() {
    return isInterface;
}

public List<TypeParameter> getTypeParameters() {
    return typeParameters;
}

public List<ClassOrInterfaceType> getExtends() {
    return extendsList;
}

public List<ClassOrInterfaceType> getImplements() {
    return implementsList;
}

@Override
public <A> void accept(VoidVisitor<A> v, A arg) {
    v.visit(this, arg);
}

@Override
public <R, A> R accept(GenericVisitor<R, A> v, A arg) {
    return v.visit(this, arg);
}
}

TypeDeclaration和BodyDeclaration类似。其中没有关于行,列或范围的内容。但是,虽然beginLine()beginColumn()效果很好,但etMyScope(), getMyScope()却没有。我添加了后两种方法。我怀疑我做了一些愚蠢但却无法理解的事情。

1 个答案:

答案 0 :(得分:0)

这似乎是您无法引用最新课程版本的问题。 可能的问题:

  • 代码不会重新编译
  • 同一个src中的其他类可能存在编译错误。修复这些并再次编译。
  • 您的类路径中可能有jar文件路径,其中jar不会被最新的jar替换。

请检查是否勾选了所有这些方框。如果问题仍然存在,请告诉我们