Exemplo n.º 1
0
        private void RequestCompileShader(SquiggleTagger tagger, string shaderCode, string shaderType, string documentDir)
        {
            if (shaderCompiler is null)
            {
                return;
            }
            //if not currently compiling then compile shader from changed text otherwise add to the "to be compiled" list
            var options = OptionsPagePackage.Options;

            if (!options.LiveCompiling)
            {
                tagger.UpdateErrors(new List <ShaderLogLine>());
                return;
            }
            shaderCompiler.RequestCompile(shaderCode, shaderType, tagger.UpdateErrors, documentDir);
        }
Exemplo n.º 2
0
        public ITagger <T> CreateTagger <T>(ITextView textView, ITextBuffer buffer) where T : ITag
        {
            //Debug.WriteLine($"CreateTagger: textView={textView}, buffer={buffer}");

            // Make sure we are only tagging the top buffer
            if (!ReferenceEquals(buffer, textView.TextBuffer))
            {
                return(null);
            }

            return(buffer.Properties.GetOrCreateSingletonProperty(() =>
            {
                var tagger = new SquiggleTagger(buffer);

                // TODO: Move all this stuff into the SquiggleTagger constructor
                var typeName = buffer.ContentType.TypeName;
                buffer.Changed += (s, e) => RequestCompileShader(tagger, e.After.GetText(), typeName, GetDocumentDir(buffer));    //compile on text change. can be very often!
                RequestCompileShader(tagger, buffer.CurrentSnapshot.GetText(), typeName, GetDocumentDir(buffer));                 //initial compile

                return tagger;
            }) as ITagger <T>);
        }