package jetbrains.mps.lang.actions.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.CollectionSequence;
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.editor.runtime.impl.cellActions.CommentUtil;
import jetbrains.mps.lang.migration.runtime.base.MigrationScriptReference;
public class CommentOutOldActionsIfAutomaticallyMigrated extends MigrationScriptBase {
public String getCaption() {
return "Comment out old actions if all of them were automatically migrated by the previous migrations";
}
@Override
public boolean isRerunnable() {
return false;
}
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;
}
};
if (CollectionSequence.fromCollection(CommandUtil.instances(CommandUtil.createConsoleScope(null, false, context), MetaAdapterFactory.getInterfaceConcept(0xaee9cad2acd44608L, 0xaef20004f6a1cdbdL, 0x7650d61a085f9929L, "jetbrains.mps.lang.actions.structure.ICouldBeAnnotatedWithMigrateManually"), false)).any(new IWhereFilter<SNode>() {
public boolean accept(SNode it) {
return (AttributeOperations.getAttribute(it, new IAttributeDescriptor.NodeAttribute(MetaAdapterFactory.getConcept(0xaee9cad2acd44608L, 0xaef20004f6a1cdbdL, 0x7ce019826543db5L, "jetbrains.mps.lang.actions.structure.MigrateManuallyAnnotation"))) != null) && !(CommentUtil.isCommentedOut(it));
}
})) {
return;
}
Iterable<SNode> stBuilders = CollectionSequence.fromCollection(CommandUtil.instances(CommandUtil.createConsoleScope(null, false, context), MetaAdapterFactory.getConcept(0xaee9cad2acd44608L, 0xaef20004f6a1cdbdL, 0x108facec6d2L, "jetbrains.mps.lang.actions.structure.SideTransformHintSubstituteActionsBuilder"), false)).where(new IWhereFilter<SNode>() {
public boolean accept(SNode it) {
return !(CommentUtil.isCommentedOut(it));
}
});
CommentUtil.commentOutAll(stBuilders);
Iterable<SNode> substBuilders = CollectionSequence.fromCollection(CommandUtil.instances(CommandUtil.createConsoleScope(null, false, context), MetaAdapterFactory.getConcept(0xaee9cad2acd44608L, 0xaef20004f6a1cdbdL, 0x102ebd2e9eaL, "jetbrains.mps.lang.actions.structure.NodeSubstituteActionsBuilder"), false)).where(new IWhereFilter<SNode>() {
public boolean accept(SNode it) {
return !(CommentUtil.isCommentedOut(it));
}
});
CommentUtil.commentOutAll(substBuilders);
}
}
public MigrationScriptReference getDescriptor() {
return new MigrationScriptReference(MetaAdapterFactory.getLanguage(0xaee9cad2acd44608L, 0xaef20004f6a1cdbdL, "jetbrains.mps.lang.actions"), 2);
}
}