public override WorkspaceCommandResult Run(string sourceCode, string path, Range range, Dictionary <string, string> parameters)
        {
            SyntaxTree             sourceSyntaxTree = null;
            WorkspaceCommandResult outVal           = null;
            string sourcePath = null;

            if (parameters.ContainsKey("sourceFilePath"))
            {
                sourcePath = parameters["sourceFilePath"];
            }

            //load project
            List <SyntaxTree> syntaxTrees = new List <SyntaxTree>();
            Compilation       compilation = this.LoadProject(path, syntaxTrees, sourceCode, sourcePath, out sourceSyntaxTree);

            if (!String.IsNullOrEmpty(sourceCode))
            {
                string newSourceCode = this.ProcessSourceCode(sourceCode, sourceSyntaxTree, compilation, range, parameters);
                outVal = new WorkspaceCommandResult(newSourceCode);
            }
            else
            {
                int noOfModifiedFiles = this.ProcessFiles(syntaxTrees, compilation, parameters);
                outVal = new WorkspaceCommandResult(null);
                outVal.SetParameter(NoOfChangedFilesParameterName, noOfModifiedFiles.ToString());
            }

            return(outVal);
        }
Пример #2
0
        protected virtual WorkspaceCommandResult CreateResult(T syntaxRewriter, string newSourceCode, string path, Dictionary <string, string> parameters)
        {
            WorkspaceCommandResult result = new WorkspaceCommandResult(newSourceCode);

            result.SetParameter(NoOfChangesParameterName, syntaxRewriter.TotalNoOfChanges.ToString());
            result.SetParameter(NoOfChangedFilesParameterName, syntaxRewriter.NoOfChangedFiles.ToString());
            return(result);
        }
Пример #3
0
        public override WorkspaceCommandResult Run(string sourceCode, string path, Range range, Dictionary <string, string> parameters)
        {
            this.SyntaxRewriter.TotalNoOfChanges = 0;
            this.SyntaxRewriter.NoOfChangedFiles = 0;
            this.SyntaxRewriter.NoOfChanges      = 0;

            WorkspaceCommandResult result = base.Run(sourceCode, path, range, parameters);

            result.SetParameter(NoOfChangesParameterName, this.SyntaxRewriter.TotalNoOfChanges.ToString());
            result.SetParameter(NoOfChangedFilesParameterName, this.SyntaxRewriter.NoOfChangedFiles.ToString());
            return(result);
        }