コード例 #1
0
ファイル: ClojurePackage.cs プロジェクト: daviesian/vsClojure
        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
ファイル: ClojurePackage.cs プロジェクト: rpete4130/vsClojure
		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);
										}
									};
								}
							};
		}