public ICompletionSource TryCreateCompletionSource(ITextBuffer textBuffer) { var filename = TemplateProjectionBuffer.GetFilePath(textBuffer); if (filename != null) { var project = DjangoPackage.GetProject(filename); return(new DjangoCompletionSource(_glyphService, project.Analyzer, textBuffer)); } return(null); }
public ProjectBlockCompletionContext(DjangoAnalyzer analyzer, ITextBuffer buffer) : base(analyzer, buffer, TemplateProjectionBuffer.GetFilePath(buffer)) { TemplateProjectionBuffer projBuffer; if (buffer.Properties.TryGetProperty(typeof(TemplateProjectionBuffer), out projBuffer)) { foreach (var span in projBuffer.Spans) { if (span.Block != null) { foreach (var variable in span.Block.GetVariables()) { AddLoopVariable(variable); } } } } }
public int OnLoadCompleted(int fReload) { _cp.Unadvise(_cookie); var adapterService = _compModel.GetService <IVsEditorAdaptersFactoryService>(); ITextBuffer diskBuffer = adapterService.GetDocumentBuffer(_textLines); var contentRegistry = _compModel.GetService <IContentTypeRegistryService>(); var factService = _compModel.GetService <IProjectionBufferFactoryService>(); IContentType contentType = SniffContentType(diskBuffer) ?? contentRegistry.GetContentType("HTML"); var projBuffer = new TemplateProjectionBuffer(contentRegistry, factService, diskBuffer, _compModel.GetService <IBufferGraphFactoryService>(), contentType); diskBuffer.ChangedHighPriority += projBuffer.DiskBufferChanged; diskBuffer.Properties.AddProperty(typeof(TemplateProjectionBuffer), projBuffer); Guid langSvcGuid = typeof(DjangoLanguageInfo).GUID; _textLines.SetLanguageServiceID(ref langSvcGuid); adapterService.SetDataBuffer(_textLines, projBuffer.ProjectionBuffer); IVsTextView view; ErrorHandler.ThrowOnFailure(_window.GetPrimaryView(out view)); if (contentType != null && contentType.IsOfType("HTML")) { var editAdapter = _compModel.GetService <IVsEditorAdaptersFactoryService>(); var newView = editAdapter.GetWpfTextView(view); var intellisenseController = HtmlIntellisenseControllerProvider.GetOrCreateController(_compModel, newView); intellisenseController.AttachKeyboardFilter(); } return(VSConstants.S_OK); }