示例#1
0
        /// <summary>
        /// A method that find a destructor and makes it the current node.
        /// </summary>
        /// <returns>True if found and made current, false otherwise.</returns>
        public T SelectDestructorDeclaration()
        {
            var result = CurrentNode?.DescendantNodes().OfType <DestructorDeclarationSyntax>().FirstOrDefault();

            NextStep(result);
            return(Composer);
        }
示例#2
0
        /// <summary>
        /// Finds all constructors of a class, and makes them current.
        /// </summary>
        /// <returns>True if found and made current, false otherwise.</returns>
        public T SelectOverloadedConstructorDeclarations()
        {
            var result = CurrentNode?.DescendantNodes().OfType <ConstructorDeclarationSyntax>().Cast <SyntaxNode>().ToList();

            NextStep(result);
            return(Composer);
        }
示例#3
0
        /// <summary>
        /// Finds the last method declaration and makes it the current node.
        /// </summary>
        /// <returns>True if found and made current, false otherwise.</returns>
        public T SelectLastMethodDeclaration()
        {
            var result = CurrentNode?.DescendantNodes().OfType <FieldDeclarationSyntax>().LastOrDefault();

            NextStep(result);
            return(Composer);
        }
示例#4
0
        public T SelectInterfaceDeclaration(string interfaceName)
        {
            var @interface = CurrentNode?.DescendantNodes().OfType <InterfaceDeclarationSyntax>()
                             .Where(cl => cl.Identifier.ToString() == interfaceName).FirstOrDefault();

            NextStep(@interface);
            return(Composer);
        }
示例#5
0
        public T SelectClassDeclaration(string className)
        {
            var @class = CurrentNode?.DescendantNodes().OfType <ClassDeclarationSyntax>()
                         .Where(cl => cl.Identifier.ToString() == className).FirstOrDefault();

            NextStep(@class);
            return(Composer);
        }
示例#6
0
        public T SelectStructDeclaration(string structName)
        {
            var @struct = CurrentNode?.DescendantNodes().OfType <StructDeclarationSyntax>()
                          .Where(st => st.Identifier.ToString() == structName).FirstOrDefault();

            NextStep(@struct);
            return(Composer);
        }
示例#7
0
        public T SelectAllUnaryOperatorDeclarations()
        {
            var resultingOperators = CurrentNode?.DescendantNodes().OfType <OperatorDeclarationSyntax>()
                                     .Where(op => op.ParameterList.Parameters.Count == PARAM_NUM_OF_UNARY).ToList <SyntaxNode>();

            NextStep(resultingOperators);
            return(Composer);
        }
示例#8
0
        public T SelectEnumDeclaration(string enumName)
        {
            var @enum = CurrentNode?.DescendantNodes().OfType <EnumDeclarationSyntax>()
                        .Where(en => en.Identifier.ToString() == enumName).FirstOrDefault();

            NextStep(@enum);
            return(Composer);
        }
示例#9
0
        /// <summary>
        /// Finds a property declaration of a given name (if such exists) and makes it the current node.
        /// </summary>
        /// <param name="propertyName">Name of the property.</param>
        ///  <returns>True if found and made current, false otherwise.</returns>
        public T SelectPropertyDeclaration([NotBlank] string propertyName)
        {
            var result = CurrentNode?.DescendantNodes().OfType <PropertyDeclarationSyntax>().
                         Where(p => p.Identifier.ValueText == propertyName).FirstOrDefault();

            NextStep(result);
            return(Composer);
        }
示例#10
0
        /// <summary>
        /// Finds occurances of (possibly overloaded) methods with a specified name, if such exist, and makes them current.
        /// </summary>
        /// <param name="methodName">Method's name</param>
        /// <returns>True if any found and made current, false otherwise.</returns>
        public T SelectOverloadedMethodDeclarations([NotBlank] string methodName)
        {
            var allMethods = CurrentNode?.DescendantNodes().OfType <MethodDeclarationSyntax>();

            var result = allMethods?.Where(p => p.Identifier.ValueText == methodName).Cast <SyntaxNode>().ToList();

            NextStep(result);
            return(Composer);
        }
示例#11
0
        public T SelectUnaryOperatorDeclaration(string operatorToken)
        {
            var resultingOperator = CurrentNode?.DescendantNodes().OfType <OperatorDeclarationSyntax>()
                                    .Where(op => op.ParameterList.Parameters.Count == PARAM_NUM_OF_UNARY && op.OperatorToken.ToString() == operatorToken)
                                    .FirstOrDefault();

            NextStep(resultingOperator);
            return(Composer);
        }
示例#12
0
        /// <summary>
        /// Finds the last statement contained by the given syntax node, and makes it current.
        /// </summary>
        /// <returns>True if found made current, false otherwise</returns>
        public T SelectLastStatement()
        {
            List <StatementSyntax> statements = CurrentNode?.DescendantNodes().OfType <StatementSyntax>().ToList();

            if (statements.Count() > 0)
            {
                NextStep(statements.Last());
            }

            return(Composer);
        }
示例#13
0
        /// <summary>
        ///Finds variable declaration based on the variable's name if it exists within the specified root, and is made current.
        /// </summary>
        /// <param name="variableName">Name of the variable</param>
        /// <returns>True if found and made current, false otherwise</returns>
        public bool SelectVariableDeclaration([NotBlank] string variableName)
        {
            var declarator = CurrentNode?.DescendantNodes().OfType <VariableDeclaratorSyntax>()
                             .Where(v => v.Identifier.ValueText == variableName).FirstOrDefault();

            if (declarator != null)
            {
                //return NextStep(declarator.Parent);
            }

            return(false);
        }
示例#14
0
        public T SelectConversionOperatorDeclaration([NotBlank] string parameterType)
        {
            var conversionOperators = CurrentNode?.DescendantNodes().OfType <ConversionOperatorDeclarationSyntax>();

            foreach (var co in conversionOperators)
            {
                if (CompareParameterTypes(co, parameterType))
                {
                    NextStep(co);
                }
            }

            return(Composer);
        }
示例#15
0
        public T SelectNamespace()
        {
            var @namespace = CurrentNode?
                             .DescendantNodes()
                             .OfType <NamespaceDeclarationSyntax>()
                             .FirstOrDefault();

            if (@namespace != null)
            {
                NextStep(@namespace);
            }

            return(Composer);
        }
示例#16
0
        /// <summary>
        /// Selects a field declaration of a given name (if such exists) and makes it the current node.
        /// </summary>
        /// <param name="fieldName">Name of the variable being declared</param>
        /// <returns>True if found and made current, false otherwise.</returns>
        public T SelectFieldDeclaration([NotBlank] string fieldName)
        {
            var fieldDeclarations = CurrentNode?.DescendantNodes().OfType <FieldDeclarationSyntax>().ToList();

            foreach (var fieldDeclaration in fieldDeclarations)
            {
                var declaratorExists = fieldDeclaration.DescendantNodes().OfType <VariableDeclaratorSyntax>().
                                       Where(d => d.Identifier.ValueText == fieldName).Any();

                if (declaratorExists)
                {
                    NextStep(fieldDeclaration);
                }
            }

            return(Composer);
        }
示例#17
0
        /// <summary>
        /// Finds an invocation of a method of the given name which is a descendant of the provided root, and makes it the current node.
        /// </summary>
        /// <param name="root">Root node</param>
        /// <param name="methodName">Method's name</param>
        /// <returns>True if found and made current, false otherwise</returns>
        public bool SelectMethodInvocation([NotBlank] string methodName)
        {
            var invocations = CurrentNode?.DescendantNodes().OfType <InvocationExpressionSyntax>().ToList();

            foreach (var invocation in invocations)
            {
                var  identifierNames = invocation.DescendantNodes().OfType <IdentifierNameSyntax>().ToList();
                bool found           = (from name in identifierNames
                                        where name.Identifier.ValueText == methodName
                                        select name).Any();
                if (found)
                {
                    //return NextStep(invocation);
                }
            }

            return(false);
        }
示例#18
0
        /// <summary>
        /// Finds all method invocations of the given name which are a descendant of the provided root, and makes them the current standing point.
        /// </summary>
        /// <param name="methodName">Method's name</param>
        /// <returns>True if found and made current, false otherwise</returns>
        public bool SelectAllMethodInvocationByMethodName([NotBlank] string methodName)
        {
            var invocations         = CurrentNode?.DescendantNodes().OfType <ExpressionStatementSyntax>().ToList();
            List <SyntaxNode> found = new List <SyntaxNode>();

            foreach (var invocation in invocations)
            {
                var identifierNames = invocation.DescendantNodes().OfType <IdentifierNameSyntax>().ToList();
                if ((from name in identifierNames
                     where name.Identifier.ValueText == methodName
                     select name).Any())
                {
                    found.Add(invocation);
                }
            }

            if (found.Any())
            {
                //return NextStep(found);
            }

            return(false);
        }
示例#19
0
 private IEnumerable <OperatorDeclarationSyntax> GetBinaryOperators(string operatorToken)
 {
     return(CurrentNode?.DescendantNodes().OfType <OperatorDeclarationSyntax>()
            .Where(op => op.OperatorToken.ToString() == operatorToken && op.ParameterList.Parameters.Count == PARAM_NUM_OF_BINARY));
 }