public void SetUpTestFixture()
		{
			try {
				string configFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "NCoverAddIn.Tests");
				PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests");
			} catch (Exception) {}
			
			document = MockTextMarkerService.CreateDocumentWithMockService();
			markerStrategy = document.GetService(typeof(ITextMarkerService)) as ITextMarkerService;
			string code = "\t\t{\r\n" +
				"\t\t\tint count = 0;\r\n" +
				"\t\t}\r\n";
			document.Text = code;
			
			string xml = "<PartCoverReport>\r\n" +
				"\t<File id=\"1\" url=\"c:\\Projects\\Foo\\FooTestFixture.cs\"/>\r\n" +
				"\t<Assembly id=\"1\" name=\"Foo.Tests\" module=\"C:\\Projects\\Test\\bin\\Foo.Tests.DLL\" domain=\"test-domain-Foo.Tests.dll\" domainIdx=\"1\" />\r\n" +
				"\t<Type name=\"Foo.Tests.FooTestFixture\" asmref=\"1\">\r\n" +
				"\t\t<Method name=\"SimpleTest\">\r\n" +
				"\t\t\t<pt visit=\"1\" sl=\"1\" sc=\"3\" el=\"1\" ec=\"4\" fid=\"1\" />\r\n" +
				"\t\t\t<pt visit=\"1\" sl=\"2\" sc=\"4\" el=\"2\" ec=\"18\" fid=\"1\" />\r\n" +
				"\t\t\t<pt visit=\"0\" sl=\"3\" sc=\"3\" el=\"3\" ec=\"4\" fid=\"1\" />\r\n" +
				"\t\t</Method>\r\n" +
				"\t</Type>\r\n" +
				"</PartCoverReport>";
			CodeCoverageResults results = new CodeCoverageResults(new StringReader(xml));
			CodeCoverageMethod method = results.Modules[0].Methods[0];
			CodeCoverageHighlighter highlighter = new CodeCoverageHighlighter();
			highlighter.AddMarkers(document, method.SequencePoints);	
			
			// Add non-code coverage markers.
			markerStrategy.Create(0, 2);
			markerStrategy.Create(4, 5);
		}
예제 #2
0
        public void MarkError(int start, int length, string message)
        {
            var marker = textMarkerService.Create(start, length);

            marker.Tag         = ResolverMarkerType.Error;
            marker.MarkerTypes = TextMarkerTypes.SquigglyUnderline;
            marker.MarkerColor = Colors.Red;
            marker.ToolTip     = message;
        }
        public void SetUpTestFixture()
        {
            try {
                //string configFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "NCoverAddIn.Tests");
                //PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests");
            } catch (Exception) {}

            document       = MockTextMarkerService.CreateDocumentWithMockService();
            markerStrategy = document.GetService(typeof(ITextMarkerService)) as ITextMarkerService;
            string code = "\t\t{\r\n" +
                          "\t\t\tint count = 0;\r\n" +
                          "\t\t}\r\n";

            document.Text = code;

            string xml = "<CoverageSession xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n" +
                         "\t<Modules>\r\n" +
                         "\t\t<Module hash=\"44-54-B6-13-97-49-45-F8-6A-74-9E-49-0C-77-87-C6-9C-54-47-7A\">\r\n" +
                         "\t\t\t<FullName>C:\\Projects\\Test\\Foo.Tests\\bin\\Foo.Tests.DLL</FullName>\r\n" +
                         "\t\t\t<ModuleName>Foo.Tests</ModuleName>\r\n" +
                         "\t\t\t<Files>\r\n" +
                         "\t\t\t\t<File uid=\"1\" fullPath=\"c:\\Projects\\Foo\\FooTestFixture.cs\" />\r\n" +
                         "\t\t\t</Files>\r\n" +
                         "\t\t\t<Classes>\r\n" +
                         "\t\t\t\t<Class>\r\n" +
                         "\t\t\t\t\t<FullName>Foo.Tests.FooTestFixture</FullName>\r\n" +
                         "\t\t\t\t\t<Methods>\r\n" +
                         "\t\t\t\t\t\t<Method visited=\"true\" cyclomaticComplexity=\"1\" sequenceCoverage=\"100\" branchCoverage=\"100\" isConstructor=\"false\" isStatic=\"false\" isGetter=\"false\" isSetter=\"false\">\r\n" +
                         "\t\t\t\t\t\t\t<MetadataToken>100663297</MetadataToken>\r\n" +
                         "\t\t\t\t\t\t\t<Name>System.Void Foo.Tests.FooTestFixture::SimpleTest()</Name>\r\n" +
                         "\t\t\t\t\t\t\t<FileRef uid=\"1\" />\r\n" +
                         "\t\t\t\t\t\t\t<SequencePoints>\r\n" +
                         "\t\t\t\t\t\t\t\t<SequencePoint vc=\"1\" sl=\"1\" sc=\"3\" el=\"1\" ec=\"4\" />\r\n" +
                         "\t\t\t\t\t\t\t\t<SequencePoint vc=\"1\" sl=\"2\" sc=\"4\" el=\"2\" ec=\"18\" />\r\n" +
                         "\t\t\t\t\t\t\t\t<SequencePoint vc=\"0\" sl=\"3\" sc=\"3\" el=\"3\" ec=\"4\" />\r\n" +
                         "\t\t\t\t\t\t\t</SequencePoints>\r\n" +
                         "\t\t\t\t\t\t</Method>\r\n" +
                         "\t\t\t\t\t</Methods>\r\n" +
                         "\t\t\t\t</Class>\r\n" +
                         "\t\t\t</Classes>\r\n" +
                         "\t\t</Module>\r\n" +
                         "\t</Modules>\r\n" +
                         "</CoverageSession>";
            CodeCoverageResults     results     = new CodeCoverageResults(new StringReader(xml));
            CodeCoverageMethod      method      = results.Modules[0].Methods[0];
            CodeCoverageHighlighter highlighter = new CodeCoverageHighlighter();

            highlighter.AddMarkers(document, method.SequencePoints);

            // Add non-code coverage markers.
            markerStrategy.Create(0, 2);
            markerStrategy.Create(4, 5);
        }
		public void SetUpTestFixture()
		{
			try {
				string configFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "NCoverAddIn.Tests");
				PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests");
			} catch (Exception) {}
			
			document = MockTextMarkerService.CreateDocumentWithMockService();
			markerStrategy = document.GetService(typeof(ITextMarkerService)) as ITextMarkerService;
			string code = "\t\t{\r\n" +
				"\t\t\tint count = 0;\r\n" +
				"\t\t}\r\n";
			document.Text = code;
			
			string xml = "<CoverageSession xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n" +
				"\t<Modules>\r\n" +
				"\t\t<Module hash=\"44-54-B6-13-97-49-45-F8-6A-74-9E-49-0C-77-87-C6-9C-54-47-7A\">\r\n" +
				"\t\t\t<FullName>C:\\Projects\\Test\\Foo.Tests\\bin\\Foo.Tests.DLL</FullName>\r\n" +
				"\t\t\t<ModuleName>Foo.Tests</ModuleName>\r\n" +
				"\t\t\t<Files>\r\n" +
				"\t\t\t\t<File uid=\"1\" fullPath=\"c:\\Projects\\Foo\\FooTestFixture.cs\" />\r\n" +
				"\t\t\t</Files>\r\n" +
				"\t\t\t<Classes>\r\n" +
				"\t\t\t\t<Class>\r\n" +
				"\t\t\t\t\t<FullName>Foo.Tests.FooTestFixture</FullName>\r\n" +
				"\t\t\t\t\t<Methods>\r\n" +
				"\t\t\t\t\t\t<Method visited=\"true\" cyclomaticComplexity=\"1\" sequenceCoverage=\"100\" branchCoverage=\"100\" isConstructor=\"false\" isStatic=\"false\" isGetter=\"false\" isSetter=\"false\">\r\n" +
				"\t\t\t\t\t\t\t<MetadataToken>100663297</MetadataToken>\r\n" +
				"\t\t\t\t\t\t\t<Name>System.Void Foo.Tests.FooTestFixture::SimpleTest()</Name>\r\n" +
				"\t\t\t\t\t\t\t<FileRef uid=\"1\" />\r\n" +
				"\t\t\t\t\t\t\t<SequencePoints>\r\n" +
				"\t\t\t\t\t\t\t\t<SequencePoint vc=\"1\" sl=\"1\" sc=\"3\" el=\"1\" ec=\"4\" />\r\n" +
				"\t\t\t\t\t\t\t\t<SequencePoint vc=\"1\" sl=\"2\" sc=\"4\" el=\"2\" ec=\"18\" />\r\n" +
				"\t\t\t\t\t\t\t\t<SequencePoint vc=\"0\" sl=\"3\" sc=\"3\" el=\"3\" ec=\"4\" />\r\n" +
				"\t\t\t\t\t\t\t</SequencePoints>\r\n" +
				"\t\t\t\t\t\t</Method>\r\n" +
				"\t\t\t\t\t</Methods>\r\n" +
				"\t\t\t\t</Class>\r\n" +
				"\t\t\t</Classes>\r\n" +
				"\t\t</Module>\r\n" +
				"\t</Modules>\r\n" +
				"</CoverageSession>";
			CodeCoverageResults results = new CodeCoverageResults(new StringReader(xml));
			CodeCoverageMethod method = results.Modules[0].Methods[0];
			CodeCoverageHighlighter highlighter = new CodeCoverageHighlighter();
			highlighter.AddMarkers(document, method.SequencePoints);	
			
			// Add non-code coverage markers.
			markerStrategy.Create(0, 2);
			markerStrategy.Create(4, 5);
		}
예제 #5
0
        void AddMarkerFromSelectionClick(object sender, RoutedEventArgs e)
        {
            ITextMarker marker = textMarkerService.Create(textEditor.SelectionStart, textEditor.SelectionLength);

            marker.MarkerTypes = TextMarkerTypes.SquigglyUnderline;
            marker.MarkerColor = Colors.Red;
        }
        public void ShowExample(TextArea exampleTextArea)
        {
            string exampleText            = StringParser.Parse(color.ExampleText, GetXshdProperties().ToArray());
            int    semanticHighlightStart = exampleText.IndexOf("#{#", StringComparison.OrdinalIgnoreCase);
            int    semanticHighlightEnd   = exampleText.IndexOf("#}#", StringComparison.OrdinalIgnoreCase);

            if (semanticHighlightStart > -1 && semanticHighlightEnd >= semanticHighlightStart + 3)
            {
                semanticHighlightEnd -= 3;
                exampleText           = exampleText.Remove(semanticHighlightStart, 3).Remove(semanticHighlightEnd, 3);
                ITextMarkerService svc = exampleTextArea.GetService(typeof(ITextMarkerService)) as ITextMarkerService;
                exampleTextArea.Document.Text = exampleText;
                if (svc != null)
                {
                    ITextMarker m = svc.Create(semanticHighlightStart, semanticHighlightEnd - semanticHighlightStart);
                    m.Tag = (Action <IHighlightingItem, ITextMarker>)(
                        (IHighlightingItem item, ITextMarker marker) => {
                        marker.BackgroundColor = item.Background;
                        marker.ForegroundColor = item.Foreground;
                        marker.FontStyle       = item.Italic ? FontStyles.Italic : FontStyles.Normal;
                        marker.FontWeight      = item.Bold ? FontWeights.Bold : FontWeights.Normal;
                        if (item.Underline)
                        {
                            marker.MarkerColor = item.Foreground;
                            marker.MarkerTypes = TextMarkerTypes.NormalUnderline;
                        }
                    });
                }
            }
            else
            {
                exampleTextArea.Document.Text = exampleText;
            }
        }
예제 #7
0
        private void TE_TextChanged(object sender, EventArgs e)
        {
            toolTipService.RemoveAll();
            textMarkerService.RemoveAll(delegate(ITextMarker marker) { return(true); });

            var textEditor = sender as TextEditor;
            var text       = textEditor.Text;
            var tuple      = Controller.Check(text);

            Errors = tuple.Item2;
            tree   = tuple.Item1;

            Debug.WriteLine("\n");
            Errors.ForEach((VoltaCompilerError error) => {
                int offset         = textEditor.Document.GetOffset(error.Line, error.Column);
                ITextMarker marker = textMarkerService.Create(offset, 0);
                marker.MarkerTypes = TextMarkerTypes.SquigglyUnderline;
                marker.MarkerColor = Colors.Red;

                toolTipService.CreateErrorToolTip(error, marker as TextMarker);
            });

            OnErrorListUpdated?.Invoke(Errors);

            if (e != null)
            {
                CodeFile.HasUnsavedChanges = true;
            }
        }
예제 #8
0
        void AddErrorHighlight(int start, int length)
        {
            ITextMarker marker = textMarkerService.Create(start, length);

            marker.MarkerTypes = TextMarkerTypes.SquigglyUnderline;
            marker.MarkerColor = Colors.Red;
        }
        private void DisplayValidationError(string message, int linePosition, int lineNumber)
        {
            ErrorsRow.Height = new GridLength(1, GridUnitType.Star);

            ValidationErrors.Add(new ValidationError
            {
                Message      = message,
                LineNumber   = lineNumber,
                LinePosition = linePosition
            });

            if (lineNumber < 1 || lineNumber > TextEditor.Document.LineCount)
            {
                return;
            }

            var offset    = TextEditor.Document.GetOffset(new TextLocation(lineNumber, linePosition));
            var endOffset = TextUtilities.GetNextCaretPosition(TextEditor.Document, offset,
                                                               System.Windows.Documents.LogicalDirection.Forward, CaretPositioningMode.WordBorderOrSymbol);

            if (endOffset < 0)
            {
                endOffset = TextEditor.Document.TextLength;
            }

            var length = endOffset - offset;

            if (length < 2)
            {
                length = Math.Min(2, TextEditor.Document.TextLength - offset);
            }

            _textMarkerService.Create(offset, length, message);
        }
		/// <summary>
		/// <inheritdoc/>
		/// </summary>
		/// <param name="markerService"><inheritdoc/></param>
		/// <returns><inheritdoc/></returns>
		protected override ITextMarker CreateMarker(ITextMarkerService markerService)
		{
			IDocumentLine line = this.Document.GetLine(this.LineNumber);
			ITextMarker marker = markerService.Create(line.Offset, line.Length);
			marker.BackgroundColor = Color.FromRgb(162, 208, 80);
			marker.ForegroundColor = Colors.White;
			return marker;
		}
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                CSharpCodeProvider provider   = new CSharpCodeProvider();
                CompilerParameters parameters = new CompilerParameters();
                parameters.ReferencedAssemblies.Add("System.dll");
                parameters.ReferencedAssemblies.Add("System.Net.Http.dll");
                //parameters.ReferencedAssemblies.Add("PresentationFramework.dll");
                //parameters.ReferencedAssemblies.Add("PresentationCore.dll");
                //parameters.ReferencedAssemblies.Add("System.dll");
                parameters.ReferencedAssemblies.Add("FacebookIDE.exe");
                parameters.GenerateInMemory   = true;
                parameters.GenerateExecutable = false;


                CompilerResults results = provider.CompileAssemblyFromSource(parameters, editor.Document.Text);

                ErrorList.Clear();
                textMarkerService.RemoveAll(m => true);
                if (results.Errors.Count > 0)
                {
                    foreach (CompilerError err in results.Errors)
                    {
                        ErrorList.Add(err);

                        var         line   = editor.Document.GetLineByNumber(err.Line);
                        ITextMarker marker = textMarkerService.Create(line.Offset + err.Column, line.Length);
                        marker.MarkerTypes = TextMarkerTypes.SquigglyUnderline;
                        marker.MarkerColor = Colors.Red;
                    }
                    return;
                }

                Assembly assembly = results.CompiledAssembly;
                Type     program  = assembly.GetType("Script");
                var      method   = program.GetMethod("GetSeries");
                var      method2  = program.GetMethod("GetCollection");
                var      instance = assembly.CreateInstance("Script");

                method.Invoke(instance, null);

                SeriesCollection s = (SeriesCollection)method2.Invoke(instance, null);

                chart.Series = s;

                tab_control.SelectedIndex = 1;
            }
            catch (TargetInvocationException tie)
            {
                MessageBox.Show(tie.Message + "\r\n\r\n" + tie.InnerException.Message, "Script Error", MessageBoxButton.OK, MessageBoxImage.Error);;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #12
0
        protected override ITextMarker CreateMarker(ITextMarkerService markerService)
        {
            IDocumentLine line   = this.Document.GetLine(startLine);
            ITextMarker   marker = markerService.Create(line.Offset + startColumn - 1, Math.Max(endColumn - startColumn, 1));

            marker.BackgroundColor = Colors.Yellow;
            marker.ForegroundColor = Colors.Blue;
            return(marker);
        }
예제 #13
0
        protected override ITextMarker CreateMarker(ITextMarkerService markerService)
        {
            IDocumentLine line   = this.Document.GetLine(this.LineNumber);
            ITextMarker   marker = markerService.Create(line.Offset, line.Length);

            marker.BackgroundColor = Color.FromRgb(180, 38, 38);
            marker.ForegroundColor = Colors.White;
            return(marker);
        }
예제 #14
0
        public void CodeCoverageHighlighterRemoveMarkersDoesNotThrowInvalidCastExceptionWhenOneMarkerTagIsTask()
        {
            ITextMarker textMarker = markerService.Create(0, 2);

            textMarker.Tag = new Task(null, String.Empty, 1, 1, TaskType.Error);

            CodeCoverageHighlighter highlighter = new CodeCoverageHighlighter();

            Assert.DoesNotThrow(delegate { highlighter.RemoveMarkers(document); });
        }
예제 #15
0
 private void AddSquigglies()
 {
     foreach (var error in _errorListener.Errors)
     {
         var lineOffset = CodeEditor.Document.Lines[Math.Max(0, error.Line - 1)].Offset;
         var length     = error.OffendingSymbol.Text == "<EOF>" ? 0 : error.OffendingSymbol.Text.Length;
         var marker     = _textMarkerService.Create(lineOffset + Math.Max(0, error.CharPositionInLine), length);
         marker.MarkerTypes = TextMarkerTypes.SquigglyUnderline;
         marker.MarkerColor = Colors.Red;
     }
 }
예제 #16
0
		public override ITextMarker CreateMarker(ITextMarkerService markerService, int offset, int length)
		{
			ITextMarker marker = markerService.Create(offset + startColumn - 1, length + 1);
			marker.BackgroundColor = Colors.Yellow;
			marker.ForegroundColor = Colors.Blue;
			marker.IsVisible = b => b is MarkerBookmark && DebugInformation.DecompiledMemberReferences != null &&
				DebugInformation.DecompiledMemberReferences.ContainsKey(((MarkerBookmark)b).MemberReference.MetadataToken.ToInt32());
			marker.Bookmark = this;
			this.Marker = marker;
			return marker;
		}
예제 #17
0
        public override ITextMarker CreateMarker(ITextMarkerService markerService, int offset, int length)
        {
            ITextMarker marker = markerService.Create(offset + startColumn - 1, length + 1);

            marker.BackgroundColor = Colors.Yellow;
            marker.ForegroundColor = Colors.Blue;
            marker.IsVisible       = b => b is MarkerBookmark && DebugInformation.CodeMappings != null &&
                                     DebugInformation.CodeMappings.ContainsKey(((MarkerBookmark)b).MemberReference.MDToken.ToInt32());
            marker.Bookmark = this;
            this.Marker     = marker;
            return(marker);
        }
예제 #18
0
        void UpdateErrorMarkers(SqlException ex)
        {
            var doc = _avEdit.Document;

            foreach (SqlError err in ex.Errors)
            {
                var line   = doc.GetLineByNumber(err.LineNumber);
                var marker = _textMarkerService.Create(line.Offset, line.Length);
                marker.MarkerTypes = TextMarkerTypes.SquigglyUnderline;
                marker.MarkerColor = Colors.Red;
            }
        }
예제 #19
0
 public void AddMarker(XPathNodeMatch node)
 {
     if (node.HasLineInfo() && node.Value.Length > 0)
     {
         int offset = document.PositionToOffset(node.LineNumber + 1, node.LinePosition + 1);
         if (markerService != null)
         {
             ITextMarker marker = markerService.Create(offset, node.Value.Length);
             marker.Tag             = typeof(XPathNodeTextMarker);
             marker.BackgroundColor = MarkerBackColor;
         }
     }
 }
예제 #20
0
        public override ITextMarker CreateMarker(ITextMarkerService markerService, int offset, int length)
        {
            ITextMarker marker = markerService.Create(offset, length);

            marker.BackgroundColor = Color.FromRgb(180, 38, 38);
            marker.ForegroundColor = Colors.White;
            marker.IsVisible       = b => b is MarkerBookmark && DebugInformation.DecompiledMemberReferences != null &&
                                     DebugInformation.DecompiledMemberReferences.ContainsKey(((MarkerBookmark)b).MemberReference.MetadataToken.ToInt32());
            marker.Bookmark = this;
            this.Marker     = marker;

            return(marker);
        }
        public override ITextMarker CreateMarker(ITextMarkerService markerService, int offset, int length)
        {
            ITextMarker marker = markerService.Create(offset, length);

            marker.BackgroundColor = Color.FromRgb(180, 38, 38);
            marker.ForegroundColor = Colors.White;
            marker.IsVisible       = b => b is BreakpointBookmark && DebugInformation.CodeMappings != null &&
                                     DebugInformation.CodeMappings.ContainsKey(((BreakpointBookmark)b).FunctionToken);
            marker.Bookmark = this;
            this.Marker     = marker;

            return(marker);
        }
        public void SetUpTestFixture()
        {
            try {
                string configFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "NCoverAddIn.Tests");
                PropertyService.InitializeService(configFolder, Path.Combine(configFolder, "data"), "NCoverAddIn.Tests");
            } catch (Exception) {}

            document       = MockTextMarkerService.CreateDocumentWithMockService();
            markerStrategy = document.GetService(typeof(ITextMarkerService)) as ITextMarkerService;
            string code = "\t\t{\r\n" +
                          "\t\t\tint count = 0;\r\n" +
                          "\t\t}\r\n";

            document.Text = code;

            string xml = "<PartCoverReport>\r\n" +
                         "\t<File id=\"1\" url=\"c:\\Projects\\Foo\\FooTestFixture.cs\"/>\r\n" +
                         "\t<Assembly id=\"1\" name=\"Foo.Tests\" module=\"C:\\Projects\\Test\\bin\\Foo.Tests.DLL\" domain=\"test-domain-Foo.Tests.dll\" domainIdx=\"1\" />\r\n" +
                         "\t<Type name=\"Foo.Tests.FooTestFixture\" asmref=\"1\">\r\n" +
                         "\t\t<Method name=\"SimpleTest\">\r\n" +
                         "\t\t\t<pt visit=\"1\" sl=\"1\" sc=\"3\" el=\"1\" ec=\"4\" fid=\"1\" />\r\n" +
                         "\t\t\t<pt visit=\"1\" sl=\"2\" sc=\"4\" el=\"2\" ec=\"18\" fid=\"1\" />\r\n" +
                         "\t\t\t<pt visit=\"0\" sl=\"3\" sc=\"3\" el=\"3\" ec=\"4\" fid=\"1\" />\r\n" +
                         "\t\t</Method>\r\n" +
                         "\t</Type>\r\n" +
                         "</PartCoverReport>";
            CodeCoverageResults     results     = new CodeCoverageResults(new StringReader(xml));
            CodeCoverageMethod      method      = results.Modules[0].Methods[0];
            CodeCoverageHighlighter highlighter = new CodeCoverageHighlighter();

            highlighter.AddMarkers(document, method.SequencePoints);

            // Add non-code coverage markers.
            markerStrategy.Create(0, 2);
            markerStrategy.Create(4, 5);
        }
예제 #23
0
        void ParseInformationUpdated(object sender, ICSharpCode.SharpDevelop.Parser.ParseInformationEventArgs e)
        {
            if (!e.FileName.Equals(textView.Document.FileName))
            {
                return;
            }
            ITextMarkerService markerService = textView.GetService <ITextMarkerService>();

            if (markerService == null)
            {
                return;
            }
            markerService.RemoveAll(m => m.Tag is Error);
            foreach (Error error in e.NewUnresolvedFile.Errors)
            {
                var offset    = textView.Document.GetOffset(error.Region.Begin);
                var endOffset = textView.Document.GetOffset(error.Region.End);
                int length    = endOffset - offset;

                if (length < 2)
                {
                    // marker should be at least 2 characters long, but take care that we don't make
                    // it longer than the document
                    length = Math.Min(2, textView.Document.TextLength - offset);
                }
                var marker = markerService.Create(offset, length);
                switch (error.ErrorType)
                {
                case ErrorType.Unknown:
                    marker.MarkerColor = Colors.Blue;
                    break;

                case ErrorType.Error:
                    marker.MarkerColor = Colors.Red;
                    break;

                case ErrorType.Warning:
                    marker.MarkerColor = Colors.Orange;
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                marker.MarkerTypes = TextMarkerTypes.SquigglyUnderline;
                marker.ToolTip     = error.Message;
                marker.Tag         = error;
            }
        }
예제 #24
0
        ITextMarker CreateMarkerInternal(ITextMarkerService markerService, ITextEditorUIContext uiContext)
        {
            TextPosition location, endLocation;

            if (!GetLocation(uiContext, out location, out endLocation))
            {
                throw new InvalidOperationException();
            }

            var line        = markerService.TextView.Document.GetLineByNumber(location.Line);
            var endLine     = markerService.TextView.Document.GetLineByNumber(endLocation.Line);
            int startOffset = line.Offset + location.Column - 1;
            int endOffset   = endLine.Offset + endLocation.Column - 1;

            return(markerService.Create(startOffset, endOffset - startOffset));
        }
예제 #25
0
        protected ITextMarker CreateMarkerInternal(ITextMarkerService markerService, DecompilerTextView textView)
        {
            TextLocation location, endLocation;

            if (!GetLocation(textView, out location, out endLocation))
            {
                throw new InvalidOperationException();
            }

            var line        = markerService.TextView.Document.GetLineByNumber(location.Line);
            var endLine     = markerService.TextView.Document.GetLineByNumber(endLocation.Line);
            int startOffset = line.Offset + location.Column - 1;
            int endOffset   = endLine.Offset + endLocation.Column - 1;

            return(markerService.Create(startOffset, endOffset - startOffset));
        }
예제 #26
0
 private void RunButton_Click(object sender, RoutedEventArgs e)
 {
     textMarkerService.RemoveAll(m => true);
     try
     {
         ConsoleTextBox.Foreground = Brushes.Black;
         ConsoleTextBox.Clear();
         jsExecutor.Execute(textEditor.Text);
     }
     catch (JavascriptException ex)
     {
         ConsoleTextBox.Foreground = Brushes.Red;
         ConsoleTextBox.AppendText($"line {ex.Line} col {ex.StartColumn}: {ex.Message}");
         var         lineIndex = FindIndex(ex.Line - 1);
         ITextMarker marker    = textMarkerService.Create(lineIndex + ex.StartColumn, ex.EndColumn - ex.StartColumn);
         marker.MarkerTypes = TextMarkerTypes.SquigglyUnderline;
         marker.MarkerColor = Colors.Red;
     }
 }
예제 #27
0
        public void AddMarker(IDocument document, CodeCoverageSequencePoint sequencePoint)
        {
            if (!IsValidSequencePoint(document, sequencePoint))
            {
                return;
            }

            ITextMarkerService markerService = document.GetService(typeof(ITextMarkerService)) as ITextMarkerService;

            if (markerService != null)
            {
                int         startOffset = document.PositionToOffset(sequencePoint.Line, sequencePoint.Column);
                int         endOffset   = document.PositionToOffset(sequencePoint.EndLine, sequencePoint.EndColumn);
                ITextMarker marker      = markerService.Create(startOffset, endOffset - startOffset);
                marker.Tag             = typeof(CodeCoverageHighlighter);
                marker.BackgroundColor = GetSequencePointColor(sequencePoint);
                marker.ForegroundColor = GetSequencePointForeColor(sequencePoint);
            }
        }
예제 #28
0
        protected override ITextMarker CreateMarker(ITextMarkerService markerService)
        {
            IDocumentLine      line        = this.Document.GetLine(this.LineNumber);
            ITextMarker        marker      = markerService.Create(line.Offset, line.Length);
            ISyntaxHighlighter highlighter = this.Document.GetService(typeof(ISyntaxHighlighter)) as ISyntaxHighlighter;

            marker.BackgroundColor = DefaultBackground;
            marker.ForegroundColor = DefaultForeground;

            if (highlighter != null)
            {
                var color = highlighter.GetNamedColor(BreakpointMarker);
                if (color != null)
                {
                    marker.BackgroundColor = color.Background.GetColor(null);
                    marker.ForegroundColor = color.Foreground.GetColor(null);
                }
            }
            return(marker);
        }
        protected override ITextMarker CreateMarker(ITextMarkerService markerService)
        {
            IDocumentLine      line        = this.Document.GetLine(startLine);
            ITextMarker        marker      = markerService.Create(line.Offset + startColumn - 1, Math.Max(endColumn - startColumn, 1));
            ISyntaxHighlighter highlighter = this.Document.GetService(typeof(ISyntaxHighlighter)) as ISyntaxHighlighter;

            marker.BackgroundColor = DefaultBackground;
            marker.ForegroundColor = DefaultForeground;

            if (highlighter != null)
            {
                var color = highlighter.GetNamedColor(Name);
                if (color != null)
                {
                    marker.BackgroundColor = color.Background.GetColor(null);
                    marker.ForegroundColor = color.Foreground.GetColor(null);
                }
            }
            return(marker);
        }
예제 #30
0
        private async void AnalyzeCodeSyntax()
        {
            dispatcherTimer.Stop();

            try
            {
                foldingStretegy.UpdateFoldings(foldingManager, _editor.Document);

                var errorService = ErrorService.GetService();
                errorService.Clear();


                var d = await CodeAnalysisService.LoadDocument(_editor.Document.Text).GetDiagnosticsAsync();

                var s = d.Select(x =>
                {
                    var cd    = new CompilationDiagnostic(x);
                    var line  = _editor.Document.GetLineByOffset(x.Location.SourceSpan.Start);
                    cd.Line   = line.LineNumber;
                    cd.Column = line.Length;
                    return(cd);
                });

                errorService.AddRange(s);

                textMarkerService.RemoveAll(m => true);

                foreach (var item in d)
                {
                    var         span = item.Location.SourceSpan;
                    ITextMarker m    = textMarkerService.Create(span.Start, span.Length);
                    m.MarkerTypes = TextMarkerTypes.SquigglyUnderline;
                    m.MarkerColor = item.Severity == DiagnosticSeverity.Error ? Colors.Red : Colors.LightGreen;
                    m.ToolTip     = item.ToString();
                }
            }
            catch { }
        }
예제 #31
0
        protected override ITextMarker CreateMarker(ITextMarkerService markerService)
        {
            IDocumentLine line        = this.Document.GetLineByNumber(this.LineNumber);
            ITextMarker   marker      = markerService.Create(line.Offset, line.Length);
            IHighlighter  highlighter = this.Document.GetService(typeof(IHighlighter)) as IHighlighter;

            marker.BackgroundColor = BookmarkBase.BreakpointDefaultBackground;
            marker.ForegroundColor = BookmarkBase.BreakpointDefaultForeground;
            marker.MarkerColor     = BookmarkBase.BreakpointDefaultBackground;
            marker.MarkerTypes     = TextMarkerTypes.CircleInScrollBar;

            if (highlighter != null)
            {
                var color = highlighter.GetNamedColor(BookmarkBase.BreakpointMarkerName);
                if (color != null)
                {
                    marker.BackgroundColor = color.Background.GetColor(null);
                    marker.MarkerColor     = color.Background.GetColor(null) ?? BookmarkBase.BreakpointDefaultForeground;
                    marker.ForegroundColor = color.Foreground.GetColor(null);
                }
            }
            return(marker);
        }
예제 #32
0
        protected override ITextMarker CreateMarker(ITextMarkerService markerService)
        {
            IDocumentLine sLine       = this.Document.GetLineByNumber(startLine);
            IDocumentLine eLine       = this.Document.GetLineByNumber(endLine);
            int           sOffset     = Math.Min(sLine.Offset + startColumn - 1, sLine.EndOffset);
            int           eOffset     = Math.Min(eLine.Offset + endColumn - 1, eLine.EndOffset);
            ITextMarker   marker      = markerService.Create(sOffset, Math.Max(eOffset - sOffset, 1));
            IHighlighter  highlighter = this.Document.GetService(typeof(IHighlighter)) as IHighlighter;

            marker.BackgroundColor = BookmarkBase.CurrentLineDefaultBackground;
            marker.ForegroundColor = BookmarkBase.CurrentLineDefaultForeground;

            if (highlighter != null)
            {
                var color = highlighter.GetNamedColor(BookmarkBase.CurrentLineBookmarkName);
                if (color != null)
                {
                    marker.BackgroundColor = color.Background.GetColor(null);
                    marker.ForegroundColor = color.Foreground.GetColor(null);
                }
            }
            return(marker);
        }
예제 #33
0
            public void CreateMarker(IDocument document, ITextMarkerService markerService)
            {
                int startOffset = InspectedVersion.MoveOffsetTo(document.Version, this.StartOffset, AnchorMovementType.Default);
                int endOffset   = InspectedVersion.MoveOffsetTo(document.Version, this.EndOffset, AnchorMovementType.Default);

                if (this.StartOffset != this.EndOffset && startOffset >= endOffset)
                {
                    return;
                }
                marker         = markerService.Create(startOffset, endOffset - startOffset);
                marker.ToolTip = this.Description;

                Color color = GetColor(this.Severity);

                color.A            = 186;
                marker.MarkerColor = color;
                if (!Provider.IsRedundancy)
                {
                    marker.MarkerTypes = TextMarkerTypes.ScrollBarRightTriangle;
                }
                switch (MarkerType)
                {
                case IssueMarker.WavedLine:
                    marker.MarkerTypes |= TextMarkerTypes.SquigglyUnderline;
                    break;

                case IssueMarker.DottedLine:
                    marker.MarkerTypes |= TextMarkerTypes.DottedUnderline;
                    break;

                case IssueMarker.GrayOut:
                    marker.ForegroundColor = SystemColors.GrayTextColor;
                    break;
                }
                marker.Tag = this;
            }
        void DisplayTooltip(MouseEventArgs e)
        {
            int line = GetLineFromMousePosition(e);

            if (line == 0)
            {
                return;
            }

            int    startLine;
            bool   added;
            string oldText = changeWatcher.GetOldVersionFromLine(line, out startLine, out added);

            TextEditor editor = this.TextView.GetService <TextEditor>();

            markerService = this.TextView.GetService <ITextMarkerService>();

            LineChangeInfo zeroLineInfo = changeWatcher.GetChange(0);

            int  offset, length;
            bool hasNewVersion = changeWatcher.GetNewVersionFromLine(line, out offset, out length);

            if (line == 1 && zeroLineInfo.Change == ChangeType.Deleted)
            {
                int zeroStartLine; bool zeroAdded;
                startLine = 1;
                string deletedText = changeWatcher.GetOldVersionFromLine(0, out zeroStartLine, out zeroAdded);
                var    docLine     = editor.Document.GetLineByNumber(line);
                string newLine     = DocumentUtilities.GetLineTerminator(changeWatcher.CurrentDocument, 1);
                deletedText += newLine;
                deletedText += editor.Document.GetText(docLine.Offset, docLine.Length);
                if (oldText != null)
                {
                    oldText = deletedText + newLine + oldText;
                }
                else
                {
                    oldText = deletedText;
                }

                if (!hasNewVersion)
                {
                    offset        = 0;
                    length        = docLine.Length;
                    hasNewVersion = true;
                }
            }

            if (hasNewVersion)
            {
                if (marker != null)
                {
                    markerService.Remove(marker);
                }
                if (length <= 0)
                {
                    marker = null;
                    length = 0;
                }
                else
                {
                    marker = markerService.Create(offset, length);
                    marker.BackgroundColor = Colors.LightGreen;
                }
            }

            if (oldText != null)
            {
                LineChangeInfo currLineInfo = changeWatcher.GetChange(startLine);

                if (currLineInfo.Change == ChangeType.Deleted && !(line == 1 && zeroLineInfo.Change == ChangeType.Deleted))
                {
                    var docLine = editor.Document.GetLineByNumber(startLine);
                    if (docLine.DelimiterLength == 0)
                    {
                        oldText = DocumentUtilities.GetLineTerminator(changeWatcher.CurrentDocument, startLine) + oldText;
                    }
                    oldText = editor.Document.GetText(docLine.Offset, docLine.TotalLength) + oldText;
                }

                DiffControl differ = new DiffControl();
                differ.CopyEditorSettingsAndHighlighting(editor);
                differ.editor.Document.Text = oldText;

                if (oldText == string.Empty)
                {
                    differ.editor.Visibility     = Visibility.Collapsed;
                    differ.copyButton.Visibility = Visibility.Collapsed;
                }
                else
                {
                    if (differ.editor.SyntaxHighlighting != null)
                    {
                        var baseDocument     = new ReadOnlyDocument(changeWatcher.BaseDocument, TextView.Document.FileName);
                        var mainHighlighter  = new DocumentHighlighter(baseDocument, differ.editor.SyntaxHighlighting);
                        var popupHighlighter = differ.editor.TextArea.GetService(typeof(IHighlighter)) as DocumentHighlighter;

                        popupHighlighter.InitialSpanStack = mainHighlighter.GetSpanStack(currLineInfo.OldStartLineNumber);
                    }
                }

                differ.revertButton.Click += delegate {
                    if (hasNewVersion)
                    {
                        Document.Replace(offset, length, oldText);
                        tooltip.IsOpen = false;
                    }
                };

                const double borderThickness = 1;
                tooltip.Child = new Border {
                    Child           = differ,
                    BorderBrush     = editor.TextArea.Foreground,
                    BorderThickness = new Thickness(borderThickness)
                };

                if (tooltip.IsOpen)
                {
                    tooltip.IsOpen = false;
                }

                tooltip.Closed += delegate {
                    if (marker != null)
                    {
                        markerService.Remove(marker);
                    }
                };
                tooltip.HorizontalOffset = -borderThickness - TextView.ScrollOffset.X;
                tooltip.VerticalOffset   =
                    TextView.GetVisualTopByDocumentLine(startLine) - TextView.ScrollOffset.Y;
                tooltip.Placement       = PlacementMode.Top;
                tooltip.PlacementTarget = this.TextView;

                tooltip.IsOpen = true;
            }
        }
예제 #35
0
		void DisplayTooltip(MouseEventArgs e)
		{
			int line = GetLineFromMousePosition(e);
			
			if (line == 0)
				return;
			
			int startLine;
			bool added;
			string oldText = changeWatcher.GetOldVersionFromLine(line, out startLine, out added);
			
			TextEditor editor = this.TextView.Services.GetService(typeof(TextEditor)) as TextEditor;
			markerService = this.TextView.Services.GetService(typeof(ITextMarkerService)) as ITextMarkerService;
			
			LineChangeInfo zeroLineInfo = changeWatcher.GetChange(0);
			
			int offset, length;
			bool hasNewVersion = changeWatcher.GetNewVersionFromLine(line, out offset, out length);
			
			if (line == 1 && zeroLineInfo.Change == ChangeType.Deleted) {
				int zeroStartLine; bool zeroAdded;
				startLine = 1;
				string deletedText = changeWatcher.GetOldVersionFromLine(0, out zeroStartLine, out zeroAdded);
				var docLine = editor.Document.GetLineByNumber(line);
				string newLine = DocumentUtilitites.GetLineTerminator(changeWatcher.CurrentDocument, 1);
				deletedText += newLine;
				deletedText += editor.Document.GetText(docLine.Offset, docLine.Length);
				if (oldText != null)
					oldText = deletedText + newLine + oldText;
				else
					oldText = deletedText;
				
				if (!hasNewVersion) {
					offset = 0;
					length = docLine.Length;
					hasNewVersion = true;
				}
			}
			
			if (hasNewVersion) {
				if (marker != null)
					markerService.Remove(marker);
				if (length <= 0) {
					marker = null;
					length = 0;
				} else {
					marker = markerService.Create(offset, length);
					marker.BackgroundColor = Colors.LightGreen;
				}
			}
			
			if (oldText != null) {
				LineChangeInfo currLineInfo = changeWatcher.GetChange(startLine);
				
				if (currLineInfo.Change == ChangeType.Deleted && !(line == 1 && zeroLineInfo.Change == ChangeType.Deleted)) {
					var docLine = editor.Document.GetLineByNumber(startLine);
					if (docLine.DelimiterLength == 0)
						oldText = DocumentUtilitites.GetLineTerminator(changeWatcher.CurrentDocument, startLine) + oldText;
					oldText = editor.Document.GetText(docLine.Offset, docLine.TotalLength) + oldText;
				}
				
				DiffControl differ = new DiffControl();
				differ.editor.SyntaxHighlighting = editor.SyntaxHighlighting;
				differ.editor.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
				differ.editor.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;
				differ.editor.Document.Text = oldText;
				differ.Background = Brushes.White;
				
				if (oldText == string.Empty) {
					differ.editor.Visibility = Visibility.Collapsed;
					differ.copyButton.Visibility = Visibility.Collapsed;
				} else {
					var baseDocument = new TextDocument(DocumentUtilitites.GetTextSource(changeWatcher.BaseDocument));
					if (differ.editor.SyntaxHighlighting != null) {
						var mainHighlighter = new DocumentHighlighter(baseDocument, differ.editor.SyntaxHighlighting.MainRuleSet);
						var popupHighlighter = differ.editor.TextArea.GetService(typeof(IHighlighter)) as DocumentHighlighter;
						
						popupHighlighter.InitialSpanStack = mainHighlighter.GetSpanStack(currLineInfo.OldStartLineNumber);
					}
				}
				
				differ.revertButton.Click += delegate {
					if (hasNewVersion) {
						Document.Replace(offset, length, oldText);
						tooltip.IsOpen = false;
					}
				};
				
				tooltip.Child = new Border() {
					Child = differ,
					BorderBrush = Brushes.Black,
					BorderThickness = new Thickness(1)
				};
				
				if (tooltip.IsOpen)
					tooltip.IsOpen = false;
				
				tooltip.IsOpen = true;
				
				tooltip.Closed += delegate {
					if (marker != null) markerService.Remove(marker);
				};
				tooltip.HorizontalOffset = -10;
				tooltip.VerticalOffset =
					TextView.GetVisualTopByDocumentLine(startLine) - TextView.ScrollOffset.Y;
				tooltip.Placement = PlacementMode.Top;
				tooltip.PlacementTarget = this.TextView;
			}
		}
예제 #36
0
		protected override ITextMarker CreateMarker(ITextMarkerService markerService)
		{
			IDocumentLine line = this.Document.GetLineByNumber(this.LineNumber);
			ITextMarker marker = markerService.Create(line.Offset, line.Length);
			IHighlighter highlighter = this.Document.GetService(typeof(IHighlighter)) as IHighlighter;
			marker.BackgroundColor = DefaultBackground;
			marker.ForegroundColor = DefaultForeground;
			marker.MarkerColor = DefaultBackground;
			marker.MarkerTypes = TextMarkerTypes.CircleInScrollBar;
			
			if (highlighter != null) {
				var color = highlighter.GetNamedColor(BreakpointMarker);
				if (color != null) {
					marker.BackgroundColor = color.Background.GetColor(null);
					marker.MarkerColor = color.Background.GetColor(null) ?? DefaultBackground;
					marker.ForegroundColor = color.Foreground.GetColor(null);
				}
			}
			return marker;
		}
		protected override void OnMouseMove(MouseEventArgs e)
		{
			int line = GetLineFromMousePosition(e);
			
			if (line == 0)
				return;
			
			int startLine;
			bool added;
			string oldText = changeWatcher.GetOldVersionFromLine(line, out startLine, out added);
			
			TextEditor editor = this.TextView.Services.GetService(typeof(TextEditor)) as TextEditor;
			markerService = this.TextView.Services.GetService(typeof(ITextMarkerService)) as ITextMarkerService;
			
			int offset, length;
			bool hasNewVersion = changeWatcher.GetNewVersionFromLine(line, out offset, out length);
			
			if (hasNewVersion) {
				if (marker != null)
					markerService.Remove(marker);
				if (length <= 0) {
					marker = null;
					length = 0;
				} else {
					marker = markerService.Create(offset, length);
					marker.BackgroundColor = Colors.LightGreen;
				}
			}
			
			if (oldText != null) {
				DiffControl differ = new DiffControl();
				differ.editor.SyntaxHighlighting = editor.SyntaxHighlighting;
				differ.editor.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
				differ.editor.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;
				differ.editor.Document.Text = oldText;
				differ.Background = Brushes.White;
				
				// TODO : deletions on line 0 cannot be displayed.
				
				LineChangeInfo prevLineInfo = changeWatcher.GetChange(startLine - 1);
				LineChangeInfo lineInfo = changeWatcher.GetChange(startLine);
				
				if (prevLineInfo.Change == ChangeType.Deleted) {
					var docLine = editor.Document.GetLineByNumber(startLine - 1);
					differ.editor.Document.Insert(0, editor.Document.GetText(docLine.Offset, docLine.TotalLength));
				}
				
				if (oldText == string.Empty) {
					differ.editor.Visibility = Visibility.Collapsed;
					differ.copyButton.Visibility = Visibility.Collapsed;
				} else {
					var baseDocument = new TextDocument(changeWatcher.BaseDocument.Text);
					var mainHighlighter = new DocumentHighlighter(baseDocument, differ.editor.SyntaxHighlighting.MainRuleSet);
					var popupHighlighter = differ.editor.TextArea.GetService(typeof(IHighlighter)) as DocumentHighlighter;
					
					if (prevLineInfo.Change == ChangeType.Deleted)
						popupHighlighter.InitialSpanStack = mainHighlighter.GetSpanStack(prevLineInfo.OldStartLineNumber);
					else
						popupHighlighter.InitialSpanStack = mainHighlighter.GetSpanStack(lineInfo.OldStartLineNumber);
				}
				
				differ.revertButton.Click += delegate {
					if (hasNewVersion) {
						int delimiter = 0;
						DocumentLine l = Document.GetLineByOffset(offset + length);
						if (added)
							delimiter = l.DelimiterLength;
						if (length == 0)
							oldText += DocumentUtilitites.GetLineTerminator(new AvalonEditDocumentAdapter(Document, null), l.LineNumber);
						Document.Replace(offset, length + delimiter, oldText);
						tooltip.IsOpen = false;
					}
				};
				
				tooltip.Child = new Border() {
					Child = differ,
					BorderBrush = Brushes.Black,
					BorderThickness = new Thickness(1)
				};
				
				if (tooltip.IsOpen)
					tooltip.IsOpen = false;
				
				tooltip.IsOpen = true;
				
				tooltip.Closed += delegate {
					if (marker != null) markerService.Remove(marker);
				};
				
				tooltip.HorizontalOffset = -10;
				tooltip.VerticalOffset =
					TextView.GetVisualTopByDocumentLine(startLine) - TextView.ScrollOffset.Y;
				tooltip.Placement = PlacementMode.Top;
				tooltip.PlacementTarget = this.TextView;
			}
			
			base.OnMouseMove(e);
		}
예제 #38
0
			public void CreateMarker(IDocument document, ITextMarkerService markerService)
			{
				int startOffset = InspectedVersion.MoveOffsetTo(document.Version, this.StartOffset, AnchorMovementType.Default);
				int endOffset = InspectedVersion.MoveOffsetTo(document.Version, this.EndOffset, AnchorMovementType.Default);
				if (this.StartOffset != this.EndOffset && startOffset >= endOffset)
					return;
				marker = markerService.Create(startOffset, endOffset - startOffset);
				marker.ToolTip = this.Description;
				
				Color color = GetColor(this.Severity);
				color.A = 186;
				marker.MarkerColor = color;
				if (!Provider.IsRedundancy)
					marker.MarkerTypes = TextMarkerTypes.ScrollBarRightTriangle;
				switch (MarkerType) {
					case IssueMarker.WavedLine:
						marker.MarkerTypes |= TextMarkerTypes.SquigglyUnderline;
						break;
					case IssueMarker.DottedLine:
						marker.MarkerTypes |= TextMarkerTypes.DottedUnderline;
						break;
					case IssueMarker.GrayOut:
						marker.ForegroundColor = SystemColors.GrayTextColor;
						break;
				}
				marker.Tag = this;
			}
예제 #39
0
		protected override ITextMarker CreateMarker(ITextMarkerService markerService)
		{
			IDocumentLine sLine = this.Document.GetLineByNumber(startLine);
			IDocumentLine eLine = this.Document.GetLineByNumber(endLine);
			int sOffset = Math.Min(sLine.Offset + startColumn - 1, sLine.EndOffset);
			int eOffset = Math.Min(eLine.Offset + endColumn - 1, eLine.EndOffset);
			ITextMarker marker = markerService.Create(sOffset, Math.Max(eOffset - sOffset, 1));
			IHighlighter highlighter = this.Document.GetService(typeof(IHighlighter)) as IHighlighter;
			marker.BackgroundColor = BookmarkBase.CurrentLineDefaultBackground;
			marker.ForegroundColor = BookmarkBase.CurrentLineDefaultForeground;
			
			if (highlighter != null) {
				var color = highlighter.GetNamedColor(BookmarkBase.CurrentLineBookmarkName);
				if (color != null) {
					marker.BackgroundColor = color.Background.GetColor(null);
					marker.ForegroundColor = color.Foreground.GetColor(null);
				}
			}
			return marker;
		}
		protected override void OnMouseMove(MouseEventArgs e)
		{
			int line = GetLineFromMousePosition(e);
			
			if (line == 0)
				return;
			
			int startLine;
			string oldText = changeWatcher.GetOldVersionFromLine(line, out startLine);
			
			int offset, length;
			
			TextEditor editor = this.TextView.Services.GetService(typeof(TextEditor)) as TextEditor;
			markerService = this.TextView.Services.GetService(typeof(ITextMarkerService)) as ITextMarkerService;

			
			if (changeWatcher.GetNewVersionFromLine(line, out offset, out length)) {
				if (marker != null)
					markerService.Remove(marker);
				marker = markerService.Create(offset, length);
				marker.BackgroundColor = Colors.LightGreen;
			}
			
			if (oldText != null) {
				DiffControl differ = new DiffControl();
				differ.editor.SyntaxHighlighting = editor.SyntaxHighlighting;
				differ.editor.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden;
				differ.editor.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden;
				differ.editor.Document.Text = oldText;
				differ.Background = Brushes.White;
				
				DocumentHighlighter mainHighlighter = TextView.Services.GetService(typeof(IHighlighter)) as DocumentHighlighter;
				DocumentHighlighter popupHighlighter = differ.editor.TextArea.GetService(typeof(IHighlighter)) as DocumentHighlighter;
				
//				popupHighlighter.InitialSpanStack = mainHighlighter.GetSpanStack(
				
				if (oldText == string.Empty) {
					differ.editor.Visibility = Visibility.Collapsed;
				}
				
				differ.undoButton.Click += delegate {
					if (marker != null) {
						int delimiter = 0;
						if (oldText == string.Empty)
							delimiter = Document.GetLineByOffset(offset + length).DelimiterLength;
						Document.Replace(offset, length + delimiter, oldText);
						tooltip.IsOpen = false;
					}
				};
				
				tooltip.Child = new Border() {
					Child = differ,
					BorderBrush = Brushes.Black,
					BorderThickness = new Thickness(1)
				};
				
				if (tooltip.IsOpen)
					tooltip.IsOpen = false;
				
				tooltip.IsOpen = true;
				
				tooltip.Closed += delegate {
					if (marker != null) markerService.Remove(marker);
				};
				
				tooltip.HorizontalOffset = -10;
				tooltip.VerticalOffset =
					TextView.GetVisualTopByDocumentLine(startLine) - TextView.ScrollOffset.Y;
				tooltip.Placement = PlacementMode.Top;
				tooltip.PlacementTarget = this.TextView;
			}
			
			base.OnMouseMove(e);
		}
예제 #41
0
        protected ITextMarker CreateMarkerInternal(ITextMarkerService markerService, DecompilerTextView textView)
        {
            TextLocation location, endLocation;
            if (!GetLocation(textView, out location, out endLocation))
                throw new InvalidOperationException();

            var line = markerService.TextView.Document.GetLineByNumber(location.Line);
            var endLine = markerService.TextView.Document.GetLineByNumber(endLocation.Line);
            int startOffset = line.Offset + location.Column - 1;
            int endOffset = endLine.Offset + endLocation.Column - 1;

            return markerService.Create(startOffset, endOffset - startOffset);
        }
예제 #42
0
		protected override ITextMarker CreateMarker(ITextMarkerService markerService)
		{
			IDocumentLine line = this.Document.GetLine(startLine);
			ITextMarker marker = markerService.Create(line.Offset + startColumn - 1, Math.Max(endColumn - startColumn, 1));
			ISyntaxHighlighter highlighter = this.Document.GetService(typeof(ISyntaxHighlighter)) as ISyntaxHighlighter;
			marker.BackgroundColor = DefaultBackground;
			marker.ForegroundColor = DefaultForeground;
			
			if (highlighter != null) {
				var color = highlighter.GetNamedColor(Name);
				if (color != null) {
					marker.BackgroundColor = color.Background.GetColor(null);
					marker.ForegroundColor = color.Foreground.GetColor(null);
				}
			}
			return marker;
		}
예제 #43
0
		protected override ITextMarker CreateMarker(ITextMarkerService markerService)
		{
			IDocumentLine line = this.Document.GetLine(startLine);
			ITextMarker marker = markerService.Create(line.Offset + startColumn - 1, Math.Max(endColumn - startColumn, 1));
			marker.BackgroundColor = Colors.Yellow;
			marker.ForegroundColor = Colors.Blue;
			return marker;
		}
예제 #44
0
		public override ITextMarker CreateMarker(ITextMarkerService markerService, int offset, int length)
		{
			ITextMarker marker = markerService.Create(offset, length);
			marker.BackgroundColor = Color.FromRgb(180, 38, 38);
			marker.ForegroundColor = Colors.White;
			marker.IsVisible = b => b is BreakpointBookmark && DebugInformation.CodeMappings != null &&
				DebugInformation.CodeMappings.ContainsKey(((BreakpointBookmark)b).FunctionToken);
			marker.Bookmark = this;
			this.Marker = marker;
			
			return marker;
		}
예제 #45
0
		ITextMarker CreateMarkerInternal(ITextMarkerService markerService, ITextEditorUIContext uiContext) {
			TextPosition location, endLocation;
			if (!GetLocation(uiContext, out location, out endLocation))
				throw new InvalidOperationException();

			var line = markerService.TextView.Document.GetLineByNumber(location.Line);
			var endLine = markerService.TextView.Document.GetLineByNumber(endLocation.Line);
			int startOffset = line.Offset + location.Column - 1;
			int endOffset = endLine.Offset + endLocation.Column - 1;

			return markerService.Create(startOffset, endOffset - startOffset);
		}