package jetbrains.mps.baseLanguage.lightweightdsl.migration;
/*Generated by MPS */
import jetbrains.mps.lang.migration.runtime.base.MigrationScriptBase;
import org.jetbrains.mps.openapi.model.SNode;
import org.jetbrains.mps.openapi.module.SModule;
import org.jetbrains.mps.openapi.module.SearchScope;
import jetbrains.mps.lang.smodel.query.runtime.CommandUtil;
import jetbrains.mps.lang.smodel.query.runtime.QueryExecutionContext;
import jetbrains.mps.internal.collections.runtime.Sequence;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations;
import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory;
import jetbrains.mps.internal.collections.runtime.IWhereFilter;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.AttributeOperations;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.IAttributeDescriptor;
import jetbrains.mps.internal.collections.runtime.IVisitor;
import jetbrains.mps.lang.migration.runtime.base.Problem;
import jetbrains.mps.internal.collections.runtime.ISelector;
import jetbrains.mps.lang.migration.runtime.base.NotMigratedNode;
import jetbrains.mps.lang.migration.runtime.base.MigrationScriptReference;
public class RemoveOddAnnotations extends MigrationScriptBase {
public String getCaption() {
return "Remove @dslclass annotations from instances of AutoInitDSLClass";
}
@Override
public boolean isRerunnable() {
return true;
}
public SNode execute(final SModule m) {
doExecute(m);
return null;
}
public void doExecute(final SModule m) {
{
final SearchScope scope = CommandUtil.createScope(m);
QueryExecutionContext context = new QueryExecutionContext() {
public SearchScope getDefaultSearchScope() {
return scope;
}
};
Sequence.fromIterable(SNodeOperations.ofConcept(CommandUtil.instances(CommandUtil.createConsoleScope(null, false, context), MetaAdapterFactory.getInterfaceConcept(0xc7d5b9dda05f4be2L, 0xbc73f2e16994cc67L, 0xea740fb893a13edL, "jetbrains.mps.baseLanguage.lightweightdsl.structure.AutoInitDSLClass"), false), MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c108ca66L, "jetbrains.mps.baseLanguage.structure.ClassConcept"))).where(new IWhereFilter<SNode>() {
public boolean accept(SNode it) {
return (AttributeOperations.getAttribute(it, new IAttributeDescriptor.NodeAttribute(MetaAdapterFactory.getConcept(0xc7d5b9dda05f4be2L, 0xbc73f2e16994cc67L, 0x3190d3f9f1cab0caL, "jetbrains.mps.baseLanguage.lightweightdsl.structure.DSLAnnotation"))) != null);
}
}).visitAll(new IVisitor<SNode>() {
public void visit(SNode it) {
SNodeOperations.deleteNode(AttributeOperations.getAttribute(it, new IAttributeDescriptor.NodeAttribute(MetaAdapterFactory.getConcept(0xc7d5b9dda05f4be2L, 0xbc73f2e16994cc67L, 0x3190d3f9f1cab0caL, "jetbrains.mps.baseLanguage.lightweightdsl.structure.DSLAnnotation"))));
}
});
}
}
@Override
public Iterable<Problem> check(SModule m) {
{
final SearchScope scope = CommandUtil.createScope(m);
QueryExecutionContext context = new QueryExecutionContext() {
public SearchScope getDefaultSearchScope() {
return scope;
}
};
return Sequence.fromIterable(SNodeOperations.ofConcept(CommandUtil.instances(CommandUtil.createConsoleScope(null, false, context), MetaAdapterFactory.getInterfaceConcept(0xc7d5b9dda05f4be2L, 0xbc73f2e16994cc67L, 0xea740fb893a13edL, "jetbrains.mps.baseLanguage.lightweightdsl.structure.AutoInitDSLClass"), false), MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c108ca66L, "jetbrains.mps.baseLanguage.structure.ClassConcept"))).where(new IWhereFilter<SNode>() {
public boolean accept(SNode it) {
return (AttributeOperations.getAttribute(it, new IAttributeDescriptor.NodeAttribute(MetaAdapterFactory.getConcept(0xc7d5b9dda05f4be2L, 0xbc73f2e16994cc67L, 0x3190d3f9f1cab0caL, "jetbrains.mps.baseLanguage.lightweightdsl.structure.DSLAnnotation"))) != null);
}
}).select(new ISelector<SNode, Problem>() {
public Problem select(SNode it) {
return ((Problem) new NotMigratedNode(it) {
public String getMessage() {
return "Unnecessary @dslclass annotation was not migrated";
}
});
}
});
}
}
public MigrationScriptReference getDescriptor() {
return new MigrationScriptReference(MetaAdapterFactory.getLanguage(0xc7d5b9dda05f4be2L, 0xbc73f2e16994cc67L, "jetbrains.mps.baseLanguage.lightweightdsl"), 0);
}
}