protected CodeGenerator(InsertionPoint insertionPoint, SelectionResult selectionResult, AnalyzerResult analyzerResult)
            {
                //Contract.ThrowIfFalse(insertionPoint.SemanticDocument == analyzerResult.SemanticDocument);

                this.InsertionPoint   = insertionPoint;
                this.SemanticDocument = insertionPoint.SemanticDocument;

                this.SelectionResult = selectionResult;
                this.AnalyzerResult  = analyzerResult;

                this.MethodNameAnnotation       = new SyntaxAnnotation();
                this.CallSiteAnnotation         = new SyntaxAnnotation();
                this.MethodDefinitionAnnotation = MonoDevelop.Ide.TypeSystem.TypeSystemService.InsertionModeAnnotation;
            }
Esempio n. 2
0
                public static bool IsExtractMethodOnMultipleStatements(SelectionResult code)
                {
                    var result = (CSharpSelectionResult)code;
                    var first  = result.GetFirstStatement();
                    var last   = result.GetLastStatement();

                    if (first != last)
                    {
                        //var firstUnderContainer = result.GetFirstStatementUnderContainer();
                        //var lastUnderContainer = result.GetLastStatementUnderContainer();
                        //Contract.ThrowIfFalse(firstUnderContainer.Parent == lastUnderContainer.Parent);
                        return(true);
                    }

                    return(false);
                }
            private static CSharpCodeGenerator Create(
                InsertionPoint insertionPoint,
                SelectionResult selectionResult,
                AnalyzerResult analyzerResult)
            {
                if (ExpressionCodeGenerator.IsExtractMethodOnExpression(selectionResult))
                {
                    return(new ExpressionCodeGenerator(insertionPoint, selectionResult, analyzerResult));
                }

                if (SingleStatementCodeGenerator.IsExtractMethodOnSingleStatement(selectionResult))
                {
                    return(new SingleStatementCodeGenerator(insertionPoint, selectionResult, analyzerResult));
                }

                if (MultipleStatementsCodeGenerator.IsExtractMethodOnMultipleStatements(selectionResult))
                {
                    return(new MultipleStatementsCodeGenerator(insertionPoint, selectionResult, analyzerResult));
                }

                return(null);               //Contract.FailWithReturn<CSharpCodeGenerator>("Unknown selection");
            }
 public static bool IsExtractMethodOnExpression(SelectionResult code)
 {
     return(code.SelectionInExpression);
 }
 protected override Task <MethodExtractor.GeneratedCode> GenerateCodeAsync(InsertionPoint insertionPoint, SelectionResult selectionResult, AnalyzerResult analyzeResult, CancellationToken cancellationToken)
 {
     return(CSharpCodeGenerator.GenerateAsync(insertionPoint, selectionResult, analyzeResult, cancellationToken));
 }
 protected override async Task <TriviaResult> PreserveTriviaAsync(SelectionResult selectionResult, CancellationToken cancellationToken)
 {
     return(await CSharpTriviaResult.ProcessAsync(selectionResult, cancellationToken).ConfigureAwait(false));
 }
 protected override Task <AnalyzerResult> AnalyzeAsync(SelectionResult selectionResult, CancellationToken cancellationToken)
 {
     return(CSharpAnalyzer.AnalyzeAsync(selectionResult, cancellationToken));
 }
Esempio n. 8
0
 public CSharpAnalyzer(SelectionResult selectionResult, CancellationToken cancellationToken) :
     base(selectionResult, cancellationToken)
 {
 }
Esempio n. 9
0
            public static Task <AnalyzerResult> AnalyzeAsync(SelectionResult selectionResult, CancellationToken cancellationToken)
            {
                var analyzer = new CSharpAnalyzer(selectionResult, cancellationToken);

                return(analyzer.AnalyzeAsync());
            }
Esempio n. 10
0
 protected abstract Task <GeneratedCode> GenerateCodeAsync(InsertionPoint insertionPoint, SelectionResult selectionResult, AnalyzerResult analyzeResult, CancellationToken cancellationToken);
Esempio n. 11
0
 protected abstract Task <SemanticDocument> ExpandAsync(SelectionResult selection, CancellationToken cancellationToken);
Esempio n. 12
0
 protected abstract Task <TriviaResult> PreserveTriviaAsync(SelectionResult selectionResult, CancellationToken cancellationToken);
Esempio n. 13
0
 protected abstract Task <AnalyzerResult> AnalyzeAsync(SelectionResult selectionResult, CancellationToken cancellationToken);
Esempio n. 14
0
 public MethodExtractor(SelectionResult selectionResult)
 {
     //Contract.ThrowIfNull(selectionResult);
     this.OriginalSelectionResult = selectionResult;
 }