CloneWithReplacementAnnotation() public static method

public static CloneWithReplacementAnnotation ( AstNode node, AstNode replacedNode ) : AstNode
node AstNode
replacedNode AstNode
return AstNode
コード例 #1
0
        void AddNewVariable(IVariable variable, Expression initializer, AstNode node)
        {
            var variablePath       = new AccessPath(variable);
            var rightResolveResult = context.Resolve(initializer) as LocalResolveResult;

            if (rightResolveResult != null)
            {
                var rightPath = AccessPath.FromResolveResult(rightResolveResult);
                if (rightPath != null && accessPaths.ContainsKey(rightPath))
                {
                    var rightInitializer = accessPaths [rightPath];
                    ReplacementNodeHelper.AddReplacementAnnotation(rightInitializer, node);
                    accessPaths.Remove(rightPath);
                    accessPaths [variablePath] = rightInitializer;
                    if (rightPath == mainAccessPath)
                    {
                        mainAccessPath = variablePath;
                    }
                }
            }
            else
            {
                accessPaths [variablePath] = ReplacementNodeHelper.CloneWithReplacementAnnotation(initializer, node);
            }
        }
コード例 #2
0
 void Convert(IList <AstNode> originalStatements)
 {
     foreach (var node in originalStatements)
     {
         var comment = node as Comment;
         if (comment != null)
         {
             comments.Add((Comment)ReplacementNodeHelper.CloneWithReplacementAnnotation(comment, node));
             continue;
         }
         var success = TryHandleInitializer(node);
         if (success)
         {
             continue;
         }
         var expressionStatement = node as ExpressionStatement;
         if (expressionStatement == null)
         {
             break;
         }
         success = TryHandleAssignmentExpression(expressionStatement);
         if (success)
         {
             continue;
         }
         success = TryHandleAddCall(expressionStatement);
         if (success)
         {
             continue;
         }
         break;
     }
 }