Skip to content

Commit

Permalink
metamodel #226: added container to TopLevelOrMemberDeclaration
Browse files Browse the repository at this point in the history
  • Loading branch information
FroMage committed Sep 4, 2013
1 parent 5fa7eb6 commit dc0d1a5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,17 @@ public boolean getShared() {
return declaration.isShared();
}

@Override
public ceylon.language.model.declaration.AnnotatedDeclaration getContainer() {
Scope container = declaration.getContainer();
if(container instanceof com.redhat.ceylon.compiler.typechecker.model.Declaration)
return Metamodel.getOrCreateMetamodel((com.redhat.ceylon.compiler.typechecker.model.Declaration)container);
if(container instanceof com.redhat.ceylon.compiler.typechecker.model.Package)
return Metamodel.getOrCreateMetamodel((com.redhat.ceylon.compiler.typechecker.model.Package)container);
// FIXME: can that happen?
throw new RuntimeException("Illegal container type: "+container);
}

@Override
@TypeInfo("ceylon.language::Sequential<Annotation>")
@TypeParameters(@TypeParameter(value = "Annotation", satisfies = "ceylon.language.model::Annotation<Annotation>"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ shared interface TopLevelOrMemberDeclaration of FunctionOrValueDeclaration |

// FIXME: that name sucks
shared formal Package packageContainer;

// FIXME: introduce interface ContainedDeclaration { shared formal AnnotatedDeclaration container; }?
// that would allow to go all the way up to Module as long as the container is a ContainedDeclaration.
// Alternatively we could make this an attribute of AnnotatedDeclaration and make it optional, where for Module it would be null,
// which would allow us to go all the way up to the module.
// Other question is should TypeParameter have a container? I don't think we consider it a member, so not sure
shared formal AnnotatedDeclaration container;

shared formal Boolean toplevel;
}

0 comments on commit dc0d1a5

Please sign in to comment.