Example #1
0
#pragma warning restore 649

        #region IClassifierProvider

        /// <summary>
        /// Gets a classifier for the given text buffer.
        /// </summary>
        /// <param name="buffer">The <see cref="ITextBuffer"/> to classify.</param>
        /// <returns>A classifier for the text buffer, or null if the provider cannot do so in its current state.</returns>
        public IClassifier GetClassifier(ITextBuffer buffer)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            Parser.Project project       = null;
            var            bufferAdapter = AdapterFactory.GetBufferAdapter(buffer);
            var            textManager   = ServiceProvider.GetService(typeof(SVsTextManager)) as IVsTextManager;

            IVsEnumTextViews enumerator;

            textManager.EnumViews(bufferAdapter, out enumerator);

            uint count = 0;

            enumerator.GetCount(ref count);
            if (count > 0)
            {
                IVsTextView[] viewarray  = new IVsTextView[count];
                uint          fetchCount = 0;
                if (enumerator.Next(count, viewarray, ref fetchCount) == VSConstants.S_OK)
                {
                    foreach (var view in viewarray)
                    {
                        var viewAdapter = AdapterFactory.GetWpfTextView(view);
                        viewAdapter.Properties.TryGetProperty <Parser.Project>(typeof(Parser.Project), out project);
                        if (project != null)
                        {
                            break;
                        }
                    }
                }
            }

            return(buffer.Properties.GetOrCreateSingletonProperty <EpochClassifier>(creator: () => new EpochClassifier(this.classificationRegistry, project)));
        }
        internal EpochClassifier(IClassificationTypeRegistryService registry, Parser.Project project)
        {
            ParsedProject          = project;
            classificationRegistry = registry;

            TypeKeywords = new HashSet <string>()
            {
                "integer",
                "integer16",
                "integer64",
                "boolean",
                "string",
                "real",
                "buffer",
                "nothing",
                "ref",
                "structure",
                "type",
                "if",
                "elseif",
                "else",
                "while",
                "global",
            };

            LiteralKeywords = new HashSet <string>()
            {
                "true",
                "false"
            };
        }
Example #3
0
 public EpochQuickInfoSource(EpochQuickInfoSourceProvider provider, ITextBuffer subjectBuffer, IVsDebugger debugger, IVsEditorAdaptersFactoryService adapter)
 {
     m_provider      = provider;
     m_subjectBuffer = subjectBuffer;
     m_debugger      = debugger;
     m_adapter       = adapter;
     m_parsedProject = subjectBuffer.Properties.GetProperty <Parser.Project>(typeof(Parser.Project));
 }
Example #4
0
        public EpochCompletionSource(EpochCompletionSourceProvider sourceProvider, ITextBuffer textBuffer, IGlyphService glyphService)
        {
            m_sourceProvider = sourceProvider;
            m_textBuffer     = textBuffer;
            m_glyphService   = glyphService;

            m_parsedProject = textBuffer.Properties.GetProperty <Parser.Project>(typeof(Parser.Project));
        }
 public EpochQuickInfoSource(EpochQuickInfoSourceProvider provider, ITextBuffer subjectBuffer, IVsDebugger debugger, IVsEditorAdaptersFactoryService adapter, ITextBufferFactoryService bufferfactory, IContentTypeRegistryService contentTypes, IClassifierProvider classifierprovider, IGlyphService glyphService)
 {
     m_provider           = provider;
     m_subjectBuffer      = subjectBuffer;
     m_debugger           = debugger;
     m_adapter            = adapter;
     m_parsedProject      = subjectBuffer.Properties.GetProperty <Parser.Project>(typeof(Parser.Project));
     m_bufferFactory      = bufferfactory;
     m_contentTypes       = contentTypes;
     m_classifierProvider = classifierprovider;
     m_glyphService       = glyphService;
 }
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            ITextView textView = AdapterService.GetWpfTextView(textViewAdapter);

            if (textView == null)
            {
                return;
            }

            ThreadHelper.ThrowIfNotOnUIThread();

            Parser.Project parsedproject = null;
            var            buffer        = textView.TextBuffer;

            IVsTextBuffer bufferAdapter;

            buffer.Properties.TryGetProperty(typeof(IVsTextBuffer), out bufferAdapter);

            var persist = (IPersistFileFormat)bufferAdapter;

            if (persist != null)
            {
                string filename    = null;
                uint   formatindex = 0;
                if (persist.GetCurFile(out filename, out formatindex) == VSConstants.S_OK)
                {
                    var doctable  = new RunningDocumentTable(ServiceProvider);
                    var hierarchy = doctable.GetHierarchyItem(filename);
                    if (hierarchy != null)
                    {
                        parsedproject = Parser.ProjectMapper.GetInstance().Map(hierarchy);
                    }
                }
            }

            if (!buffer.Properties.ContainsProperty(typeof(Parser.Project)))
            {
                buffer.Properties.AddProperty(typeof(Parser.Project), parsedproject);
            }


            Func <EpochCompletionCommandHandler> createCommandHandler = delegate()
            {
                return(new EpochCompletionCommandHandler(textViewAdapter, textView, this, SignatureHelpBroker, NavigatorService.GetTextStructureNavigator(textView.TextBuffer)));
            };

            textView.Properties.GetOrCreateSingletonProperty(createCommandHandler);
        }
Example #7
0
 public EpochSignatureHelpSource(ITextBuffer textBuffer, ITextStructureNavigatorSelectorService navigator)
 {
     m_textBuffer    = textBuffer;
     m_navigator     = navigator;
     m_parsedProject = textBuffer.Properties.GetProperty <Parser.Project>(typeof(Parser.Project));
 }