package jetbrains.mps.migration.component.util; /*Generated by MPS */ import java.util.Set; import org.jetbrains.mps.openapi.model.SNode; import org.jetbrains.mps.openapi.module.SearchScope; import jetbrains.mps.internal.collections.runtime.SetSequence; import java.util.HashSet; import jetbrains.mps.internal.collections.runtime.Sequence; import jetbrains.mps.lang.smodel.query.runtime.CommandUtil; import jetbrains.mps.lang.smodel.query.runtime.QueryExecutionContext; import jetbrains.mps.internal.collections.runtime.ITranslator2; import org.jetbrains.mps.openapi.model.SReference; import jetbrains.mps.internal.collections.runtime.ISelector; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations; import jetbrains.mps.internal.collections.runtime.CollectionSequence; import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory; import jetbrains.mps.internal.collections.runtime.IWhereFilter; import jetbrains.mps.smodel.adapter.MetaAdapterByDeclaration; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SPropertyOperations; import jetbrains.mps.lang.smodel.generator.smodelAdapter.AttributeOperations; import jetbrains.mps.lang.smodel.generator.smodelAdapter.IAttributeDescriptor; public class DeprecatedUtil { public static Set<SNode> usagesOfDeprecated(SearchScope depScope, SearchScope s) { Set<SNode> usagesOfDeprecated = SetSequence.fromSet(new HashSet<SNode>()); SetSequence.fromSet(usagesOfDeprecated).addSequence(Sequence.fromIterable(DeprecatedUtil.usagesOfDeprecatedMeta(depScope, s))); SetSequence.fromSet(usagesOfDeprecated).addSequence(Sequence.fromIterable(DeprecatedUtil.usagesOfDeprecatedNodes(depScope, s))); return usagesOfDeprecated; } public static Set<SNode> deprecated(SearchScope s) { Set<SNode> deprecated = SetSequence.fromSet(new HashSet<SNode>()); SetSequence.fromSet(deprecated).addSequence(Sequence.fromIterable(depLinks(s))); SetSequence.fromSet(deprecated).addSequence(Sequence.fromIterable(depProps(s))); SetSequence.fromSet(deprecated).addSequence(Sequence.fromIterable(depConcepts(s))); SetSequence.fromSet(deprecated).addSequence(Sequence.fromIterable(depNodes(s))); return deprecated; } private static Iterable<SNode> usagesOfDeprecatedNodes(SearchScope depScope, SearchScope s) { { final SearchScope scope = CommandUtil.createScope(s); final QueryExecutionContext context = new QueryExecutionContext() { public SearchScope getDefaultSearchScope() { return scope; } }; return Sequence.fromIterable(DeprecatedUtil.depNodes(depScope)).translate(new ITranslator2<SNode, SReference>() { public Iterable<SReference> translate(SNode it) { return CommandUtil.usages(CommandUtil.createConsoleScope(null, false, context), it); } }).select(new ISelector<SReference, SNode>() { public SNode select(SReference it) { return it.getSourceNode(); } }); } } private static Iterable<SNode> usagesOfDeprecatedMeta(SearchScope depScope, SearchScope s) { { final SearchScope scope = CommandUtil.createScope(s); final QueryExecutionContext context = new QueryExecutionContext() { public SearchScope getDefaultSearchScope() { return scope; } }; Iterable<SNode> dc = DeprecatedUtil.depConcepts(depScope); Iterable<SNode> dci = Sequence.fromIterable(dc).translate(new ITranslator2<SNode, SNode>() { public Iterable<SNode> translate(SNode it) { return CommandUtil.instances(CommandUtil.createConsoleScope(null, false, context), SNodeOperations.asSConcept(SNodeOperations.asSConcept(it)), false); } }); Iterable<SNode> dcu = Sequence.fromIterable(dc).translate(new ITranslator2<SNode, SReference>() { public Iterable<SReference> translate(SNode it) { return CommandUtil.usages(CommandUtil.createConsoleScope(null, false, context), it); } }).select(new ISelector<SReference, SNode>() { public SNode select(SReference it) { return it.getSourceNode(); } }); Iterable<SNode> dp = DeprecatedUtil.depProps(depScope); Iterable<SNode> dpi = Sequence.fromIterable(dp).translate(new ITranslator2<SNode, SNode>() { public Iterable<SNode> translate(final SNode prop) { return CollectionSequence.fromCollection(CommandUtil.instances(CommandUtil.createConsoleScope(null, false, context), SNodeOperations.asSConcept(SNodeOperations.asSConcept(SNodeOperations.getNodeAncestor(prop, MetaAdapterFactory.getConcept(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0x1103553c5ffL, "jetbrains.mps.lang.structure.structure.AbstractConceptDeclaration"), false, false))), false)).where(new IWhereFilter<SNode>() { public boolean accept(SNode ins) { return ins.getProperty(MetaAdapterByDeclaration.getProperty(prop)) != null; } }); } }); Iterable<SNode> dpu = Sequence.fromIterable(dp).translate(new ITranslator2<SNode, SReference>() { public Iterable<SReference> translate(SNode it) { return CommandUtil.usages(CommandUtil.createConsoleScope(null, false, context), it); } }).select(new ISelector<SReference, SNode>() { public SNode select(SReference it) { return it.getSourceNode(); } }); Iterable<SNode> dl = DeprecatedUtil.depLinks(depScope); Iterable<SNode> dli = Sequence.fromIterable(dl).where(new IWhereFilter<SNode>() { public boolean accept(SNode it) { return SPropertyOperations.hasValue(it, MetaAdapterFactory.getProperty(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0xf979bd086aL, 0xf980556927L, "metaClass"), "aggregation", "reference"); } }).translate(new ITranslator2<SNode, SNode>() { public Iterable<SNode> translate(final SNode link) { return CollectionSequence.fromCollection(CommandUtil.instances(CommandUtil.createConsoleScope(null, false, context), SNodeOperations.asSConcept(SNodeOperations.asSConcept(SNodeOperations.getNodeAncestor(link, MetaAdapterFactory.getConcept(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0x1103553c5ffL, "jetbrains.mps.lang.structure.structure.AbstractConceptDeclaration"), false, false))), false)).where(new IWhereFilter<SNode>() { public boolean accept(SNode ins) { return ins.getChildren(MetaAdapterByDeclaration.getContainmentLink(link)).iterator().hasNext(); } }); } }); Iterable<SNode> dri = Sequence.fromIterable(dl).where(new IWhereFilter<SNode>() { public boolean accept(SNode it) { return SPropertyOperations.hasValue(it, MetaAdapterFactory.getProperty(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0xf979bd086aL, 0xf980556927L, "metaClass"), "reference", "reference"); } }).translate(new ITranslator2<SNode, SNode>() { public Iterable<SNode> translate(final SNode link) { return CollectionSequence.fromCollection(CommandUtil.instances(CommandUtil.createConsoleScope(null, false, context), SNodeOperations.asSConcept(SNodeOperations.asSConcept(SNodeOperations.getNodeAncestor(link, MetaAdapterFactory.getConcept(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0x1103553c5ffL, "jetbrains.mps.lang.structure.structure.AbstractConceptDeclaration"), false, false))), false)).where(new IWhereFilter<SNode>() { public boolean accept(SNode ins) { return ins.getReference(MetaAdapterByDeclaration.getReferenceLink(link)) != null; } }); } }); Iterable<SNode> dlu = Sequence.fromIterable(dl).translate(new ITranslator2<SNode, SReference>() { public Iterable<SReference> translate(SNode it) { return CommandUtil.usages(CommandUtil.createConsoleScope(null, false, context), it); } }).select(new ISelector<SReference, SNode>() { public SNode select(SReference it) { return it.getSourceNode(); } }); return Sequence.fromIterable(dci).union(Sequence.fromIterable(dpi)).union(Sequence.fromIterable(dli)).union(Sequence.fromIterable(dri)).union(Sequence.fromIterable(dcu)).union(Sequence.fromIterable(dpu)).union(Sequence.fromIterable(dlu)); } } private static Iterable<SNode> depNodes(SearchScope depScope) { { final SearchScope scope = CommandUtil.createScope(depScope); QueryExecutionContext context = new QueryExecutionContext() { public SearchScope getDefaultSearchScope() { return scope; } }; return CollectionSequence.fromCollection(CommandUtil.usages(CommandUtil.createConsoleScope(null, false, context), SNodeOperations.getNode("6354ebe7-c22a-4a0f-ac54-50b52ab9b065/java:java.lang(JDK/)", "~Deprecated"))).where(new IWhereFilter<SReference>() { public boolean accept(SReference it) { return it.getLink() == MetaAdapterFactory.getReferenceLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x114a6b4ccabL, 0x114a6b85d40L, "annotation"); } }).select(new ISelector<SReference, SNode>() { public SNode select(SReference it) { return it.getSourceNode(); } }); } } private static Iterable<SNode> depLinks(SearchScope depScope) { { final SearchScope scope = CommandUtil.createScope(depScope); QueryExecutionContext context = new QueryExecutionContext() { public SearchScope getDefaultSearchScope() { return scope; } }; return CollectionSequence.fromCollection(CommandUtil.instances(CommandUtil.createConsoleScope(null, false, context), MetaAdapterFactory.getConcept(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0xf979bd086aL, "jetbrains.mps.lang.structure.structure.LinkDeclaration"), false)).where(new IWhereFilter<SNode>() { public boolean accept(SNode it) { return !((AttributeOperations.getAttribute(SNodeOperations.getNodeAncestor(it, MetaAdapterFactory.getConcept(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0x1103553c5ffL, "jetbrains.mps.lang.structure.structure.AbstractConceptDeclaration"), false, false), new IAttributeDescriptor.NodeAttribute(MetaAdapterFactory.getConcept(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0x11d0a70ae54L, "jetbrains.mps.lang.structure.structure.DeprecatedNodeAnnotation"))) == null)) && (AttributeOperations.getAttribute(it, new IAttributeDescriptor.NodeAttribute(MetaAdapterFactory.getConcept(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0x11d0a70ae54L, "jetbrains.mps.lang.structure.structure.DeprecatedNodeAnnotation"))) != null); } }); } } private static Iterable<SNode> depProps(SearchScope depScope) { { final SearchScope scope = CommandUtil.createScope(depScope); QueryExecutionContext context = new QueryExecutionContext() { public SearchScope getDefaultSearchScope() { return scope; } }; return CollectionSequence.fromCollection(CommandUtil.instances(CommandUtil.createConsoleScope(null, false, context), MetaAdapterFactory.getConcept(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0xf979bd086bL, "jetbrains.mps.lang.structure.structure.PropertyDeclaration"), false)).where(new IWhereFilter<SNode>() { public boolean accept(SNode it) { return !((AttributeOperations.getAttribute(SNodeOperations.getNodeAncestor(it, MetaAdapterFactory.getConcept(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0x1103553c5ffL, "jetbrains.mps.lang.structure.structure.AbstractConceptDeclaration"), false, false), new IAttributeDescriptor.NodeAttribute(MetaAdapterFactory.getConcept(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0x11d0a70ae54L, "jetbrains.mps.lang.structure.structure.DeprecatedNodeAnnotation"))) == null)) && (AttributeOperations.getAttribute(it, new IAttributeDescriptor.NodeAttribute(MetaAdapterFactory.getConcept(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0x11d0a70ae54L, "jetbrains.mps.lang.structure.structure.DeprecatedNodeAnnotation"))) != null); } }); } } private static Iterable<SNode> depConcepts(SearchScope depScope) { { final SearchScope scope = CommandUtil.createScope(depScope); QueryExecutionContext context = new QueryExecutionContext() { public SearchScope getDefaultSearchScope() { return scope; } }; return CollectionSequence.fromCollection(CommandUtil.instances(CommandUtil.createConsoleScope(null, false, context), MetaAdapterFactory.getConcept(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0x1103553c5ffL, "jetbrains.mps.lang.structure.structure.AbstractConceptDeclaration"), false)).where(new IWhereFilter<SNode>() { public boolean accept(SNode it) { return (AttributeOperations.getAttribute(it, new IAttributeDescriptor.NodeAttribute(MetaAdapterFactory.getConcept(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0x11d0a70ae54L, "jetbrains.mps.lang.structure.structure.DeprecatedNodeAnnotation"))) != null); } }); } } }