Beispiel #1
0
 public MockOpenedFile(string fileName, bool isUntitled)
 {
     base.FileName   = FileName.Create(fileName);
     base.IsUntitled = isUntitled;
 }
Beispiel #2
0
 static void AddTask(string fileName, string message, int column, int line, TaskType taskType)
 {
     TaskService.Add(new Task(FileName.Create(fileName), message, column, line, taskType));
 }
        void listViewHyperlinkClick(object sender, RoutedEventArgs e)
        {
            RecentOpenItem item = (RecentOpenItem)((Hyperlink)sender).Tag;

            SD.ProjectService.OpenSolutionOrProject(FileName.Create(item.Path));
        }
 public ProvidedDocumentInformation(IDocument document, string fileName, int currentOffset)
 {
     this.document  = document;
     this.fileName  = FileName.Create(fileName);
     this.endOffset = this.currentOffset = currentOffset;
 }
 public ITextSource GetFileContent(string fileName)
 {
     return(GetFileContent(FileName.Create(fileName)));
 }
 public static bool IsOpen(string fileName)
 {
     return(SD.FileService.IsOpen(FileName.Create(fileName)));
 }
 /// <summary>
 /// Opens a view content for the specified file
 /// or returns the existing view content for the file if it is already open.
 /// </summary>
 /// <param name="fileName">The name of the file to open.</param>
 /// <param name="switchToOpenedView">Specifies whether to switch to the view for the specified file.</param>
 /// <returns>The existing or opened <see cref="IViewContent"/> for the specified file.</returns>
 public static IViewContent OpenFile(string fileName, bool switchToOpenedView)
 {
     return(SD.FileService.OpenFile(FileName.Create(fileName), switchToOpenedView));
 }
        /// <summary>
        /// This method can be used in three modes:
        /// 1. Find references to classes (parentClass = targetClass, member = null, fileName = null)
        /// 2. Find references to members (parentClass = parent, member = member, fileName = null)
        /// 3. Find references to local variables (parentClass = parent, member = local var as field, fileName = parent.CompilationUnit.FileName)
        /// </summary>
        static List <Reference> RunFindReferences(IClass ownerClass, IMember member,
                                                  string fileName,
                                                  IProgressMonitor progressMonitor)
        {
            if (ParserService.LoadSolutionProjectsThreadRunning)
            {
                if (progressMonitor != null)
                {
                    progressMonitor.ShowingDialog = true;
                }
                MessageService.ShowMessage("${res:SharpDevelop.Refactoring.LoadSolutionProjectsThreadRunning}");
                if (progressMonitor != null)
                {
                    progressMonitor.ShowingDialog = false;
                }
                return(null);
            }

            CancellationToken ct = progressMonitor != null ? progressMonitor.CancellationToken : CancellationToken.None;

            List <ProjectItem> files;

            if (!string.IsNullOrEmpty(fileName))
            {
                // search just in given file
                files = new List <ProjectItem>();
                files.Add(FindItem(fileName));
            }
            else
            {
                // search in all possible files
                ownerClass = ownerClass.GetCompoundClass();
                files      = GetPossibleFiles(ownerClass, member);
            }
            ParseableFileContentFinder finder     = new ParseableFileContentFinder();
            List <Reference>           references = new List <Reference>();

            if (progressMonitor != null)
            {
                progressMonitor.TaskName = StringParser.Parse("${res:SharpDevelop.Refactoring.FindingReferences}");
            }

            foreach (ProjectItem item in files)
            {
                FileName itemFileName = FileName.Create(item.FileName);

                if (progressMonitor != null)
                {
                    progressMonitor.Progress += 1.0 / files.Count;
                    if (ct.IsCancellationRequested)
                    {
                        return(null);
                    }
                }
                // Don't read files we don't have a parser for.
                // This avoids loading huge files (e.g. sdps) when we have no intention of parsing them.
                if (ParserService.GetParser(itemFileName) != null)
                {
                    ITextBuffer content = finder.Create(itemFileName);
                    if (content != null)
                    {
                        try {
                            AddReferences(references, ownerClass, member, itemFileName, content.Text, ct);
                        } catch (OperationCanceledException ex) {
                            if (ex.CancellationToken == ct)
                            {
                                return(null);
                            }
                            else
                            {
                                throw;
                            }
                        }
                    }
                }
            }

            return(references);
        }
 /// <summary>
 /// Shows the OpenWith dialog for the specified file.
 /// </summary>
 static void OpenWith(string fileName)
 {
     SD.FileService.ShowOpenWithDialog(new [] { FileName.Create(fileName) });
 }
Beispiel #10
0
        bool IsInScope(Task item)
        {
            IClass current   = GetCurrentClass();
            IClass itemClass = GetCurrentClass(item);

            switch (this.selectedScopeIndex)
            {
            case 0:
                // Solution
                if (ProjectService.OpenSolution != null)
                {
                    foreach (AbstractProject proj in ProjectService.OpenSolution.Projects)
                    {
                        if (proj.FindFile(item.FileName) != null)
                        {
                            return(true);
                        }
                    }
                }
                return(false);

            case 1:
                // Project
                return(ProjectService.CurrentProject != null && ProjectService.CurrentProject.FindFile(item.FileName) != null);

            case 2:
                // All open documents
                return(WorkbenchSingleton.Workbench.ViewContentCollection.OfType <ITextEditorProvider>().Any(provider => item.FileName == provider.TextEditor.FileName));

            case 3:
                // Document
                return(WorkbenchSingleton.Workbench.ActiveViewContent != null && WorkbenchSingleton.Workbench.ActiveViewContent.PrimaryFileName == FileName.Create(item.FileName));

            case 4:
                // Namespace
                return(current != null && itemClass != null && current.Namespace == itemClass.Namespace);

            case 5:
                // Class/Module
                return(current != null && itemClass != null && current == itemClass);
            }

            return(true);
        }
Beispiel #11
0
        void classComboBoxSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            // The selected class was changed.
            // Update the list of member items to be the list of members of the current class.
            EntityItem item = classComboBox.SelectedItem as EntityItem;
            IUnresolvedTypeDefinition selectedClass = item != null ? item.Entity as IUnresolvedTypeDefinition : null;

            memberItems = new List <EntityItem>();
            if (selectedClass != null)
            {
                ICompilation    compilation   = SD.ParserService.GetCompilationForFile(FileName.Create(selectedClass.UnresolvedFile.FileName));
                var             context       = new SimpleTypeResolveContext(compilation.MainAssembly);
                ITypeDefinition compoundClass = selectedClass.Resolve(context).GetDefinition();
                if (compoundClass != null)
                {
                    var ambience = compilation.GetAmbience();
                    foreach (var member in compoundClass.Members)
                    {
                        if (member.IsSynthetic)
                        {
                            continue;
                        }
                        bool isInSamePart = string.Equals(member.Region.FileName, selectedClass.Region.FileName, StringComparison.OrdinalIgnoreCase);
                        memberItems.Add(new EntityItem(member, ambience)
                        {
                            IsInSamePart = isInSamePart
                        });
                    }
                    memberItems.Sort();
                    if (jumpOnSelectionChange)
                    {
                        SD.AnalyticsMonitor.TrackFeature(GetType(), "JumpToClass");
                        JumpTo(item, selectedClass.Region);
                    }
                }
            }
            membersComboBox.ItemsSource = memberItems;
        }
Beispiel #12
0
 FileProjectItem GetFileFromMSBuildProject(string fileName)
 {
     return(msbuildProject.Items.Single(item => item.FileName == FileName.Create(fileName)) as FileProjectItem);
 }
Beispiel #13
0
 ProjectItem GetFileProjectItemInMSBuildProject(string fileName)
 {
     return(msbuildProject.Items.SingleOrDefault(item => item.FileName == FileName.Create(fileName)));
 }
Beispiel #14
0
 ProjectItem GetFirstServiceReferenceFileInMSBuildProject(ServiceReferenceFileName fileName)
 {
     return(msbuildProject.Items.SingleOrDefault(item => item.FileName == FileName.Create(fileName.Path)));
 }
Beispiel #15
0
        public static void CopyDirectory(string directoryName, DirectoryNode node, bool includeInProject)
        {
            directoryName = FileUtility.NormalizePath(directoryName);
            string copiedFileName = Path.Combine(node.Directory, Path.GetFileName(directoryName));

            LoggingService.Debug("Copy " + directoryName + " to " + copiedFileName);
            if (!FileUtility.IsEqualFileName(directoryName, copiedFileName))
            {
                if (includeInProject && ProjectService.OpenSolution != null)
                {
                    // get ProjectItems in source directory
                    foreach (IProject project in ProjectService.OpenSolution.Projects)
                    {
                        if (!FileUtility.IsBaseDirectory(project.Directory, directoryName))
                        {
                            continue;
                        }
                        LoggingService.Debug("Searching for child items in " + project.Name);
                        foreach (ProjectItem item in project.Items)
                        {
                            FileProjectItem fileItem = item as FileProjectItem;
                            if (fileItem == null)
                            {
                                continue;
                            }
                            string virtualFullName = Path.Combine(project.Directory, fileItem.VirtualName);
                            if (FileUtility.IsBaseDirectory(directoryName, virtualFullName))
                            {
                                if (item.ItemType == ItemType.Folder && FileUtility.IsEqualFileName(directoryName, virtualFullName))
                                {
                                    continue;
                                }
                                LoggingService.Debug("Found file " + virtualFullName);
                                FileProjectItem newItem = new FileProjectItem(node.Project, fileItem.ItemType);
                                if (FileUtility.IsBaseDirectory(directoryName, fileItem.FileName))
                                {
                                    newItem.FileName = FileName.Create(FileUtility.RenameBaseDirectory(fileItem.FileName, directoryName, copiedFileName));
                                }
                                else
                                {
                                    newItem.FileName = fileItem.FileName;
                                }
                                fileItem.CopyMetadataTo(newItem);
                                if (fileItem.IsLink)
                                {
                                    string newVirtualFullName = FileUtility.RenameBaseDirectory(virtualFullName, directoryName, copiedFileName);
                                    fileItem.SetEvaluatedMetadata("Link", FileUtility.GetRelativePath(node.Project.Directory, newVirtualFullName));
                                }
                                ProjectService.AddProjectItem(node.Project, newItem);
                            }
                        }
                    }
                }

                FileService.CopyFile(directoryName, copiedFileName, true, false);
                DirectoryNode newNode = new DirectoryNode(copiedFileName);
                newNode.InsertSorted(node);
                if (includeInProject)
                {
                    IncludeFileInProject.IncludeDirectoryNode(newNode, false);
                }
                newNode.Expanding();
            }
            else if (includeInProject)
            {
                foreach (TreeNode childNode in node.Nodes)
                {
                    if (childNode is DirectoryNode)
                    {
                        DirectoryNode directoryNode = (DirectoryNode)childNode;
                        if (FileUtility.IsEqualFileName(directoryNode.Directory, copiedFileName))
                        {
                            IncludeFileInProject.IncludeDirectoryNode(directoryNode, true);
                        }
                    }
                }
            }
        }
        public IList <ReferenceProjectItem> ResolveAssemblyReferences(
            MSBuildBasedProject baseProject,
            ReferenceProjectItem[] additionalReferences, bool resolveOnlyAdditionalReferences,
            bool logErrorsToOutputPad)
        {
            ProjectInstance project = baseProject.CreateProjectInstance();

            project.SetProperty("BuildingProject", "false");
            project.SetProperty("DesignTimeBuild", "true");

            List <ProjectItemInstance> references = (
                from item in project.Items
                where ItemType.ReferenceItemTypes.Contains(new ItemType(item.ItemType))
                select item
                ).ToList();

            List <ReferenceProjectItem> referenceProjectItems;

            if (resolveOnlyAdditionalReferences)
            {
                // Remove existing references from project
                foreach (ProjectItemInstance reference in references)
                {
                    project.RemoveItem(reference);
                }
                references.Clear();
                referenceProjectItems = new List <ReferenceProjectItem>();
            }
            else
            {
                // Remove the "Private" meta data.
                // This is necessary to detect the default value for "Private"
                foreach (ProjectItemInstance reference in references)
                {
                    reference.RemoveMetadata("Private");
                }
                referenceProjectItems = baseProject.Items.OfType <ReferenceProjectItem>().ToList();
            }

            if (additionalReferences != null)
            {
                referenceProjectItems.AddRange(additionalReferences);
                foreach (ReferenceProjectItem item in additionalReferences)
                {
                    references.Add(project.AddItem("Reference", item.Include));
                }
            }

            List <string> targets = new List <string>();

            if (baseProject.MinimumSolutionVersion >= SolutionFormatVersion.VS2010)
            {
                targets.Add("ResolveReferences");
                targets.Add("DesignTimeResolveAssemblyReferences");
            }
            else
            {
                targets.Add("ResolveAssemblyReferences");
            }
            BuildRequestData requestData = new BuildRequestData(project, targets.ToArray(), new HostServices());
            List <ILogger>   loggers     = new List <ILogger>();

            //loggers.Add(new ConsoleLogger(LoggerVerbosity.Diagnostic));
            if (logErrorsToOutputPad)
            {
                loggers.Add(new SimpleErrorLogger());
            }
            lock (MSBuildInternals.SolutionProjectCollectionLock) {
                BuildParameters parameters = new BuildParameters(baseProject.MSBuildProjectCollection);
                parameters.Loggers = loggers;

                //LoggingService.Debug("Started build for ResolveAssemblyReferences");
                BuildResult result = BuildManager.DefaultBuildManager.Build(parameters, requestData);
                if (result == null)
                {
                    throw new InvalidOperationException("BuildResult is null");
                }
                //LoggingService.Debug("Build for ResolveAssemblyReferences finished: " + result.OverallResult);
            }

            IEnumerable <ProjectItemInstance> resolvedAssemblyProjectItems = project.GetItems("_ResolveAssemblyReferenceResolvedFiles");

            var query =
                from msbuildItem in resolvedAssemblyProjectItems
                where msbuildItem.GetMetadataValue("ReferenceSourceTarget") != "ProjectReference"
                let originalInclude = msbuildItem.GetMetadataValue("OriginalItemSpec")
                                      join item in referenceProjectItems.Where(p => p.ItemType != ItemType.ProjectReference) on originalInclude equals item.Include into referenceItems
                                      select new {
                OriginalInclude = originalInclude,
                AssemblyName    = new DomAssemblyName(msbuildItem.GetMetadataValue("FusionName")),
                FullPath        = FileUtility.GetAbsolutePath(baseProject.Directory, msbuildItem.GetMetadataValue("Identity")),
                Redist          = msbuildItem.GetMetadataValue("Redist"),
                CopyLocal       = bool.Parse(msbuildItem.GetMetadataValue("CopyLocal")),
                ReferenceItems  = referenceItems
            };

            // HACK: mscorlib is reported twice for portable library projects (even if we don't specify it as additionalReference)
            query = query.DistinctBy(asm => asm.FullPath);
            List <ReferenceProjectItem> resolvedAssemblies    = new List <ReferenceProjectItem>();
            List <ReferenceProjectItem> handledReferenceItems = new List <ReferenceProjectItem>();

            foreach (var assembly in query)
            {
                //LoggingService.Debug("Got information about " + assembly.OriginalInclude + "; fullpath=" + assembly.FullPath);
                foreach (var referenceItem in assembly.ReferenceItems)
                {
                    referenceItem.AssemblyName          = assembly.AssemblyName;
                    referenceItem.FileName              = FileName.Create(assembly.FullPath);
                    referenceItem.Redist                = assembly.Redist;
                    referenceItem.DefaultCopyLocalValue = assembly.CopyLocal;
                    handledReferenceItems.Add(referenceItem);
                }
                ReferenceProjectItem firstItem = assembly.ReferenceItems.FirstOrDefault();
                if (firstItem != null)
                {
                    resolvedAssemblies.Add(firstItem);
                }
                else
                {
                    resolvedAssemblies.Add(new ReferenceProjectItem(baseProject, assembly.OriginalInclude)
                    {
                        FileName = FileName.Create(assembly.FullPath)
                    });
                }
            }
            // Add any assemblies that weren't resolved yet. This is important - for example, this adds back project references.
            foreach (var referenceItem in referenceProjectItems.Except(handledReferenceItems))
            {
                resolvedAssemblies.Add(referenceItem);
            }
            return(resolvedAssemblies);
        }
Beispiel #17
0
 /// <summary>
 /// Opens the specified file and jumps to the specified file position.
 /// Line and column start counting at 1.
 /// </summary>
 public static IViewContent JumpToFilePosition(string fileName, int line, int column)
 {
     return(SD.FileService.JumpToFilePosition(FileName.Create(fileName), line, column));
 }
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            if (value is string)
            {
                string[] v = ((string)value).Split('|');

                FileName fileName     = FileName.Create(v[1]);
                int      lineNumber   = int.Parse(v[2], culture);
                int      columnNumber = int.Parse(v[3], culture);
                if (lineNumber < 0)
                {
                    return(null);
                }
                if (columnNumber < 0)
                {
                    return(null);
                }
                SDBookmark bookmark;
                switch (v[0])
                {
                case "Breakpoint":
                    Debugging.BreakpointAction action = Debugging.BreakpointAction.Break;
                    string scriptLanguage             = "";
                    string script = "";
                    action         = (Debugging.BreakpointAction)Enum.Parse(typeof(Debugging.BreakpointAction), v[5]);
                    scriptLanguage = v[6];
                    script         = v[7];

                    var bbm = new Debugging.BreakpointBookmark(fileName, new Location(columnNumber, lineNumber), action, scriptLanguage, script);
                    bbm.IsEnabled      = bool.Parse(v[4]);
                    bbm.Action         = action;
                    bbm.ScriptLanguage = scriptLanguage;
                    bbm.Condition      = script;
                    bookmark           = bbm;
                    break;

                case "PinBookmark":
                    var pin = new PinBookmark(fileName, new Location(columnNumber, lineNumber));
                    pin.Comment     = v[4];
                    pin.PinPosition =
                        new Point
                    {
                        X = double.Parse(v[5], culture),
                        Y = double.Parse(v[6], culture)
                    };

                    // pop-up nodes
                    pin.SavedNodes = new System.Collections.Generic.List <Tuple <string, string, string> >();
                    for (int i = 7; i < v.Length; i += 3)
                    {
                        pin.SavedNodes.Add(new Tuple <string, string, string>(v[i], v[i + 1], v[i + 2]));
                    }

                    bookmark = pin;
                    break;

                default:
                    bookmark = new Bookmark(fileName, new Location(columnNumber, lineNumber));
                    break;
                }
                return(bookmark);
            }
            else
            {
                return(base.ConvertFrom(context, culture, value));
            }
        }
Beispiel #19
0
 /// <summary>
 /// Opens a view content for the specified file and switches to the opened view
 /// or switches to and returns the existing view content for the file if it is already open.
 /// </summary>
 /// <param name="fileName">The name of the file to open.</param>
 /// <returns>The existing or opened <see cref="IViewContent"/> for the specified file.</returns>
 public static IViewContent OpenFile(string fileName)
 {
     return(SD.FileService.OpenFile(FileName.Create(fileName)));
 }
Beispiel #20
0
 public static FileProjectItem GetFile(MSBuildBasedProject project, string fileName)
 {
     return(project.FindFile(FileName.Create(fileName)));
 }
        public void AddItem(string fileName)
        {
            var newItem = folder.AddFile(FileName.Create(fileName));

            new SolutionItemNode(newItem).InsertSorted(this);
        }
 public static void LoadProject(string fileName)
 {
     SD.ProjectService.OpenSolutionOrProject(FileName.Create(fileName));
     //FileUtility.ObservedLoad(LoadProjectInternal, fileName);
 }
 TestableFileProjectItem(TestableProject project, string fileName)
     : base(project, ItemType.None)
 {
     this.TestableProject = project;
     this.fileName        = FileName.Create(fileName);
 }
 public static bool HasProjectLoader(string fileName)
 {
     return(SD.ProjectService.IsSolutionOrProjectFile(FileName.Create(fileName)));
 }
Beispiel #25
0
 /// <summary>
 /// Gets an opened file, or returns null if the file is not opened.
 /// </summary>
 public static OpenedFile GetOpenedFile(string fileName)
 {
     return(GetOpenedFile(FileName.Create(fileName)));
 }
 public static void LoadSolutionOrProject(string fileName)
 {
     SD.ProjectService.OpenSolutionOrProject(FileName.Create(fileName));
 }
 public static FileName GetConsoleAppFileName()
 {
     return(FileName.Create(typeof(ICSharpCode.NAntAddIn.Tests.ConsoleApp.ConsoleApp).Assembly.Location));
 }
        void AddCodeCoverageFile(string fileName)
        {
            string coverageXml = "<CodeCoverage></CodeCoverage>";

            AddCodeCoverageFile(FileName.Create(fileName), coverageXml);
        }
Beispiel #29
0
        public void Run(IList <string> fileList)
        {
            bool didLoadSolutionOrFile = false;

            NavigationService.SuspendLogging();

            foreach (string file in fileList)
            {
                LoggingService.Info("Open file " + file);
                didLoadSolutionOrFile = true;
                try {
                    var fullFileName = FileName.Create(Path.GetFullPath(file));

                    if (SD.ProjectService.IsSolutionOrProjectFile(fullFileName))
                    {
                        SD.ProjectService.OpenSolutionOrProject(fullFileName);
                    }
                    else
                    {
                        SharpDevelop.FileService.OpenFile(fullFileName);
                    }
                } catch (Exception e) {
                    MessageService.ShowException(e, "unable to open file " + file);
                }
            }

            // load previous solution
            if (!didLoadSolutionOrFile && SD.PropertyService.Get("SharpDevelop.LoadPrevProjectOnStartup", false))
            {
                if (SD.FileService.RecentOpen.RecentProjects.Count > 0)
                {
                    try {
                        SD.ProjectService.OpenSolutionOrProject(SD.FileService.RecentOpen.RecentProjects[0]);
                        didLoadSolutionOrFile = true;
                    } catch (Exception ex) {
                        MessageService.ShowException(ex);
                    }
                }
            }

            if (!didLoadSolutionOrFile)
            {
                foreach (ICommand command in AddInTree.BuildItems <ICommand>("/SharpDevelop/Workbench/AutostartNothingLoaded", null, false))
                {
                    try {
                        command.Execute(null);
                    } catch (Exception ex) {
                        MessageService.ShowException(ex);
                    }
                }
                StartPreloadThread();
            }

            NavigationService.ResumeLogging();

            ((ParserService)SD.ParserService).StartParserThread();

//			// finally run the workbench window ...
            app.Run(SD.Workbench.MainWindow);

            // save the workbench memento in the ide properties
            try {
                SD.PropertyService.SetNestedProperties(workbenchMemento, ((WpfWorkbench)SD.Workbench).CreateMemento());
            } catch (Exception e) {
                MessageService.ShowException(e, "Exception while saving workbench state.");
            }
        }
        HighlightedLine DoHighlightLine(int lineNumber, IDocumentLine documentLine, CachedLine cachedLine, ITextSourceVersion newVersion)
        {
            if (parseInfo == null)
            {
                if (forceParseOnNextRefresh)
                {
                    forceParseOnNextRefresh = false;
                    parseInfo = SD.ParserService.Parse(FileName.Create(document.FileName), document) as CSharpFullParseInformation;
                }
                else
                {
                    parseInfo = SD.ParserService.GetCachedParseInformation(FileName.Create(document.FileName), newVersion) as CSharpFullParseInformation;
                }
            }
            if (parseInfo == null)
            {
                if (invalidLines != null && !invalidLines.Contains(documentLine))
                {
                    invalidLines.Add(documentLine);
                    //Debug.WriteLine("Semantic highlighting for line {0} - marking as invalid", lineNumber);
                }

                if (cachedLine != null)
                {
                    // If there's a cached version, adjust it to the latest document changes and return it.
                    // This avoids flickering when changing a line that contains semantic highlighting.
                    cachedLine.Update(newVersion);
                                        #if DEBUG
                    cachedLine.HighlightedLine.ValidateInvariants();
                                        #endif
                    return(cachedLine.HighlightedLine);
                }
                else
                {
                    return(null);
                }
            }

            if (visitor.Resolver == null)
            {
                var compilation = SD.ParserService.GetCompilationForFile(parseInfo.FileName);
                visitor.Resolver = parseInfo.GetResolver(compilation);
            }

            line            = new HighlightedLine(document, documentLine);
            this.lineNumber = lineNumber;
            visitor.UpdateLineInformation(lineNumber);

            if (Debugger.IsAttached)
            {
                parseInfo.SyntaxTree.AcceptVisitor(visitor);
                                #if DEBUG
                line.ValidateInvariants();
                                #endif
            }
            else
            {
                try {
                    parseInfo.SyntaxTree.AcceptVisitor(visitor);
                                        #if DEBUG
                    line.ValidateInvariants();
                                        #endif
                } catch (Exception ex) {
                    hasCrashed = true;
                    throw new ApplicationException("Error highlighting line " + lineNumber, ex);
                }
            }
            //Debug.WriteLine("Semantic highlighting for line {0} - added {1} sections", lineNumber, line.Sections.Count);
            if (cachedLines != null && document.Version != null)
            {
                cachedLines.Add(new CachedLine(line, document.Version));
            }
            return(line);
        }