Exemplo n.º 1
0
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            var textView = GetInitializedTextView(textViewAdapter);

            ITextDocument document;

            if (!TextDocumentFactoryService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out document))
            {
                return;
            }

            var saveListeners = Mef.GetAllImports <IFileSaveListener>(document.TextBuffer.ContentType);

            if (saveListeners.Count == 0)
            {
                return;
            }

            EventHandler <TextDocumentFileActionEventArgs> saveHandler = (s, e) =>
            {
                if (e.FileActionType != FileActionTypes.ContentSavedToDisk)
                {
                    return;
                }

                foreach (var listener in saveListeners)
                {
                    listener.FileSaved(document.TextBuffer.ContentType, e.FilePath, false, false);
                }
            };

            document.FileActionOccurred += saveHandler;
            textView.Closed             += delegate { document.FileActionOccurred -= saveHandler; };
        }
Exemplo n.º 2
0
        protected CompilerRunnerBase(IContentType contentType)
        {
            Mef.SatisfyImportsOnce(this);
            SourceContentType = contentType;
            TargetContentType = FileExtensionRegistry.GetContentTypeForExtension(TargetExtension.TrimEnd('.'));

            _listeners = Mef.GetAllImports <IFileSaveListener>(TargetContentType);
            Settings   = WESettings.Instance.ForContentType <ICompilerInvocationSettings>(contentType);
        }
        public TypeScriptCompilationNotifier(ITextDocument doc)
        {
            Document = doc;
            Document.FileActionOccurred += Document_FileActionOccurred;

            _listeners = Mef.GetAllImports <IFileSaveListener>(ContentTypeManager.GetContentType("JavaScript"));

            _watcher        = new FileSystemWatcher(Path.GetDirectoryName(TargetFilePath));
            _watcher.Filter = Path.GetFileName(TargetFilePath);
            _watcher.EnableRaisingEvents = true;
            _watcher.Created            += FileTouched;
            _watcher.Changed            += FileTouched;
        }
Exemplo n.º 4
0
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            var textView = EditorAdaptersFactoryService.GetWpfTextView(textViewAdapter);

            textView.Properties.GetOrCreateSingletonProperty(() => new EncodeSelection(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty(() => new SortSelectedLines(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty(() => new RemoveDuplicateLines(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty(() => new RemoveEmptyLines(textViewAdapter, textView));

            textView.Properties.GetOrCreateSingletonProperty(() => new CommandExceptionFilter(textViewAdapter, textView, UndoRegistry));

            ITextDocument document;

            if (TextDocumentFactoryService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out document))
            {
                var saveListeners = Mef.GetAllImports <IFileSaveListener>(document.TextBuffer.ContentType);
                if (saveListeners.Count > 0)
                {
                    EventHandler <TextDocumentFileActionEventArgs> saveHandler = (s, e) =>
                    {
                        if (e.FileActionType != FileActionTypes.ContentSavedToDisk)
                        {
                            return;
                        }

                        foreach (var listener in saveListeners)
                        {
                            listener.FileSaved(document.TextBuffer.ContentType, e.FilePath, false, false);
                        }
                    };

                    document.FileActionOccurred += saveHandler;
                    textView.Closed             += delegate { document.FileActionOccurred -= saveHandler; };
                }
            }
        }