コード例 #1
0
        /// <summary>
        /// Occurs when the mouse pointer is over the control and a
        /// mouse button is pressed.
        /// </summary>
        void TextEditorControlDoubleClick(object sender, EventArgs e)
        {
            string fullText = textEditorControl.Text;

            // Any text?
            if (fullText.Length > 0)
            {
                //int line = textEditorControl.ActiveTextAreaControl.Caret.Line;
                //string textLine = TextUtilities.GetLineAsString(textEditorControl.Document, line);
                Point clickPos = textEditorControl.PointToClient(Control.MousePosition);
                int   index    = textEditorControl.GetCharIndexFromPosition(clickPos);
                int   start    = index;
                // find start of current line
                while (--start > 0 && fullText[start - 1] != '\n')
                {
                    ;
                }
                // find end of current line
                while (++index < fullText.Length && fullText[index] != '\n')
                {
                    ;
                }

                string textLine = fullText.Substring(start, index - start);

                FileLineReference lineReference = OutputTextLineParser.GetFileLineReference(textLine);
                if (lineReference != null)
                {
                    // Open matching file.
                    FileService.JumpToFilePosition(lineReference.FileName, lineReference.Line, lineReference.Column);
                }
            }
        }
コード例 #2
0
ファイル: TestResultTask.cs プロジェクト: Paccc/SharpDevelop
		public static SDTask Create(TestResult result, ITestProject project)
		{
			TaskType taskType = TaskType.Warning;
			FileLineReference lineRef = null;
			string message = String.Empty;
			
			if (result.IsFailure) {
				taskType = TaskType.Error;
				if (!result.StackTraceFilePosition.IsEmpty) {
					lineRef = new FileLineReference(result.StackTraceFilePosition.FileName, result.StackTraceFilePosition.BeginLine - 1, result.StackTraceFilePosition.BeginColumn - 1);
				}
				message = GetTestFailedMessage(result);
			} else if (result.IsIgnored) {
				message = GetTestIgnoredMessage(result);
			}
			if (lineRef == null) {
				lineRef = FindTest(result.Name, project);
			}
			FileName fileName = null;
			if (lineRef != null) {
				fileName = new FileName(Path.GetFullPath(lineRef.FileName));
				int line = lineRef.Line + 1;
				return new SDTask(fileName, message, lineRef.Column, line, taskType);
			}
			return new SDTask(fileName, message, 0, 0, taskType);
		}
コード例 #3
0
		void okButtonClick(object sender, RoutedEventArgs e)
		{
			try {
				if (listBox.SelectedItem == null)
					return;
				object tag = ((GotoEntry)listBox.SelectedItem).Tag;
				if (tag is int) {
					ITextEditor editor = GetEditor();
					if (editor != null) {
						int i = Math.Min(editor.Document.TotalNumberOfLines, Math.Max(1, (int)tag));
						editor.JumpTo(i, int.MaxValue);
					}
				} else if (tag is IClass) {
					IClass c = tag as IClass;
					CodeCompletionDataUsageCache.IncrementUsage(c.DotNetName);
					GotoRegion(c.Region, c.CompilationUnit.FileName);
				} else if (tag is IMember) {
					IMember m = tag as IMember;
					CodeCompletionDataUsageCache.IncrementUsage(m.DotNetName);
					GotoRegion(m.Region, m.DeclaringType.CompilationUnit.FileName);
				} else if (tag is FileLineReference) {
					FileLineReference flref = (FileLineReference)tag;
					if (flref.Line <= 0) {
						FileService.OpenFile(flref.FileName);
					} else {
						FileService.JumpToFilePosition(flref.FileName, flref.Line, flref.Column);
					}
				} else {
					throw new NotImplementedException("Unknown tag: " + tag);
				}
			} finally {
				Close();
			}
		}
コード例 #4
0
 void okButtonClick(object sender, RoutedEventArgs e)
 {
     try {
         if (listBox.SelectedItem == null)
         {
             return;
         }
         object tag = ((GotoEntry)listBox.SelectedItem).Tag;
         if (tag is int)
         {
             ITextEditor editor = GetEditor();
             if (editor != null)
             {
                 int i = Math.Min(editor.Document.LineCount, Math.Max(1, (int)tag));
                 editor.JumpTo(i, int.MaxValue);
             }
         }
         else if (tag is IUnresolvedEntity)
         {
             IUnresolvedEntity c = tag as IUnresolvedEntity;
             CodeCompletionDataUsageCache.IncrementUsage(c.ReflectionName);
             GotoRegion(c.Region);
         }
         else if (tag is IEntity)
         {
             IEntity m = tag as IEntity;
             CodeCompletionDataUsageCache.IncrementUsage(m.ReflectionName);
             GotoRegion(m.Region);
         }
         else if (tag is FileLineReference)
         {
             FileLineReference flref = (FileLineReference)tag;
             if (flref.Line <= 0)
             {
                 FileService.OpenFile(flref.FileName);
             }
             else
             {
                 FileService.JumpToFilePosition(flref.FileName, flref.Line, flref.Column);
             }
         }
         else
         {
             throw new NotImplementedException("Unknown tag: " + tag);
         }
     } finally {
         Close();
     }
 }
コード例 #5
0
ファイル: OutputTextLineParser.cs プロジェクト: soshan10/AI
        /// <summary>
        /// Extracts source code file reference.
        /// </summary>
        /// <param name="lineText">The text line to parse.</param>
        /// <returns>A <see cref="FileLineReference"/> if the line of text contains a
        /// file reference otherwise <see langword="null"/></returns>
        public static FileLineReference GetFileLineReference(string lineText)
        {
            FileLineReference lineReference = GetCSharpCompilerFileLineReference(lineText);

            if (lineReference == null)
            {
                lineReference = GetNUnitOutputFileLineReference(lineText, false);
            }

            if (lineReference == null)
            {
                // Also works for VB compiler output.
                lineReference = GetCppCompilerFileLineReference(lineText);
            }

            return(lineReference);
        }
コード例 #6
0
ファイル: OutputTextLineParser.cs プロジェクト: soshan10/AI
        /// <summary>
        /// Extracts source code file reference from NUnit output. (stacktrace format)
        /// </summary>
        /// <param name="lineText">The text line to parse.</param>
        /// <param name="multiline">The <paramref name="line"/> text is multilined.</param>
        /// <returns>A <see cref="FileLineReference"/> if the line of text contains a
        /// file reference otherwise <see langword="null"/></returns>
        public static FileLineReference GetNUnitOutputFileLineReference(string lineText, bool multiline)
        {
            RegexOptions regexOptions = multiline ? RegexOptions.Multiline : RegexOptions.None;

            FileLineReference result = null;

            if (lineText != null)
            {
                Match match = Regex.Match(lineText, @"\b(\w:[/\\].*?):line\s(\d+)?\r?$", regexOptions);
                while (match.Success)
                {
                    try     {
                        int line = Convert.ToInt32(match.Groups[2].Value);
                        result = new FileLineReference(match.Groups[1].Value, line);
                    } catch (FormatException) {
                    } catch (OverflowException) {
                        // Ignore.
                    }
                    match = match.NextMatch();
                }
            }

            return(result);
        }
コード例 #7
0
        /// <summary>
        /// Extracts source code file reference from NUnit output. (stacktrace format)
        /// </summary>
        /// <param name="lineText">The text line to parse.</param>
        /// <param name="multiline">The <paramref name="lineText"/> text is multilined.</param>
        /// <returns>A <see cref="FileLineReference"/> if the line of text contains a
        /// file reference otherwise <see langword="null"/></returns>
        public static FileLineReference GetNUnitOutputFileLineReference(string lineText, bool multiline)
        {
            RegexOptions regexOptions = multiline ? RegexOptions.Multiline : RegexOptions.None;

            FileLineReference result = null;

            if (lineText != null) {
                Match match = CreateStackTraceMatch(lineText, regexOptions);
                while (match.Success) {
                    try	{
                        int line = Convert.ToInt32(match.Groups[2].Value);
                        result = new FileLineReference(match.Groups[1].Value, line);
                    } catch (FormatException) {
                    } catch (OverflowException) {
                        // Ignore.
                    }
                    match = match.NextMatch();
                }
            }

            return result;
        }
コード例 #8
0
        private void CompleteSelectedEntry()
        {
            if (listBox.SelectedItem == null)
            {
                return;
            }

            string completed      = null;
            bool   partlyComplete = false;

            object tag = ((GotoEntry)listBox.SelectedItem).Tag;

            if (tag is IUnresolvedEntity)
            {
                IUnresolvedEntity c = tag as IUnresolvedEntity;
                completed      = c.Name;
                partlyComplete = (tag is IUnresolvedMember);
            }
            else if (tag is IEntity)
            {
                IEntity m = tag as IEntity;
                completed      = m.Name;
                partlyComplete = (tag is IMember);
            }
            else if (tag is FileLineReference)
            {
                FileLineReference flref = tag as FileLineReference;
                // Only complete if we are not matching with a concrete number
                if (flref.Line == 0)
                {
                    completed = Path.GetFileName(flref.FileName);
                }
                else
                {
                    return;
                }
            }
            else
            {
                // Unsupported list item, do nothing
                return;
            }

            if (completed != null)
            {
                string currentText = textBox.Text;
                int    dotPos      = currentText.IndexOf('.');
                string needle      = currentText;
                string member      = null;
                if (dotPos > 0)
                {
                    needle = currentText.Substring(0, dotPos).Trim();
                    member = currentText.Substring(dotPos + 1).Trim();
                }

                // Replace the text, set caret to end, so user can continue typing
                if (partlyComplete && (member != null))
                {
                    // Only replace the part after the dot
                    textBox.Text = needle + "." + completed;
                }
                else
                {
                    textBox.Text = completed;
                }
                textBox.CaretIndex = textBox.Text.Length;
            }
        }
コード例 #9
0
		FilePosition CreateFilePosition(FileLineReference fileLineRef)
		{
			string fileName = Path.GetFullPath(fileLineRef.FileName);
			return new FilePosition(fileName, fileLineRef.Line, fileLineRef.Column + 1);
		}