예제 #1
0
        private void EnableTokenizationOfNewClojureBuffers()
        {
            var componentModel = (IComponentModel)GetService(typeof(SComponentModel));
            TokenizedBufferBuilder      tokenizedBufferBuilder = new TokenizedBufferBuilder(new Tokenizer());
            ITextDocumentFactoryService documentFactoryService = componentModel.GetService <ITextDocumentFactoryService>();

            documentFactoryService.TextDocumentDisposed +=
                (o, e) => tokenizedBufferBuilder.RemoveTokenizedBuffer(e.TextDocument.TextBuffer);

            documentFactoryService.TextDocumentCreated +=
                (o, e) => { if (e.TextDocument.FilePath.EndsWith(".clj"))
                            {
                                tokenizedBufferBuilder.CreateTokenizedBuffer(e.TextDocument.TextBuffer);
                            }
            };
        }
예제 #2
0
        private void EnableTokenizationOfNewClojureBuffers()
        {
            var componentModel = (IComponentModel)GetService(typeof(SComponentModel));
            TokenizedBufferBuilder      tokenizedBufferBuilder = new TokenizedBufferBuilder(new Tokenizer());
            ITextDocumentFactoryService documentFactoryService = componentModel.GetService <ITextDocumentFactoryService>();

            documentFactoryService.TextDocumentDisposed +=
                (o, e) => tokenizedBufferBuilder.RemoveTokenizedBuffer(e.TextDocument.TextBuffer);

            documentFactoryService.TextDocumentCreated +=
                (o, e) =>
            {
                if (e.TextDocument.FilePath.EndsWith(".clj"))
                {
                    tokenizedBufferBuilder.CreateTokenizedBuffer(e.TextDocument.TextBuffer);

                    e.TextDocument.FileActionOccurred += (sender, fileActionEvent) =>
                    {
                        if (fileActionEvent.FileActionType == FileActionTypes.ContentSavedToDisk)
                        {
                            RequestClojureCompile(e.TextDocument);
                        }
                    };
                }
                else if (e.TextDocument.FilePath.EndsWith(".cljs"))
                {
                    tokenizedBufferBuilder.CreateTokenizedBuffer(e.TextDocument.TextBuffer);

                    e.TextDocument.FileActionOccurred += (sender, fileActionEvent) =>
                    {
                        if (fileActionEvent.FileActionType == FileActionTypes.ContentSavedToDisk)
                        {
                            RequestClojureScriptCompile(e.TextDocument);
                        }
                    };
                }
            };
        }