private boolean canExecute_internal( final KeyEvent keyEvent, final EditorContext editorContext, final SNode node, final List<SNode> selectedNodes) { if (ListSequence.fromList(selectedNodes).count() != 1) { return false; } if (SNodeOperations.getAncestorWhereConceptInList( node, new String[] { "jetbrains.mps.lang.generator.structure.TemplateDeclaration", "jetbrains.mps.lang.generator.structure.InlineTemplateWithContext_RuleConsequence" }, false, false) == null) { return false; } if (ListSequence.fromList(SNodeOperations.getAncestors(node, null, false)) .where( new IWhereFilter<SNode>() { public boolean accept(SNode it) { return SNodeOperations.isAttribute(it); } }) .isNotEmpty()) { return false; } if (QueriesUtil.isInsideTemplateFragment(node)) { return false; } return true; }
public static boolean static_canBeAChild( SNode node, SNode parentNode, SNode link, SNode childConcept, final IOperationContext operationContext) { return SNodeOperations.getAncestorWhereConceptInList( parentNode, new String[] { "jetbrains.mps.lang.findUsages.structure.FindBlock", "jetbrains.mps.lang.findUsages.structure.SearchedNodesBlock" }, false, false) != null; }
public static SNode getApplicableConcept_fromEnvironment(SNode node) { SNode ancestor = SNodeOperations.getAncestorWhereConceptInList( node, new String[] { "jetbrains.mps.lang.generator.structure.TemplateDeclaration", "jetbrains.mps.lang.generator.structure.BaseMappingRule", "jetbrains.mps.lang.generator.structure.PatternReduction_MappingRule" }, false, false); if (SNodeOperations.isInstanceOf( ancestor, "jetbrains.mps.lang.generator.structure.TemplateDeclaration")) { return SLinkOperations.getTarget( SNodeOperations.cast( ancestor, "jetbrains.mps.lang.generator.structure.TemplateDeclaration"), "applicableConcept", false); } if (SNodeOperations.isInstanceOf( ancestor, "jetbrains.mps.lang.generator.structure.PatternReduction_MappingRule")) { return PatternReduction_MappingRule_Behavior.call_getConcept_1805153994417064763( SNodeOperations.cast( ancestor, "jetbrains.mps.lang.generator.structure.PatternReduction_MappingRule")); } if (SNodeOperations.isInstanceOf( ancestor, "jetbrains.mps.lang.generator.structure.BaseMappingRule")) { return SLinkOperations.getTarget( SNodeOperations.cast(ancestor, "jetbrains.mps.lang.generator.structure.BaseMappingRule"), "applicableConcept", false); } // ============ SNode rootAnnotation = AttributeOperations.getAttribute( SNodeOperations.getContainingRoot(node), new IAttributeDescriptor.NodeAttribute( SConceptOperations.findConceptDeclaration( "jetbrains.mps.lang.generator.structure.RootTemplateAnnotation"))); return SLinkOperations.getTarget( SNodeOperations.cast( rootAnnotation, "jetbrains.mps.lang.generator.structure.RootTemplateAnnotation"), "applicableConcept", false); }
public static SNode findWrappableAncestor(SNode source, boolean isRoot) { Iterable<SNode> concepts = (isRoot ? TestNodeWrapperFactory.getWrappedRootConcepts() : TestNodeWrapperFactory.getWrappedNonRootConcepts()); return SNodeOperations.getAncestorWhereConceptInList( source, Sequence.fromIterable(concepts) .select( new ISelector<SNode, String>() { public String select(SNode it) { return BehaviorReflection.invokeVirtual( String.class, it, "virtual_getFqName_1213877404258", new Object[] {}); } }) .toGenericArray(String.class), true, isRoot); }
@InferenceMethod public static void equate_templateFunction_inputNodeType( final TypeCheckingContext typeCheckingContext, SNode contextNode, SNode InputNodeType) { SNode enclosingMacro = SNodeOperations.getAncestorWhereConceptInList( contextNode, new String[] { "jetbrains.mps.lang.generator.structure.PropertyMacro", "jetbrains.mps.lang.generator.structure.ReferenceMacro", "jetbrains.mps.lang.generator.structure.NodeMacro" }, false, false); if (enclosingMacro != null) { if (SNodeOperations.isInstanceOf( enclosingMacro, "jetbrains.mps.lang.generator.structure.MapSrcNodeMacro")) { // inside mapper func or post-mapper function? if ((SNodeOperations.getAncestorWhereConceptInList( contextNode, new String[] { "jetbrains.mps.lang.generator.structure.MapSrcMacro_MapperFunction", "jetbrains.mps.lang.generator.structure.MapSrcMacro_PostMapperFunction" }, true, false) != null)) { SNode query = SLinkOperations.getTarget( SNodeOperations.cast( enclosingMacro, "jetbrains.mps.lang.generator.structure.MapSrcNodeMacro"), "sourceNodeQuery", true); if (query != null) { QueriesUtil.equate_outputNodeType_fromSourceQuery( typeCheckingContext, query, InputNodeType); return; } } } if (SNodeOperations.isInstanceOf( enclosingMacro, "jetbrains.mps.lang.generator.structure.MapSrcListMacro")) { // inside mapper func or post-mapper function? if ((SNodeOperations.getAncestorWhereConceptInList( contextNode, new String[] { "jetbrains.mps.lang.generator.structure.MapSrcMacro_MapperFunction", "jetbrains.mps.lang.generator.structure.MapSrcMacro_PostMapperFunction" }, true, false) != null)) { SNode query = SLinkOperations.getTarget( SNodeOperations.cast( enclosingMacro, "jetbrains.mps.lang.generator.structure.MapSrcListMacro"), "sourceNodesQuery", true); if (query != null) { QueriesUtil.equate_outputNodeType_fromSourceQuery( typeCheckingContext, query, InputNodeType); return; } } } SNode enclosingNodeMacro = (SNodeOperations.isInstanceOf( enclosingMacro, "jetbrains.mps.lang.generator.structure.NodeMacro") ? enclosingMacro : null); SNode macroOwner = SNodeOperations.getParent(enclosingMacro); SNode prevSourceSubstituteMacro = QueriesUtil.getEnclosing_SourceSubstituteMacro(macroOwner, enclosingNodeMacro); if (prevSourceSubstituteMacro != null) { SNode query = QueriesUtil.getQueryFunction_fromSourceSubstituteMacro(prevSourceSubstituteMacro); QueriesUtil.equate_outputNodeType_fromSourceQuery( typeCheckingContext, query, InputNodeType); return; } } // =============== SNode applicableConcept = QueriesUtil.getApplicableConcept_fromEnvironment(contextNode); { SNode _nodeToCheck_1029348928467 = null; EquationInfo _info_12389875345 = new EquationInfo( _nodeToCheck_1029348928467, null, "r:00000000-0000-4000-0000-011c895902e4(jetbrains.mps.lang.generator.typesystem)", "1206286374200", 0, null); typeCheckingContext.createEquation( (SNode) _quotation_createNode_w9106s_a0e0a(applicableConcept), (SNode) InputNodeType, _info_12389875345); } }