Example #1
0
            public CodeSource GetSource(ProbeAppSettings appSettings)
            {
                if (_source == null)
                {
                    try
                    {
                        var merger = new FileMerger();
                        merger.MergeFile(appSettings, _fullPathName, null, false, false);
                        _source = merger.MergedContent;

                        var fileInfo = new FileInfo(_fullPathName);
                        _lastModifiedDate = fileInfo.LastWriteTime;
                        _lastCheck        = DateTime.Now;

                        foreach (var mergeFileName in merger.FileNames)
                        {
                            var content = merger.GetFileContent(mergeFileName);
                            if (content == null)
                            {
                                throw new InvalidOperationException("Merger content is null.");
                            }
                            _preMergeContent[mergeFileName.ToLower()] = content;
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex, "Exception when attempting to read content of include file '{0}'.", _fullPathName);
                        _source = null;
                    }
                }
                return(_source);
            }
Example #2
0
        public CodeModel CreatePreprocessedModel(ProbeAppSettings appSettings, string fileName, VsText.ITextSnapshot snapshot, bool visible, string reason)
        {
            CodeSource source;
            IEnumerable <Preprocessor.IncludeDependency> includeDependencies = null;

            if (visible)
            {
                source = new CodeSource();
                source.Append(snapshot.GetText(), fileName, 0, snapshot.Length, true, true, false);
                source.Flush();
            }
            else
            {
                var merger = new FileMerger();
                merger.MergeFile(appSettings, fileName, snapshot.GetText(), false, true);
                source = merger.MergedContent;

                includeDependencies = (from f in merger.FileNames
                                       select new Preprocessor.IncludeDependency(f, false, true, merger.GetFileContent(f))).ToArray();
            }

            var model = CreatePreprocessedModel(appSettings, source, fileName, visible, reason, includeDependencies);

            model.Snapshot = snapshot;
            return(model);
        }