예제 #1
0
        private void AddReferenceIfNeeded(IVBProject project, IUnitTestSettings settings)
        {
            switch (settings.BindingMode)
            {
            case BindingMode.EarlyBinding:
                _interaction.EnsureProjectReferencesUnitTesting(project);
                return;

            case BindingMode.LateBinding:
                return;

            case BindingMode.DualBinding:
                var precompile = _argumentsProvider.UserDefinedCompilationArguments(project.ProjectId);
                if (precompile is null)
                {
                    return;
                }

                var setting = precompile.FirstOrDefault(option =>
                                                        option.Key.Equals(LateBindDirectiveName, StringComparison.CurrentCultureIgnoreCase));

                if (!string.IsNullOrEmpty(setting.Key) && setting.Value != 0)
                {
                    _interaction.EnsureProjectReferencesUnitTesting(project);
                }

                return;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
예제 #2
0
        public CommonTokenStream PreprocessTokenStream(string projectId, string moduleName, CommonTokenStream tokenStream, CancellationToken token, CodeKind codeKind = CodeKind.SnippetCode)
        {
            token.ThrowIfCancellationRequested();

            var tree = _parser.Parse(moduleName, tokenStream, codeKind);

            token.ThrowIfCancellationRequested();

            var charStream  = tokenStream.TokenSource.InputStream;
            var symbolTable = new SymbolTable <string, IValue>();
            var userCompilationArguments      = _compilationArgumentsProvider.UserDefinedCompilationArguments(projectId);
            var predefinedCompilationArgument = _compilationArgumentsProvider.PredefinedCompilationConstants;
            var evaluator       = new VBAPreprocessorVisitor(symbolTable, predefinedCompilationArgument, userCompilationArguments, charStream, tokenStream);
            var expr            = evaluator.Visit(tree);
            var processedTokens = expr.Evaluate(); //This does the actual preprocessing of the token stream as a side effect.

            tokenStream.Reset();
            return(tokenStream);
        }
예제 #3
0
 private void ReloadCompilationArguments(string projectId)
 {
     _compilationArguments[projectId] = _provider.UserDefinedCompilationArguments(projectId);
 }