Exemplo n.º 1
0
        public void Attach(ITextEditor editor)
        {
            this.editor       = editor;
            inspectionManager = new IssueManager(editor);
            codeManipulation  = new CodeManipulation(editor);
            renderer          = new CaretReferenceHighlightRenderer(editor);

            // Patch editor options (indentation) to project-specific settings
            if (!editor.ContextActionProviders.IsReadOnly)
            {
                contextActionProviders = AddInTree.BuildItems <IContextActionProvider>("/SharpDevelop/ViewContent/TextEditor/C#/ContextActions", null);
                editor.ContextActionProviders.AddRange(contextActionProviders);
            }

            // Create instance of options adapter and register it as service
            var formattingPolicy = CSharpFormattingPolicies.Instance.GetProjectOptions(
                SD.ProjectService.FindProjectContainingFile(editor.FileName));

            options = new CodeEditorFormattingOptionsAdapter(editor.Options, formattingPolicy.OptionsContainer);
            var textEditor = editor.GetService <TextEditor>();

            if (textEditor != null)
            {
                var textViewServices = textEditor.TextArea.TextView.Services;

                // Unregister any previous ITextEditorOptions instance from editor, if existing, register our impl.
                textViewServices.RemoveService(typeof(ITextEditorOptions));
                textViewServices.AddService(typeof(ITextEditorOptions), options);

                // Set TextEditor's options to same object
                originalEditorOptions = textEditor.Options;
                textEditor.Options    = options;
            }
        }
		public void Attach(ITextEditor editor)
		{
			this.editor = editor;
			inspectionManager = new IssueManager(editor);
			codeManipulation = new CodeManipulation(editor);
			renderer = new CaretReferenceHighlightRenderer(editor);
			
			// Patch editor options (indentation) to project-specific settings
			if (!editor.ContextActionProviders.IsReadOnly) {
				contextActionProviders = AddInTree.BuildItems<IContextActionProvider>("/SharpDevelop/ViewContent/TextEditor/C#/ContextActions", null);
				editor.ContextActionProviders.AddRange(contextActionProviders);
			}
			
			// Create instance of options adapter and register it as service
			var formattingPolicy = CSharpFormattingPolicies.Instance.GetProjectOptions(
				SD.ProjectService.FindProjectContainingFile(editor.FileName));
			options = new CodeEditorFormattingOptionsAdapter(editor.Options, formattingPolicy.OptionsContainer);
			var textEditor = editor.GetService<TextEditor>();
			if (textEditor != null) {
				var textViewServices = textEditor.TextArea.TextView.Services;
				
				// Unregister any previous ITextEditorOptions instance from editor, if existing, register our impl.
				textViewServices.RemoveService(typeof(ITextEditorOptions));
				textViewServices.AddService(typeof(ITextEditorOptions), options);
				
				// Set TextEditor's options to same object
				originalEditorOptions = textEditor.Options;
				textEditor.Options = options;
			}
		}
Exemplo n.º 3
0
		public void Attach(ITextEditor editor)
		{
			this.editor = editor;
			inspectionManager = new IssueManager(editor);
			codeManipulation = new CodeManipulation(editor);
			renderer = new CaretReferenceHighlightRenderer(editor);
			
			if (!editor.ContextActionProviders.IsReadOnly) {
				contextActionProviders = AddInTree.BuildItems<IContextActionProvider>("/SharpDevelop/ViewContent/TextEditor/C#/ContextActions", null);
				editor.ContextActionProviders.AddRange(contextActionProviders);
			}
		}
        public void Attach(ITextEditor editor)
        {
            this.editor       = editor;
            inspectionManager = new IssueManager(editor);
            codeManipulation  = new CodeManipulation(editor);
            renderer          = new CaretReferenceHighlightRenderer(editor);

            if (!editor.ContextActionProviders.IsReadOnly)
            {
                contextActionProviders = AddInTree.BuildItems <IContextActionProvider>("/SharpDevelop/ViewContent/TextEditor/C#/ContextActions", null);
                editor.ContextActionProviders.AddRange(contextActionProviders);
            }
        }