public ProjectedDocumentContext (TextEditor projectedEditor, DocumentContext originalContext)
		{
			if (projectedEditor == null)
				throw new ArgumentNullException ("projectedEditor");
			if (originalContext == null)
				throw new ArgumentNullException ("originalContext");
			this.projectedEditor = projectedEditor;
			this.originalContext = originalContext;

			if (originalContext.Project != null) {
				var originalProjectId = TypeSystemService.GetProjectId (originalContext.Project);
				if (originalProjectId != null) {
					var originalProject = TypeSystemService.Workspace.CurrentSolution.GetProject (originalProjectId);
					if (originalProject != null) {
						projectedDocument = originalProject.AddDocument (
							projectedEditor.FileName,
							projectedEditor
						);
					}
				}
			}

			projectedEditor.TextChanged += delegate(object sender, TextChangeEventArgs e) {
				if (projectedDocument != null)
					projectedDocument = projectedDocument.WithText (projectedEditor);
				ReparseDocument ();
			};

			ReparseDocument ();
		}
Пример #2
0
        public NRefactoryIndexerParameterDataProvider(MonoDevelop.Ide.Gui.TextEditor editor, IType type, string resolvedExpression)
        {
            this.editor = editor;
//			this.type = type;
            this.resolvedExpression = resolvedExpression;
            indexers = new List <IProperty> (type.Properties.Where(p => p.IsIndexer && !p.Name.Contains('.')));
        }
Пример #3
0
        public NRefactoryParameterDataProvider(MonoDevelop.Ide.Gui.TextEditor editor, NRefactoryResolver resolver, ThisResolveResult resolveResult)
        {
            this.editor = editor;
            HashSet <string> alreadyAdded = new HashSet <string> ();

            if (resolveResult.CallingType != null)
            {
                bool includeProtected = true;
                foreach (IMethod method in resolveResult.CallingType.Methods)
                {
                    if (!method.IsConstructor)
                    {
                        continue;
                    }
                    string str = ambience.GetString(method, OutputFlags.IncludeParameters);
                    if (alreadyAdded.Contains(str))
                    {
                        continue;
                    }
                    alreadyAdded.Add(str);

                    if (method.IsAccessibleFrom(resolver.Dom, resolver.CallingType, resolver.CallingMember, includeProtected))
                    {
                        methods.Add(method);
                    }
                }
            }
        }
		public NRefactoryIndexerParameterDataProvider (MonoDevelop.Ide.Gui.TextEditor editor, IType type, string resolvedExpression)
		{
			this.editor = editor;
//			this.type = type;
			this.resolvedExpression = resolvedExpression;
			indexers = new List<IProperty> (type.Properties.Where (p => p.IsIndexer && !p.Name.Contains ('.')));
		}
Пример #5
0
		static void Rollback (TextEditor editor, List<MonoDevelop.Core.Text.TextChangeEventArgs> textChanges)
		{
			for (int i = textChanges.Count - 1; i >= 0; i--) {
				var v = textChanges [i];
				editor.ReplaceText (v.Offset, v.InsertionLength, v.RemovedText);
			}
		}
		public TextFileNavigationPoint (Document doc, TextEditor buffer)
			: base (doc)
		{
			var location = buffer.CaretLocation;
			line = location.Line;
			column = location.Column;
		}
		/// <summary>
		/// This function formats a specific line after <code>ch</code> is pressed.
		/// </summary>
		/// <returns>
		/// the caret delta position the caret will be moved this number
		/// of bytes (e.g. the number of bytes inserted before the caret, or
		/// removed, if this number is negative)
		/// </returns>
		public virtual int FormatLine (TextEditor d, int line, int cursorOffset, char ch, string indentString, bool autoInsertCurlyBracket)
		{
			if (ch == '\n')
				return IndentLine (d, line, indentString);
			
			return 0;
		}
        public override void Initialize(IPadWindow window)
        {
            base.Initialize(window);

            // Call ctors
            inputEditor = new TextEditor() { Name = "input", Events = Gdk.EventMask.AllEventsMask, HeightRequest = 80 };
            editor = new TextEditor() { Name = "output", Events = Gdk.EventMask.AllEventsMask };
            vpaned = new Gtk.VPaned();
            var scr1 = new Gtk.ScrolledWindow();
            var scr2 = new Gtk.ScrolledWindow();

            // Init layout
            scr1.ShadowType = Gtk.ShadowType.In;
            scr1.Child = inputEditor;
            vpaned.Add1(scr1);
            scr1.ShowAll();
            inputEditor.ShowAll();

            scr2.ShadowType = Gtk.ShadowType.In;
            scr2.Child = editor;
            vpaned.Add2(scr2);
            scr2.ShowAll();
            editor.ShowAll();

            vpaned.ShowAll();

            // Init editors
            var o = editor.Options;
            inputEditor.Options = o;
            o.ShowLineNumberMargin = false;
            o.ShowFoldMargin = false;
            o.ShowIconMargin = false;

            editor.Document.ReadOnly = true;
            inputEditor.Text = PropertyService.Get(lastInputStringPropId, string.Empty);
            editor.Text = string.Empty;
            editor.Document.SyntaxMode = new Highlighting.DSyntaxMode();
            inputEditor.Document.SyntaxMode = new Highlighting.DSyntaxMode();
            editor.Document.MimeType = Formatting.DCodeFormatter.MimeType;
            inputEditor.Document.MimeType = Formatting.DCodeFormatter.MimeType;

            // Init toolbar
            var tb = window.GetToolbar(Gtk.PositionType.Top);

            executeButton = new Gtk.Button();
            executeButton.Image = new Gtk.Image(Gtk.Stock.Execute, Gtk.IconSize.Menu);
            executeButton.TooltipText = "Evaluates the expression typed in the upper input editor.";
            executeButton.Clicked += Execute;
            tb.Add(executeButton);

            abortButton = new Gtk.Button();
            abortButton.Sensitive = false;
            abortButton.Image = new Gtk.Image(Gtk.Stock.Stop, Gtk.IconSize.Menu);
            abortButton.TooltipText = "Stops the evaluation.";
            abortButton.Clicked += (object sender, EventArgs e) => AbortExecution();
            tb.Add(abortButton);

            tb.ShowAll();
        }
Пример #9
0
		internal void Run (TextEditor editor, DocumentContext ctx)
		{
			var info = RefactoringSymbolInfo.GetSymbolInfoAsync (ctx, editor.CaretOffset).Result;
			var sym = info.DeclaredSymbol ?? info.Symbol;
			if (!CanRename (sym))
				return;
			new RenameRefactoring ().Rename (sym);
		}
		public override async Task<TooltipItem> GetItem (TextEditor editor, DocumentContext ctx, int offset, CancellationToken token = default(CancellationToken))
		{
			if (offset >= editor.Length)
				return null;

			if (!DebuggingService.IsDebugging || DebuggingService.IsRunning)
				return null;

			StackFrame frame = DebuggingService.CurrentFrame;
			if (frame == null)
				return null;

			var ed = CompileErrorTooltipProvider.GetExtensibleTextEditor (editor);
			if (ed == null)
				return null;
			string expression = null;
			int startOffset;

			if (ed.IsSomethingSelected && offset >= ed.SelectionRange.Offset && offset <= ed.SelectionRange.EndOffset) {
				startOffset = ed.SelectionRange.Offset;
				expression = ed.SelectedText;
			} else {
				var doc = ctx;
				if (doc == null || doc.ParsedDocument == null)
					return null;

				var resolver = doc.GetContent<IDebuggerExpressionResolver> ();
				var data = doc.GetContent<SourceEditorView> ();

				if (resolver != null) {
					var result = await resolver.ResolveExpressionAsync (editor, doc, offset, token);
					expression = result.Text;
					startOffset = result.Span.Start;
				} else {
					int endOffset = data.GetTextEditorData ().FindCurrentWordEnd (offset);
					startOffset = data.GetTextEditorData ().FindCurrentWordStart (offset);

					expression = editor.GetTextAt (startOffset, endOffset - startOffset);
				}
			}
			
			if (string.IsNullOrEmpty (expression))
				return null;

			var options = DebuggingService.DebuggerSession.EvaluationOptions.Clone ();
			options.AllowMethodEvaluation = true;
			options.AllowTargetInvoke = true;

			var val = frame.GetExpressionValue (expression, options);

			if (val == null || val.IsUnknown || val.IsNotSupported)
				return null;
			
			val.Name = expression;
			
			return new TooltipItem (val, startOffset, expression.Length);
		}
Пример #11
0
 public NRefactoryParameterDataProvider(MonoDevelop.Ide.Gui.TextEditor editor, string delegateName, IType type)
 {
     this.editor       = editor;
     this.delegateName = delegateName;
     if (type != null)
     {
         methods.Add(ExtractInvokeMethod(type));
     }
 }
		public ParameterDataProvider (Document document, ProjectInformation info, string functionName)
		{
			this.editor = document.TextEditor;
			this.functionName = functionName;
			this.info = info;

			functions = new List<Symbol> ();
			Symbol function = info.GetFunction (functionName, document.FileName, editor.CursorLine, editor.CursorColumn);
			if (null != function){ functions.Add (function); }
		}// member function constructor
Пример #13
0
		public TextEditor CreateProjectedEditor (DocumentContext originalContext)
		{
			if (projectedEditor == null) {
				projectedEditor = TextEditorFactory.CreateNewEditor (Document, TextEditorType.Projection);
				projectedDocumentContext = new ProjectedDocumentContext (projectedEditor, originalContext);
				projectedEditor.InitializeExtensionChain (projectedDocumentContext);
				projectedProjections.InstallListener (projectedEditor);
			}
			return projectedEditor;
		}
        public NRefactoryTemplateParameterDataProvider(MonoDevelop.Ide.Gui.TextEditor editor, NRefactoryResolver resolver, IEnumerable <string> namespaces, ExpressionResult expressionResult, DomLocation loc)
        {
            this.editor = editor;
            ResolveResult       plainResolveResult = resolver.Resolve(expressionResult, loc);
            MethodResolveResult resolveResult      = plainResolveResult as MethodResolveResult;

            if (resolveResult != null)
            {
                foreach (IMethod method in resolveResult.Methods)
                {
                    if (method.TypeParameters.Count > 0)
                    {
                        this.types.Add(method);
                    }
                }
            }
            else
            {
                string typeName = expressionResult.Expression.Trim();
                foreach (string ns in namespaces)
                {
                    string prefix = ns + (ns.Length > 0 ? "." : "") + typeName + "`";
                    for (int i = 1; i < 99; i++)
                    {
                        IType possibleType = resolver.Dom.GetType(prefix + i);
                        if (possibleType != null)
                        {
                            this.types.Add(possibleType);
                        }
                    }
                }
                IType resolvedType = plainResolveResult != null?resolver.Dom.GetType(plainResolveResult.ResolvedType) : null;

                if (resolvedType == null)
                {
                    int idx = expressionResult.Expression.LastIndexOf(".");
                    if (idx < 0)
                    {
                        return;
                    }
                    typeName = expressionResult.Expression.Substring(idx + 1);
                    expressionResult.Expression = expressionResult.Expression.Substring(0, idx);
                    plainResolveResult          = resolver.Resolve(expressionResult, loc);
                    resolvedType = resolver.Dom.GetType(plainResolveResult.ResolvedType);
                }
                if (resolvedType == null)
                {
                    return;
                }
                foreach (IType innerType in resolvedType.InnerTypes)
                {
                    this.types.Add(innerType);
                }
            }
        }
		/// <summary>
		/// Could be overwritten to define more complex indenting.
		/// </summary>
		protected virtual int AutoIndentLine (TextEditor d, int lineNumber, string indentString)
		{
			string indentation = lineNumber != 0 ? GetIndentation (d, lineNumber - 1) : "";
			
			if (indentation.Length > 0) {
				string newLineText = indentation + d.GetLineText (lineNumber).Trim ();
				d.ReplaceLine (lineNumber, newLineText);
			}
			
			return indentation.Length;
		}
Пример #16
0
        // used for constructor completion
        public NRefactoryParameterDataProvider(MonoDevelop.Ide.Gui.TextEditor editor, NRefactoryResolver resolver, IType type)
        {
            this.editor = editor;

            if (type != null)
            {
                if (type.ClassType == ClassType.Delegate)
                {
                    IMethod invokeMethod = ExtractInvokeMethod(type);
                    if (type is InstantiatedType)
                    {
                        this.delegateName = ((InstantiatedType)type).UninstantiatedType.Name;
                    }
                    else
                    {
                        this.delegateName = type.Name;
                    }
                    if (invokeMethod != null)
                    {
                        methods.Add(invokeMethod);
                    }
                    else
                    {
                        // no invoke method -> tried to create an abstract delegate
                    }
                    return;
                }
                bool             includeProtected = DomType.IncludeProtected(resolver.Dom, type, resolver.CallingType);
                bool             constructorFound = false;
                HashSet <string> alreadyAdded     = new HashSet <string> ();
                foreach (IMethod method in type.Methods)
                {
                    constructorFound |= method.IsConstructor;
                    string str = ambience.GetString(method, OutputFlags.IncludeParameters);
                    if (alreadyAdded.Contains(str))
                    {
                        continue;
                    }
                    alreadyAdded.Add(str);
                    if ((method.IsConstructor && method.IsAccessibleFrom(resolver.Dom, type, resolver.CallingMember, includeProtected)))
                    {
                        methods.Add(method);
                    }
                }
                // No constructor - generating default
                if (!constructorFound && (type.TypeModifier & TypeModifier.HasOnlyHiddenConstructors) != TypeModifier.HasOnlyHiddenConstructors)
                {
                    DomMethod defaultConstructor = new DomMethod();
                    defaultConstructor.MethodModifier = MethodModifier.IsConstructor;
                    defaultConstructor.DeclaringType  = type;
                    methods.Add(defaultConstructor);
                }
            }
        }
Пример #17
0
		internal async Task Run (TextEditor editor, DocumentContext ctx)
		{
			var cts = new CancellationTokenSource ();
			var getSymbolTask = RefactoringSymbolInfo.GetSymbolInfoAsync (ctx, editor, cts.Token);
			var message = GettextCatalog.GetString ("Resolving symbol…");
			var info = await MessageService.ExecuteTaskAndShowWaitDialog (getSymbolTask, message, cts);
			var sym = info.DeclaredSymbol ?? info.Symbol;
			if (!CanRename (sym))
				return;
			await new RenameRefactoring ().Rename (sym);
		}
		protected internal void Initialize (TextEditor editor, DocumentContext context)
		{
			if (editor == null)
				throw new ArgumentNullException ("editor");
			if (context == null)
				throw new ArgumentNullException ("context");
			if (DocumentContext != null)
				throw new InvalidOperationException ("Extension is already initialized.");
			DocumentContext = context;
			Editor = editor;
			Initialize ();
		}
Пример #19
0
		public TextEditorViewContent (TextEditor textEditor, ITextEditorImpl textEditorImpl)
		{
			if (textEditor == null)
				throw new ArgumentNullException (nameof (textEditor));
			if (textEditorImpl == null)
				throw new ArgumentNullException (nameof (textEditorImpl));
			this.textEditor = textEditor;
			this.textEditorImpl = textEditorImpl;
			this.textEditor.MimeTypeChanged += UpdateTextEditorOptions;
			DefaultSourceEditorOptions.Instance.Changed += UpdateTextEditorOptions;
			this.textEditor.DocumentContextChanged += HandleDocumentContextChanged;
		}
 public NRefactoryTemplateParameterDataProvider(MonoDevelop.Ide.Gui.TextEditor editor, NRefactoryResolver resolver, IEnumerable<string> namespaces, string typeName)
 {
     this.editor = editor;
     foreach (string ns in namespaces) {
         string prefix = ns + (ns.Length > 0 ? "." : "") + typeName + "`";
         for (int i = 1; i < 99; i++) {
             IType possibleType = resolver.Dom.GetType (prefix + i);
             if (possibleType != null)
                 types.Add (possibleType);
         }
     }
 }
		/// <summary>
		/// returns the whitespaces which are before a non white space character in the line
		/// as a string.
		/// </summary>
		protected string GetIndentation (TextEditor d, int lineNumber)
		{
			string lineText = d.GetLineText (lineNumber);
			StringBuilder whitespaces = new StringBuilder ();
			
			foreach (char ch in lineText) {
				if (! Char.IsWhiteSpace (ch))
					break;
				whitespaces.Append (ch);
			}
			
			return whitespaces.ToString ();
		}
		public TextEditorViewContent (TextEditor textEditor, ITextEditorImpl textEditorImpl)
		{
			if (textEditor == null)
				throw new ArgumentNullException (nameof (textEditor));
			if (textEditorImpl == null)
				throw new ArgumentNullException (nameof (textEditorImpl));
			this.textEditor = textEditor;
			this.textEditorImpl = textEditorImpl;
			this.textEditor.MimeTypeChanged += UpdateTextEditorOptions;
			DefaultSourceEditorOptions.Instance.Changed += UpdateTextEditorOptions;
			textEditorImpl.ViewContent.ContentNameChanged += ViewContent_ContentNameChanged;
			textEditorImpl.ViewContent.DirtyChanged += ViewContent_DirtyChanged; ;

		}
        public NRefactoryResolver(ProjectDom dom, ICompilationUnit unit, SupportedLanguage lang, MonoDevelop.Ide.Gui.TextEditor editor, string fileName)
        {
            if (dom == null)
            {
                throw new ArgumentNullException("dom");
            }
            this.unit = unit;

            this.dom                = dom;
            this.lang               = lang;
            this.editor             = editor;
            this.fileName           = fileName;
            this.lookupTableVisitor = new LookupTableVisitor(lang);
        }
		// All line and column numbers are 1-based
		
		public static TextEditor GetTextEditor (IBaseViewContent content)
		{
			IEditableTextBuffer tb = (IEditableTextBuffer) content.GetContent (typeof(IEditableTextBuffer));
			if (tb == null)
				return null;
			
			TextEditor ed = new TextEditor ();
			ed.textBuffer = tb;
			ed.bookmarkBuffer = (IBookmarkBuffer) content.GetContent (typeof(IBookmarkBuffer));
			ed.encodedTextContent = (IEncodedTextContent) content.GetContent (typeof(IEncodedTextContent));
			ed.completionWidget = (ICompletionWidget) content.GetContent (typeof(ICompletionWidget));
			ed.clipboardHandler = (IClipboardHandler) content.GetContent (typeof(IClipboardHandler));
			return ed;
		}
Пример #25
0
		protected override void UndoChange (TextEditor fromEditor, TextEditor toEditor, Hunk hunk)
		{
			base.UndoChange (fromEditor, toEditor, hunk);
			int i = leftConflicts.IndexOf (hunk);
			if (i < 0)
				i = rightConflicts.IndexOf (hunk);
			// no conflicting change
			if (i < 0)
				return;
			currentConflicts.RemoveAt (i);
/*			var startLine = MainEditor.Document.GetLineByOffset (hunk.InsertStart);
			var endline   = MainEditor.Document.GetLineByOffset (hunk.InsertStart + hunk.Inserted);
			
			currentConflicts[i].StartSegment.Offset = startLine.EndOffset;
			currentConflicts[i].EndSegment.Offset = endline.EndOffset;
						 */
			UpdateDiff ();
		}
		}// member function constructor
		
		/// <summary>
		/// Create a ParameterDataProvider for a constructor
		/// </summary>
		/// <param name="constructorOverload">
		/// A <see cref="System.String"/>: The named of the pertinent constructor overload
		/// </param>
		public ParameterDataProvider (Document document, ProjectInformation info, string typename, string constructorOverload)
		{
			this.functionName = constructorOverload;
			this.editor = document.TextEditor;
			this.info = info;
			
			List<Symbol> myfunctions = info.GetConstructorsForType (typename, document.FileName, editor.CursorLine, editor.CursorColumn, null); // bottleneck
			if (1 < myfunctions.Count) {
				foreach (Symbol function in myfunctions) {
					if (functionName.Equals (function.Name, StringComparison.Ordinal)) {
						functions = new List<Symbol> () {function};
						return;
					}
				}
			}
			
			functions = myfunctions;
		}// constructor constructor
Пример #27
0
		public override void Initialize(IPadWindow pad)
		{
			base.Initialize(pad);

			// Init editor
			outputEditor = new TextEditor();
			outputEditor.Events = Gdk.EventMask.AllEventsMask;
			outputEditor.Name = "outputEditor";
			outputEditor.TabsToSpaces = false;
			
			scrolledWindow = new Gtk.ScrolledWindow();
			scrolledWindow.Child = outputEditor;
			scrolledWindow.ShadowType = Gtk.ShadowType.In;
			scrolledWindow.ShowAll();
			outputEditor.ShowAll();

			var o = outputEditor.Options;
			outputEditor.Document.MimeType = Formatting.DCodeFormatter.MimeType;
			o.ShowLineNumberMargin = false;
			o.ShowFoldMargin = false;
			o.ShowIconMargin = false;
			outputEditor.Document.ReadOnly = true;


			// Init toolbar
			var tb = pad.GetToolbar(Gtk.PositionType.Top);

			var ch = new Gtk.ToggleButton();
			ch.Image = new Gtk.Image(Gtk.Stock.Refresh, Gtk.IconSize.Menu);
			ch.Active = EnableCaretTracking;
			ch.TooltipText = "Toggle automatic update after the caret has been moved.";
			ch.Toggled += (object s, EventArgs ea) => EnableCaretTracking = ch.Active;
			tb.Add(ch);

			abortButton = new Gtk.Button();
			abortButton.Sensitive = false;
			abortButton.Image = new Gtk.Image(Gtk.Stock.Stop, Gtk.IconSize.Menu);
			abortButton.TooltipText = "Stops the evaluation.";
			abortButton.Clicked += (object sender, EventArgs e) => AbortExecution();
			tb.Add(abortButton);

			tb.ShowAll();
			Instance = this;
		}
		public NRefactoryParameterDataProvider (MonoDevelop.Ide.Gui.TextEditor editor, NRefactoryResolver resolver, ThisResolveResult resolveResult)
		{
			this.editor = editor;
			HashSet<string> alreadyAdded = new HashSet<string> ();
			if (resolveResult.CallingType != null) {
				bool includeProtected = true;
				foreach (IMethod method in resolveResult.CallingType.Methods) {
					if (!method.IsConstructor)
						continue;
					string str = ambience.GetString (method, OutputFlags.IncludeParameters);
					if (alreadyAdded.Contains (str))
						continue;
					alreadyAdded.Add (str);
					
					if (method.IsAccessibleFrom (resolver.Dom, resolver.CallingType, resolver.CallingMember, includeProtected))
						methods.Add (method);
				}
			}
		}
        public TypeScriptLanguageItemWindow(TextEditor ed, Gdk.ModifierType modifierState, DefinitionInfo result)
        {
            string tooltip = GetTooltopString (result);
            if (string.IsNullOrEmpty (tooltip)|| tooltip == "?") {
                IsEmpty = true;
                return;
            }

            var label = new MonoDevelop.Components.FixedWidthWrapLabel () {
                Wrap = Pango.WrapMode.WordChar,
                Indent = -20,
                BreakOnCamelCasing = true,
                BreakOnPunctuation = true,
                Markup = tooltip,
            };
            this.BorderWidth = 3;
            Add (label);
            UpdateFont (label);

            EnableTransparencyControl = true;
        }
		public ParameterDataProvider (Document document, ProjectInformation info, string functionName)
		{
			this.editor = document.TextEditor;
			
			foreach (Function f in info.Functions) {
				if (f.Name == functionName) {
					functions.Add (f);
				}
			}
			
			string currentFile = document.FileName;
			
			if (info.IncludedFiles.ContainsKey (currentFile)) {
				foreach (CBinding.Parser.FileInformation fi in info.IncludedFiles[currentFile]) {
					foreach (Function f in fi.Functions) {
						if (f.Name == functionName) {
							functions.Add (f);
						}
					}
				}
			}
		}
        public NewOverrideCompletionData(ProjectDom dom, MonoDevelop.Ide.Gui.TextEditor editor, int declarationBegin, IType type, IMember member)
            : base(null)
        {
            this.editor = editor;
            this.type   = type;
            this.member = member;

            this.initialOffset = editor.CursorPosition;
            this.declarationBegin = declarationBegin;
            this.unit = type.CompilationUnit;
            this.GenerateBody = true;
            string declarationText = editor.GetText (declarationBegin, initialOffset);
            insertPrivate = declarationText.Contains ("private");
            insertSealed  = declarationText.Contains ("sealed");

            this.indent = GetIndentString (editor, editor.CursorPosition);
            this.Icon = member.StockIcon;
            this.DisplayText = ambience.GetString (member, OutputFlags.IncludeParameters | OutputFlags.IncludeGenerics | OutputFlags.IncludeMarkup | OutputFlags.HideExtensionsParameter);
            this.CompletionText = member.Name;

            ResolveReturnTypes ();
        }
Пример #32
0
		public ParameterDataProvider (int startOffset, TextEditor editor, ProjectInformation info, string functionName) :base (startOffset)
		{
			this.editor = editor;
			
			foreach (Function f in info.Functions) {
				if (f.Name == functionName) {
					data.Add (new DataWrapper (f));
				}
			}
			
			string currentFile = editor.FileName;
			
			if (info.IncludedFiles.ContainsKey (currentFile)) {
				foreach (CBinding.Parser.FileInformation fi in info.IncludedFiles[currentFile]) {
					foreach (Function f in fi.Functions) {
						if (f.Name == functionName) {
							data.Add (new DataWrapper (f));
						}
					}
				}
			}
		}
        internal static int GetCurrentParameterIndex(MonoDevelop.Ide.Gui.TextEditor editor, int offset, int memberStart)
        {
            int cursor = editor.CursorPosition;
            int i      = offset;

            if (i > cursor)
            {
                return(-1);
            }
            if (i == cursor)
            {
                return(1);
            }

            int index = memberStart + 1;
            int depth = 0;

            do
            {
                char c = editor.GetCharAt(i - 1);

                if (c == ',' && depth == 1)
                {
                    index++;
                }
                if (c == '<')
                {
                    depth++;
                }
                if (c == '>')
                {
                    depth--;
                }
                i++;
            } while (i <= cursor && depth > 0);

            return(depth == 0 ? -1 : index);
        }
		public NRefactoryTemplateParameterDataProvider (MonoDevelop.Ide.Gui.TextEditor editor, NRefactoryResolver resolver, IEnumerable<string> namespaces, ExpressionResult expressionResult, DomLocation loc)
		{
			this.editor = editor;
			ResolveResult plainResolveResult = resolver.Resolve (expressionResult, loc);
			MethodResolveResult resolveResult = plainResolveResult as MethodResolveResult;
			if (resolveResult != null) {
				foreach (IMethod method in resolveResult.Methods) {
					if (method.TypeParameters.Count > 0)
						this.types.Add (method);
				}
			} else {
				string typeName = expressionResult.Expression.Trim ();
				foreach (string ns in namespaces) {
					string prefix = ns + (ns.Length > 0 ? "." : "") + typeName + "`";
					for (int i = 1; i < 99; i++) {
						IType possibleType = resolver.Dom.GetType (prefix + i);
						if (possibleType != null)
							this.types.Add (possibleType);
					}
				}
				IType resolvedType = plainResolveResult != null ? resolver.Dom.GetType (plainResolveResult.ResolvedType) : null;
				if (resolvedType == null) {
					int idx = expressionResult.Expression.LastIndexOf (".");
					if (idx < 0)
						return;
					typeName = expressionResult.Expression.Substring (idx + 1);
					expressionResult.Expression = expressionResult.Expression.Substring (0, idx);
					plainResolveResult = resolver.Resolve (expressionResult, loc);
					resolvedType = resolver.Dom.GetType (plainResolveResult.ResolvedType);
				}
				if (resolvedType == null)
					return;
				foreach (IType innerType in resolvedType.InnerTypes) {
					this.types.Add (innerType);
				}
			}
		}
Пример #35
0
		public DisassemblyView ()
		{
			ContentName = GettextCatalog.GetString ("Disassembly");
			sw = new Gtk.ScrolledWindow ();
			editor = TextEditorFactory.CreateNewEditor ();
			editor.IsReadOnly = true;
			asmMarker = TextMarkerFactory.CreateAsmLineMarker (editor);

			editor.Options = DefaultSourceEditorOptions.PlainEditor;
			
			sw.AddWithViewport (editor);
			sw.HscrollbarPolicy = Gtk.PolicyType.Automatic;
			sw.VscrollbarPolicy = Gtk.PolicyType.Automatic;
			sw.ShowAll ();
			sw.Vadjustment.ValueChanged += OnScrollEditor;
			sw.VScrollbar.ButtonPressEvent += OnPress;
			sw.VScrollbar.ButtonReleaseEvent += OnRelease;
			sw.VScrollbar.Events |= Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask;
			sw.ShadowType = Gtk.ShadowType.In;
			
			sw.Sensitive = false;

			DebuggingService.StoppedEvent += OnStop;
		}
			public ContextActionRunner (CodeAction act, TextEditor editor, DocumentContext documentContext)
			{
				this.editor = editor;
				this.act = act;
				this.documentContext = documentContext;
			}
Пример #37
0
		public AssemblyBrowserWidget ()
		{
			this.Build ();

			buttonBack = new Gtk.Button (ImageService.GetImage ("md-breadcrumb-prev", Gtk.IconSize.Menu));
			buttonBack.Clicked += OnNavigateBackwardActionActivated;

			buttonForeward = new Gtk.Button (ImageService.GetImage ("md-breadcrumb-next", Gtk.IconSize.Menu));
			buttonForeward.Clicked += OnNavigateForwardActionActivated;

			comboboxVisibilty = ComboBox.NewText ();
			comboboxVisibilty.InsertText (0, GettextCatalog.GetString ("Only public members"));
			comboboxVisibilty.InsertText (1, GettextCatalog.GetString ("All members"));
			comboboxVisibilty.Active = 0;
			comboboxVisibilty.Changed += delegate {
				TreeView.PublicApiOnly = comboboxVisibilty.Active == 0;
				FillInspectLabel ();
			};

			searchentry1 = new MonoDevelop.Components.SearchEntry ();
			searchentry1.Ready = true;
			searchentry1.HasFrame = true;
			searchentry1.WidthRequest = 200;
			searchentry1.Visible = true;
			searchentry1.EmptyMessage = GettextCatalog.GetString ("Search for types or members");
			searchentry1.InnerEntry.Changed += SearchEntryhandleChanged;

			CheckMenuItem checkMenuItem = this.searchentry1.AddFilterOption (0, GettextCatalog.GetString ("Types"));
			checkMenuItem.Active = true;
			checkMenuItem.Toggled += delegate {
				if (checkMenuItem.Active) {
					searchMode = AssemblyBrowserWidget.SearchMode.Type;
					CreateColumns ();
					StartSearch ();
				}
			};
			
			CheckMenuItem checkMenuItem1 = this.searchentry1.AddFilterOption (1, GettextCatalog.GetString ("Members"));
			checkMenuItem1.Toggled += delegate {
				if (checkMenuItem1.Active) {
					searchMode = AssemblyBrowserWidget.SearchMode.Member;
					CreateColumns ();
					StartSearch ();
				}
			};

			languageCombobox = Gtk.ComboBox.NewText ();
			//languageCombobox.AppendText (GettextCatalog.GetString ("Summary"));
			languageCombobox.AppendText (GettextCatalog.GetString ("IL"));
			languageCombobox.AppendText (GettextCatalog.GetString ("C#"));
			languageCombobox.Active = Math.Min (1, PropertyService.Get ("AssemblyBrowser.InspectLanguage", 1));
			languageCombobox.Changed += LanguageComboboxhandleChanged;

			loader = new CecilLoader (true);
			loader.IncludeInternalMembers = true;
			TreeView = new AssemblyBrowserTreeView (new NodeBuilder[] { 
				new ErrorNodeBuilder (),
				new ProjectNodeBuilder (this),
				new AssemblyNodeBuilder (this),
				new ModuleReferenceNodeBuilder (),
				new AssemblyReferenceNodeBuilder (this),
				//new AssemblyReferenceFolderNodeBuilder (this),
				new AssemblyResourceFolderNodeBuilder (),
				new ResourceNodeBuilder (),
				new NamespaceBuilder (this),
				new DomTypeNodeBuilder (this),
				new DomMethodNodeBuilder (this),
				new DomFieldNodeBuilder (this),
				new DomEventNodeBuilder (this),
				new DomPropertyNodeBuilder (this),
				new BaseTypeFolderNodeBuilder (this),
				new BaseTypeNodeBuilder (this)
				}, new TreePadOption [0]);
			TreeView.Tree.Selection.Mode = Gtk.SelectionMode.Single;
			TreeView.Tree.CursorChanged += HandleCursorChanged;
			TreeView.ShadowType = ShadowType.None;
			TreeView.BorderWidth = 1;
			TreeView.ShowBorderLine = false;
			TreeView.Zoom = 1.0;
			treeViewPlaceholder.Add (TreeView);

//			this.descriptionLabel.ModifyFont (Pango.FontDescription.FromString ("Sans 9"));
//			this.documentationLabel.ModifyFont (Pango.FontDescription.FromString ("Sans 12"));
//			this.documentationLabel.ModifyBg (Gtk.StateType.Normal, new Gdk.Color (255, 255, 225));
//			this.documentationLabel.Wrap = true;
			
			var options = new MonoDevelop.Ide.Gui.CommonTextEditorOptions () {
				ShowFoldMargin = false,
				ShowIconMargin = false,
				ShowLineNumberMargin = false,
				HighlightCaretLine = true,
			};
			inspectEditor = new TextEditor (new TextDocument (), options);
			inspectEditor.ButtonPressEvent += HandleInspectEditorButtonPressEvent;
			
			this.inspectEditor.Document.ReadOnly = true;
//			this.inspectEditor.Document.SyntaxMode = new Mono.TextEditor.Highlighting.MarkupSyntaxMode ();
			this.inspectEditor.TextViewMargin.GetLink = delegate(Mono.TextEditor.MarginMouseEventArgs arg) {
				var loc = inspectEditor.PointToLocation (arg.X, arg.Y);
				int offset = inspectEditor.LocationToOffset (loc);
				var referencedSegment = ReferencedSegments != null ? ReferencedSegments.FirstOrDefault (seg => seg.Segment.Contains (offset)) : null;
				if (referencedSegment == null)
					return null;
				if (referencedSegment.Reference is TypeDefinition)
					return new XmlDocIdGenerator ().GetXmlDocPath ((TypeDefinition)referencedSegment.Reference);
				
				if (referencedSegment.Reference is MethodDefinition)
					return new XmlDocIdGenerator ().GetXmlDocPath ((MethodDefinition)referencedSegment.Reference);
				
				if (referencedSegment.Reference is PropertyDefinition)
					return new XmlDocIdGenerator ().GetXmlDocPath ((PropertyDefinition)referencedSegment.Reference);
				
				if (referencedSegment.Reference is FieldDefinition)
					return new XmlDocIdGenerator ().GetXmlDocPath ((FieldDefinition)referencedSegment.Reference);
				
				if (referencedSegment.Reference is EventDefinition)
					return new XmlDocIdGenerator ().GetXmlDocPath ((EventDefinition)referencedSegment.Reference);
				
				if (referencedSegment.Reference is FieldDefinition)
					return new XmlDocIdGenerator ().GetXmlDocPath ((FieldDefinition)referencedSegment.Reference);

				if (referencedSegment.Reference is TypeReference) {
					return new XmlDocIdGenerator ().GetXmlDocPath ((TypeReference)referencedSegment.Reference);
				}
				return referencedSegment.Reference.ToString ();
			};
			this.inspectEditor.LinkRequest += InspectEditorhandleLinkRequest;
			documentationScrolledWindow.Add (inspectEditor);

			this.hpaned1.ExposeEvent += HPaneExpose;
			hpaned1 = hpaned1.ReplaceWithWidget (new HPanedThin (), true);
			hpaned1.Position = 271;

			this.notebook1.SetTabLabel (this.documentationScrolledWindow, new Label (GettextCatalog.GetString ("Documentation")));
			this.notebook1.SetTabLabel (this.searchWidget, new Label (GettextCatalog.GetString ("Search")));
			notebook1.Page = 0;
			//this.searchWidget.Visible = false;
				
			typeListStore = new Gtk.ListStore (typeof(Xwt.Drawing.Image), // type image
			                                   typeof(string), // name
			                                   typeof(string), // namespace
			                                   typeof(string), // assembly
				                               typeof(IMember)
			                                  );
			
			memberListStore = new Gtk.ListStore (typeof(Xwt.Drawing.Image), // member image
			                                   typeof(string), // name
			                                   typeof(string), // Declaring type full name
			                                   typeof(string), // assembly
				                               typeof(IMember)
			                                  );
			CreateColumns ();
//			this.searchEntry.Changed += SearchEntryhandleChanged;
			this.searchTreeview.RowActivated += SearchTreeviewhandleRowActivated;
			this.notebook1.ShowTabs = false;
			this.ShowAll ();
		}
Пример #38
0
        internal static int GetCurrentParameterIndex(MonoDevelop.Ide.Gui.TextEditor editor, int offset, int memberStart)
        {
            int cursor = editor.CursorPosition;
            int i      = offset;

            if (i > cursor)
            {
                return(-1);
            }
            if (i == cursor)
            {
                return(1);                // parameters are 1 based
            }
            IEnumerable <string> types  = MonoDevelop.Ide.DesktopService.GetMimeTypeInheritanceChain(CSharpFormatter.MimeType);
            CSharpIndentEngine   engine = new CSharpIndentEngine(MonoDevelop.Projects.Policies.PolicyService.GetDefaultPolicy <CSharpFormattingPolicy> (types));
            int index       = memberStart + 1;
            int parentheses = 0;
            int bracket     = 0;

            do
            {
                char c = editor.GetCharAt(i - 1);
                engine.Push(c);
                switch (c)
                {
                case '{':
                    if (!engine.IsInsideOrdinaryCommentOrString)
                    {
                        bracket++;
                    }
                    break;

                case '}':
                    if (!engine.IsInsideOrdinaryCommentOrString)
                    {
                        bracket--;
                    }
                    break;

                case '(':
                    if (!engine.IsInsideOrdinaryCommentOrString)
                    {
                        parentheses++;
                    }
                    break;

                case ')':
                    if (!engine.IsInsideOrdinaryCommentOrString)
                    {
                        parentheses--;
                    }
                    break;

                case ',':
                    if (!engine.IsInsideOrdinaryCommentOrString && parentheses == 1 && bracket == 0)
                    {
                        index++;
                    }
                    break;
                }
                i++;
            } while (i <= cursor && parentheses >= 0);

            return(parentheses != 1 || bracket > 0 ? -1 : index);
        }
 public NRefactoryResolver(ProjectDom dom, ICompilationUnit unit, MonoDevelop.Ide.Gui.TextEditor editor, string fileName) : this(dom, unit, SupportedLanguage.CSharp, editor, fileName)
 {
 }