Ejemplo n.º 1
0
        public bool Run(RecoveryAlgorithm recoveryAlgorithm = RecoveryAlgorithm.Smart, int completionStartPos = -1, string completionPrefix = null)
        {
            var project = _file.Project;

            _file._completionStartPos = completionStartPos;
            _file._completionPrefix   = completionPrefix;
            _file.ResetCache();

            if (_file.Ast == null)
            {
                return(false);
            }

            var tests = _testFolder == null ? (IEnumerable <TestVm>) new[] { this } : _testFolder.Tests;
            var files = tests.Select(t => t.File).ToArray();

            foreach (var file in files)
            {
                file.DeepResetProperties();
            }

            var projectSupport    = _file.Ast as IProjectSupport;
            var compilerMessages  = new CompilerMessageList();
            var cancellationToken = new CancellationToken();
            var filesData         = NitraFile.GetEvalPropertiesData(files);

            if (projectSupport != null)
            {
                if (_data == null)
                {
                    _data = projectSupport.RefreshReferences(cancellationToken, project);
                }
                projectSupport.RefreshProject(cancellationToken, filesData, _data);
            }
            else if (_testFolder != null)
            {
                throw new InvalidOperationException("The '" + _file.Ast.GetType().Name +
                                                    "' type must implement IProjectSupport, to be used in a multi-file test.");
            }
            else
            {
                var context  = new DependentPropertyEvalContext();
                var evalHost = new ProjectEvalPropertiesHost(filesData);
                evalHost.EvalProperties(context);
            }

            foreach (var fileData in filesData)
            {
                if (fileData.HasCompilerMessage)
                {
                    fileData.GetCompilerMessage().TranslateTo(fileData.Ast.Location.Source.File.AstMessages);
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        public bool Run(RecoveryAlgorithm recoveryAlgorithm = RecoveryAlgorithm.Smart, int completionStartPos = -1, string completionPrefix = null)
        {
            var project = _file.Project;

            _file._completionStartPos = completionStartPos;
            _file._completionPrefix   = completionPrefix;
            _file.ResetCache();

            if (_file.Ast == null)
            {
                return(false);
            }

            var tests = _testFolder == null ? (IEnumerable <TestVm>) new[] { this } : _testFolder.Tests;
            var files = tests.Select(t => t.File).ToArray();

            foreach (var file in files)
            {
                file.DeepResetProperties();
            }

            var projectSupport = _file.Ast as IProjectSupport;

            if (projectSupport != null)
            {
                projectSupport.RefreshProject(project);
            }
            else if (_testFolder != null)
            {
                throw new InvalidOperationException("The '" + _file.Ast.GetType().Name +
                                                    "' type must implement IProjectSupport, to be used in a multi-file test.");
            }
            else
            {
                var context  = new DependentPropertyEvalContext();
                var evalHost = new ProjectEvalPropertiesHost(files);
                evalHost.EvalProperties(context);
            }

            return(true);
        }