public IWpfTextView CreateTextView(MonoDevelop.Ide.Editor.TextEditor textEditor, ITextViewRoleSet roles = null, IEditorOptions parentOptions = null) { if (textEditor == null) { throw new ArgumentNullException("textEditor"); } if (roles == null) { roles = _defaultRoles; } ITextBuffer textBuffer = textEditor.GetContent <Mono.TextEditor.ITextEditorDataProvider>().GetTextEditorData().Document.TextBuffer; ITextDataModel dataModel = new VacuousTextDataModel(textBuffer); ITextViewModel viewModel = UIExtensionSelector.InvokeBestMatchingFactory (TextViewModelProviders, dataModel.ContentType, roles, (provider) => (provider.CreateTextViewModel(dataModel, roles)), ContentTypeRegistryService, this.GuardedOperations, this) ?? new VacuousTextViewModel(dataModel); TextView view = new TextView(textEditor, viewModel, roles ?? this.DefaultRoles, parentOptions ?? this.EditorOptionsFactoryService.GlobalOptions, this); view.Properties.AddProperty(typeof(MonoDevelop.Ide.Editor.TextEditor), textEditor); this.TextViewCreated?.Invoke(this, new TextViewCreatedEventArgs(view)); return(view); }
public Task <ICompletionDataList> HandlePopupCompletion(MonoDevelop.Ide.Editor.TextEditor editor, DocumentContext context, UnderlyingDocumentInfo docInfo) { CodeCompletionContext ccc; var completion = CreateCompletionAndUpdate(editor, context, docInfo, out ccc); return(completion.HandleCodeCompletionAsync(ccc, CompletionTriggerInfo.CodeCompletionCommand)); }
internal void InsertTemplate(CodeTemplate template, MonoDevelop.Ide.Editor.TextEditor editor, MonoDevelop.Ide.Editor.DocumentContext context) { using (var undo = editor.OpenUndoGroup()) { var result = template.InsertTemplateContents(editor, context); var links = result.TextLinks.Select(l => new Mono.TextEditor.TextLink(l.Name) { Links = l.Links.Select(s => (ISegment) new TextSegment(s.Offset, s.Length)).ToList(), IsEditable = l.IsEditable, IsIdentifier = l.IsIdentifier, GetStringFunc = l.GetStringFunc != null ? (Func <Func <string, string>, Mono.TextEditor.PopupWindow.IListDataProvider <string> >)(arg => new ListDataProviderWrapper(l.GetStringFunc(arg))) : null }).ToList(); var tle = new TextLinkEditMode(this, result.InsertPosition, links); tle.TextLinkMode = TextLinkMode.General; if (tle.ShouldStartTextLinkMode) { tle.OldMode = CurrentMode; tle.StartMode(); CurrentMode = tle; GLib.Timeout.Add(10, delegate { tle.UpdateTextLinks(); return(false); }); } } }
public ITextView CreateTextView(MonoDevelop.Ide.Editor.TextEditor textEditor) { if (textEditor == null) { throw new ArgumentNullException("textEditor"); } var roles = _defaultRoles; ITextBuffer textBuffer = textEditor.GetContent <Mono.TextEditor.ITextEditorDataProvider>().GetTextEditorData().Document.TextBuffer; ITextDataModel dataModel = new VacuousTextDataModel(textBuffer); var providers = TextViewModelProviders .Where(t => allowedTextViewModelProviders.Contains(t.Value.ToString())) .ToArray(); ITextViewModel viewModel = UIExtensionSelector.InvokeBestMatchingFactory (providers, dataModel.ContentType, roles, (provider) => (provider.CreateTextViewModel(dataModel, roles)), ContentTypeRegistryService, this.GuardedOperations, this) ?? new VacuousTextViewModel(dataModel); var view = ((MonoDevelop.SourceEditor.SourceEditorView)textEditor.Implementation).TextEditor; view.Initialize(viewModel, roles, this.EditorOptionsFactoryService.GlobalOptions, this); view.Properties.AddProperty(typeof(MonoDevelop.Ide.Editor.TextEditor), textEditor); this.TextViewCreated?.Invoke(this, new TextViewCreatedEventArgs(view)); return(view); }
// public bool GetParameterCompletionCommandOffset (MonoDevelop.Ide.Editor.TextEditor editor, DocumentContext context, UnderlyingDocumentInfo docInfo, out int cpos) // { // CodeCompletionContext ccc; // var completion = CreateCompletionAndUpdate (editor, context, docInfo, out ccc); // return completion.GetParameterCompletionCommandOffset (out cpos); // } public Task <int> GetCurrentParameterIndex(MonoDevelop.Ide.Editor.TextEditor editor, DocumentContext context, UnderlyingDocumentInfo docInfo, int startOffset) { CodeCompletionContext ccc; var completion = CreateCompletionAndUpdate(editor, context, docInfo, out ccc); return(completion.GetCurrentParameterIndex(startOffset, default(CancellationToken))); }
CSharpCompletionTextEditorExtension CreateCompletionAndUpdate(MonoDevelop.Ide.Editor.TextEditor editor, DocumentContext context, UnderlyingDocumentInfo docInfo, out CodeCompletionContext codeCompletionContext) { var completion = CreateCompletion(editor, context, docInfo, out codeCompletionContext); completion.UpdateParsedDocument(); return(completion); }
public Task <ICompletionDataList> HandleCompletion(MonoDevelop.Ide.Editor.TextEditor editor, DocumentContext context, CodeCompletionContext completionContext, UnderlyingDocumentInfo docInfo, char currentChar, CancellationToken token) { CodeCompletionContext ccc; var completion = CreateCompletionAndUpdate(editor, context, docInfo, out ccc); return(completion.HandleCodeCompletionAsync(completionContext, new CompletionTriggerInfo(CompletionTriggerReason.CharTyped, currentChar), token)); }
public Task <ParameterHintingResult> HandleParameterCompletion(MonoDevelop.Ide.Editor.TextEditor editor, DocumentContext context, CodeCompletionContext completionContext, UnderlyingDocumentInfo docInfo, char completionChar) { CodeCompletionContext ccc; var completion = CreateCompletionAndUpdate(editor, context, docInfo, out ccc); return(completion.HandleParameterCompletionAsync(completionContext, completionChar)); }
public XmlExpandSelectionAnnotation(MonoDevelop.Ide.Editor.TextEditor editor, XmlParser parser) { this.parser = parser; this.editor = editor; document = editor.CreateDocumentSnapshot(); editor.CaretPositionChanged += Editor_CaretPositionChanged; NodePath = GetNodePath(parser, document); }
static XmlExpandSelectionAnnotation GetAnnotation(MonoDevelop.Ide.Editor.TextEditor editor, Func <XmlParser> getTreeParser) { var result = editor.Annotation <XmlExpandSelectionAnnotation> (); if (result == null) { result = new XmlExpandSelectionAnnotation(editor, getTreeParser()); editor.AddAnnotation(result); } return(result); }
public static string CreateSchema(MonoDevelop.Ide.Editor.TextEditor doc, string xml) { using (var dataSet = new System.Data.DataSet()) { dataSet.ReadXml(new StringReader(xml), System.Data.XmlReadMode.InferSchema); using (var writer = new EncodedStringWriter(Encoding.UTF8)) { using (var xmlWriter = CreateXmlTextWriter(doc, writer)) { dataSet.WriteXmlSchema(xmlWriter); return(writer.ToString()); } } } }
public static bool CanExpandSelection(MonoDevelop.Ide.Editor.TextEditor editor) { if (!editor.IsSomethingSelected) { return(true); } if (editor.Selections.Count() == 1) { return(editor.SelectionRange.Offset > 0 || editor.SelectionRange.Length != editor.Length); } return(false); }
protected override void Initialize() { base.Initialize(); defaultCompletionWidget = CompletionWidget; defaultDocumentContext = DocumentContext; defaultEditor = Editor; completionBuilder = RazorCompletionBuilderService.GetBuilder("C#"); // defaultEditor.TextChanging += UnderlyingDocument_TextReplacing; //syntaxMode = new RazorSyntaxMode (Editor, DocumentContext); //var textEditorData = DocumentContext.GetContent<TextEditorData> (); //if (textEditorData != null) // textEditorData.Document.SyntaxMode = syntaxMode; }
internal static void ExpandSelection(MonoDevelop.Ide.Editor.TextEditor editor, Func <XmlParser> getTreeParser) { var selectionAnnotation = GetAnnotation(editor, getTreeParser); if (selectionAnnotation.NodePath.Count == 0) { return; } var newRegion = selectionAnnotation.Grow(); if (newRegion.HasValue) { editor.SetSelection(newRegion.Value.Begin, newRegion.Value.End); } }
CSharpCompletionTextEditorExtension CreateCompletion(MonoDevelop.Ide.Editor.TextEditor editor, DocumentContext context, UnderlyingDocumentInfo docInfo, out CodeCompletionContext codeCompletionContext) { var documentLocation = docInfo.UnderlyingDocument.Editor.OffsetToLocation(docInfo.CaretPosition); codeCompletionContext = new CodeCompletionContext() { TriggerOffset = docInfo.CaretPosition, TriggerLine = documentLocation.Line, TriggerLineOffset = documentLocation.Column - 1 }; return(new CSharpCompletionTextEditorExtension(docInfo.UnderlyingDocument) { CompletionWidget = CreateCompletionWidget(editor, context, docInfo) }); }
/// <summary> /// Creates a XmlTextWriter using the current text editor /// properties for indentation. /// </summary> public static XmlTextWriter CreateXmlTextWriter(MonoDevelop.Ide.Editor.TextEditor doc, TextWriter textWriter) { var xmlWriter = new XmlTextWriter(textWriter) { Formatting = System.Xml.Formatting.Indented }; if (doc.Options.TabsToSpaces) { xmlWriter.Indentation = doc.Options.TabSize; xmlWriter.IndentChar = ' '; } else { xmlWriter.Indentation = 1; xmlWriter.IndentChar = '\t'; } return(xmlWriter); }
internal void InsertTemplate(CodeTemplate template, MonoDevelop.Ide.Editor.TextEditor editor, MonoDevelop.Ide.Editor.DocumentContext context) { using (var undo = editor.OpenUndoGroup()) { var result = template.InsertTemplateContents(editor, context); var links = result.TextLinks.Select(l => new Mono.TextEditor.TextLink(l.Name) { Links = l.Links.Select(s => new TextSegment(s.Offset, s.Length)).ToList(), IsEditable = l.IsEditable, IsIdentifier = l.IsIdentifier }).ToList(); var tle = new TextLinkEditMode(this, result.InsertPosition, links); tle.TextLinkMode = TextLinkMode.General; if (tle.ShouldStartTextLinkMode) { tle.OldMode = CurrentMode; tle.StartMode(); CurrentMode = tle; } } }
static void AddGlobalNamespaceImport(MonoDevelop.Ide.Editor.TextEditor editor, DocumentContext context, string nsName) { var parsedDocument = context.ParsedDocument; var unit = parsedDocument.GetAst <SemanticModel> (); if (unit == null) { return; } int offset = SearchUsingInsertionPoint(unit.SyntaxTree.GetRoot()); var text = new StringBuilder(); text.Append("using "); text.Append(nsName); text.Append(";"); text.Append(editor.EolMarker); editor.InsertText(offset, text.ToString()); }
public RazorCompletionWidget (MonoDevelop.Ide.Editor.TextEditor editor, DocumentContext context, UnderlyingDocumentInfo docInfo) { this.realEditor = editor; this.realDocumentContext = context; this.docInfo = docInfo; }
public TestCompletionWidget (TextEditor editor, DocumentContext document) { this.editor = editor; documentContext = document; }
public TestCompletionExtension(TextEditor editor) { Editor = editor; }
public static bool CanShrinkSelection(MonoDevelop.Ide.Editor.TextEditor editor) { return(editor.IsSomethingSelected && editor.Selections.Count() == 1); }
public ICompletionWidget CreateCompletionWidget(MonoDevelop.Ide.Editor.TextEditor editor, DocumentContext context, UnderlyingDocumentInfo docInfo) { return(new RazorCompletionWidget(editor, context, docInfo)); }
public EmptyCompletionWidget(TextEditor editor) { this.editor = editor; }
public static Task <TooltipInformation> CreateTooltipInformation(CancellationToken ctoken, MonoDevelop.Ide.Editor.TextEditor editor, MonoDevelop.Ide.Editor.DocumentContext ctx, ISymbol entity, bool smartWrap, bool createFooter = false, SemanticModel model = null) { if (entity == null) { return(TaskUtil.Default <TooltipInformation> ()); } var tooltipInfo = new TooltipInformation(); var sig = new SignatureMarkupCreator(ctx, editor != null ? editor.CaretOffset : 0); sig.SemanticModel = model; sig.BreakLineAfterReturnType = smartWrap; return(Task.Run(() => { if (ctoken.IsCancellationRequested) { return null; } try { tooltipInfo.SignatureMarkup = sig.GetMarkup(entity); } catch (Exception e) { LoggingService.LogError("Got exception while creating markup for :" + entity, e); return new TooltipInformation(); } if (ctoken.IsCancellationRequested) { return null; } tooltipInfo.SummaryMarkup = Ambience.GetSummaryMarkup(entity) ?? ""; if (entity is IMethodSymbol) { var method = (IMethodSymbol)entity; if (method.IsExtensionMethod) { tooltipInfo.AddCategory(GettextCatalog.GetString("Extension Method from"), method.ContainingType.Name); } } if (createFooter) { tooltipInfo.FooterMarkup = sig.CreateFooter(entity); } return tooltipInfo; })); }
protected override void Initialize () { base.Initialize (); defaultCompletionWidget = CompletionWidget; defaultDocumentContext = DocumentContext; defaultEditor = Editor; completionBuilder = RazorCompletionBuilderService.GetBuilder ("C#"); defaultEditor.TextChanging += UnderlyingDocument_TextReplacing; syntaxMode = new RazorSyntaxMode (DocumentContext); var textEditorData = DocumentContext.GetContent<TextEditorData> (); if (textEditorData != null) textEditorData.Document.SyntaxMode = syntaxMode; }
public RazorCompletionWidget(MonoDevelop.Ide.Editor.TextEditor editor, DocumentContext context, UnderlyingDocumentInfo docInfo) { this.realEditor = editor; this.realDocumentContext = context; this.docInfo = docInfo; }
public static IGenericTextSegmentMarker CreateGenericTextSegmentMarker(TextEditor editor, TextSegmentMarkerEffect effect, int offset, int length) { return(editor.TextMarkerFactory.CreateGenericTextSegmentMarker(editor, effect, offset, length)); }
public TestCompletionWidget(TextEditor editor, DocumentContext document) { this.editor = editor; documentContext = document; }
public static Task <TooltipInformation> CreateTooltipInformation(CancellationToken ctoken, MonoDevelop.Ide.Editor.TextEditor editor, MonoDevelop.Ide.Editor.DocumentContext ctx, ISymbol entity, bool smartWrap, bool createFooter = false, SemanticModel model = null) { var tooltipInfo = new TooltipInformation(); // if (resolver == null) // resolver = file != null ? file.GetResolver (compilation, textEditorData.Caret.Location) : new CSharpResolver (compilation); var sig = new SignatureMarkupCreator(ctx, editor != null ? editor.CaretOffset : 0); sig.SemanticModel = model; sig.BreakLineAfterReturnType = smartWrap; return(Task.Run(() => { if (ctoken.IsCancellationRequested) { return null; } try { tooltipInfo.SignatureMarkup = sig.GetMarkup(entity); } catch (Exception e) { LoggingService.LogError("Got exception while creating markup for :" + entity, e); return new TooltipInformation(); } if (ctoken.IsCancellationRequested) { return null; } tooltipInfo.SummaryMarkup = Ambience.GetSummaryMarkup(entity) ?? ""; // if (entity is IMember) { // var evt = (IMember)entity; // if (evt.ReturnType.Kind == TypeKind.Delegate) { // tooltipInfo.AddCategory (GettextCatalog.GetString ("Delegate Info"), sig.GetDelegateInfo (evt.ReturnType)); // } // } if (entity is IMethodSymbol) { var method = (IMethodSymbol)entity; if (method.IsExtensionMethod) { tooltipInfo.AddCategory(GettextCatalog.GetString("Extension Method from"), method.ContainingType.Name); } } if (createFooter) { tooltipInfo.FooterMarkup = sig.CreateFooter(entity); } return tooltipInfo; })); }
public CSharpSelectionSurroundingProvider(MonoDevelop.Ide.Editor.TextEditor editor, DocumentContext context) { this.editor = editor; this.context = context; }
public TestCompletionWidget(MonoDevelop.Ide.Editor.TextEditor editor, DocumentContext documentContext) { this.editor = editor; this.documentContext = documentContext; }
public static ITextSegmentMarker CreateLinkMarker(TextEditor editor, int offset, int length, Action <LinkRequest> activateLink) { return(editor.TextMarkerFactory.CreateLinkMarker(editor, offset, length, activateLink)); }