示例#1
0
 public void SetCurrentRuleForMatchAnnotation(IRulePattern curRulePattern)
 {
     this.curRulePatternForMatchAnnotation = curRulePattern;
 }
示例#2
0
 public void SetCurrentRule(IRulePattern curRulePattern)
 {
     this.curRulePattern = curRulePattern;
 }
示例#3
0
 private static bool IsFilterVariable(string variable, IRulePattern rulePattern)
 {
     foreach(IPatternVariable patternVariable in rulePattern.PatternGraph.Variables)
     {
         if(patternVariable.UnprefixedName == variable)
             return true;
     }
     return false;
 }
示例#4
0
        void DebugMatched(IMatches matches, IMatch match, bool special)
        {
            if(matches.Count == 0) // happens e.g. from compiled sequences firing the event always, but the Finishing only comes in case of Count!=0
                return;

            // integrate matched actions into subrule traces stack
            computationsEnteredStack.Add(new SubruleComputation(matches.Producer.Name));

            SubruleDebuggingConfigurationRule cr;
            SubruleDebuggingDecision d = shellProcEnv.SubruleDebugConfig.Decide(SubruleDebuggingEvent.Match, 
                matches, shellProcEnv.ProcEnv, out cr);
            if(d == SubruleDebuggingDecision.Break)
                InternalHalt(cr, matches);
            else if(d == SubruleDebuggingDecision.Continue)
            {
                recentlyMatched = lastlyEntered;
                if(!detailedMode)
                    return;
                if(recordMode)
                {
                    DebugFinished(null, false);
                    matchDepth++;
                    annotatedNodes.Clear();
                    annotatedEdges.Clear();
                }
                return;
            }

            if(dynamicStepMode && !skipMode)
            {
                skipMode = true;
                ycompClient.UpdateDisplay();
                ycompClient.Sync();
                context.highlightSeq = lastlyEntered;
                context.success = true;
                PrintSequence(debugSequences.Peek(), context, debugSequences.Count);
                Console.WriteLine();

                if(!QueryUser(lastlyEntered))
                {
                    recentlyMatched = lastlyEntered;
                    return;
                }
            }

            recentlyMatched = lastlyEntered;

            if(!detailedMode)
                return;

            if(recordMode)
            {
                DebugFinished(null, false);
                matchDepth++;
                if(outOfDetailedMode)
                {
                    annotatedNodes.Clear();
                    annotatedEdges.Clear();
                    return;
                }
            }

            if(matchDepth++ > 0 || computationsEnteredStack.Count > 0)
                Console.WriteLine("Matched " + matches.Producer.Name);

            annotatedNodes.Clear();
            annotatedEdges.Clear();

            curRulePattern = matches.Producer.RulePattern;

            if(ycompClient.dumpInfo.IsExcludedGraph())
            {
                if(!recordMode)
                {
                    ycompClient.ClearGraph();
                    excludedGraphNodesIncluded.Clear();
                    excludedGraphEdgesIncluded.Clear();
                }

                // add all elements from match to graph and excludedGraphElementsIncluded
                if(match != null)
                    AddNeededGraphElements(match);
                else
                    AddNeededGraphElements(matches);

                AddNeighboursAndParentsOfNeededGraphElements();
            }

            if(match!=null)
                MarkMatch(match, realizers.MatchedNodeRealizer, realizers.MatchedEdgeRealizer);
            else
                MarkMatches(matches, realizers.MatchedNodeRealizer, realizers.MatchedEdgeRealizer);
            if(match!=null)
                AnnotateMatch(match, true);
            else
                AnnotateMatches(matches, true);

            ycompClient.UpdateDisplay();
            ycompClient.Sync();
            Console.WriteLine("Press any key to apply rewrite...");
            ReadKeyWithCancel();

            if(match!=null)
                MarkMatch(match, null, null);
            else
                MarkMatches(matches, null, null);

            recordMode = true;
            ycompClient.NodeRealizerOverride = realizers.NewNodeRealizer;
            ycompClient.EdgeRealizerOverride = realizers.NewEdgeRealizer;
            nextAddedNodeIndex = 0;
            nextAddedEdgeIndex = 0;
        }
示例#5
0
 public static bool IsGeneratedFilter(string filter, IRulePattern rulePattern)
 {
     if(filter.IndexOf('_')!=-1)
     {
         string filterBase = filter.Substring(0, filter.IndexOf('_'));
         string filterVariable = filter.Substring(filter.IndexOf('_') + 1);
         if(filterBase=="orderAscendingBy" || filterBase=="orderDescendingBy"
             || filterBase=="groupBy" || filterBase=="keepSameAsFirst"
             || filterBase=="keepSameAsLast" || filterBase=="keepOneForEach")
         {
             if(IsFilterVariable(filterVariable, rulePattern))
                 return true;
         }
     }
     if(filter == "auto")
         return true;
     return false;
 }