Exemple #1
0
        public int GetLineAndColumn(int iPos, out int piLine, out int piIndex)
        {
            IVsTextLines buffer;

            ErrorHandler.ThrowOnFailure(bufferCoordinator.GetSecondaryBuffer(out buffer));
            return(buffer.GetLineIndexOfPosition(iPos, out piLine, out piIndex));
        }
Exemple #2
0
        public int GetColorizer(out IVsColorizer ppColorizer)
        {
            ppColorizer = null;
            if (null == LanguageService)
            {
                // We should always be able to get the language service.
                return(VSConstants.E_UNEXPECTED);
            }
            IVsTextLines buffer;

            ErrorHandler.ThrowOnFailure(bufferCoordinator.GetSecondaryBuffer(out buffer));
            return(LanguageService.GetColorizer(buffer, out ppColorizer));
        }
        public NemerleContainedLanguage(IVsTextBufferCoordinator bufferCoordinator, NemerleIntellisenseProvider intellisenseProject, uint itemId, IVsHierarchy pHierarchy)
        {
            if (null == bufferCoordinator)
            {
                throw new ArgumentNullException("bufferCoordinator");
            }
            if (null == intellisenseProject)
            {
                throw new ArgumentNullException("intellisenseProject");
            }
            _hierarchy = pHierarchy;

            object projectItem = null;

            pHierarchy.GetProperty(itemId, (int)__VSHPROPID.VSHPROPID_ExtObject, out projectItem);

            _projectItem = projectItem as EnvDTE.ProjectItem;

            EnvDTE.Property prop = _projectItem.Properties.Item("FullPath");
            if (prop != null)
            {
                _filePath = prop.Value as string;
            }

            var project = _projectItem.ContainingProject as NemerleOAProject;

            if (project != null)
            {
                _projectInfo = ((NemerleProjectNode)project.Project).ProjectInfo;
            }

            _typeResolutionService = null;
            DynamicTypeService typeService = LanguageService.GetService(typeof(DynamicTypeService)) as DynamicTypeService;

            if (typeService != null)
            {
                _typeResolutionService = typeService.GetTypeResolutionService(this._hierarchy);
            }

            this.bufferCoordinator   = bufferCoordinator;
            this.intellisenseProject = intellisenseProject;
            this.itemId = itemId;

            // Make sure that the secondary buffer uses the IronPython language service.
            IVsTextLines buffer;

            ErrorHandler.ThrowOnFailure(bufferCoordinator.GetSecondaryBuffer(out buffer));

            Guid languageGuid;

            this.GetLanguageServiceID(out languageGuid);
            ErrorHandler.ThrowOnFailure(buffer.SetLanguageServiceID(ref languageGuid));

            _documentClosingEventHandler = new _dispDocumentEvents_DocumentClosingEventHandler(OnDocumentClosing);
        }
Exemple #4
0
        public ContainedLanguage(
            IVsTextBufferCoordinator bufferCoordinator,
            IComponentModel componentModel,
            TProject project,
            IVsHierarchy hierarchy,
            uint itemid,
            TLanguageService languageService,
            SourceCodeKind sourceCodeKind,
            IFormattingRule vbHelperFormattingRule = null)
            : base(project)
        {
            this.BufferCoordinator = bufferCoordinator;
            this.ComponentModel    = componentModel;
            this.Project           = project;
            _languageService       = languageService;

            this.Workspace = componentModel.GetService <VisualStudioWorkspace>();
            _editorAdaptersFactoryService = componentModel.GetService <IVsEditorAdaptersFactoryService>();

            // Get the ITextBuffer for the secondary buffer
            IVsTextLines secondaryTextLines;

            Marshal.ThrowExceptionForHR(bufferCoordinator.GetSecondaryBuffer(out secondaryTextLines));
            var secondaryVsTextBuffer = (IVsTextBuffer)secondaryTextLines;

            SetSubjectBuffer(_editorAdaptersFactoryService.GetDocumentBuffer(secondaryVsTextBuffer));

            var bufferTagAggregatorFactory = ComponentModel.GetService <IBufferTagAggregatorFactoryService>();

            _bufferTagAggregator = bufferTagAggregatorFactory.CreateTagAggregator <ITag>(SubjectBuffer);

            IVsTextLines primaryTextLines;

            Marshal.ThrowExceptionForHR(bufferCoordinator.GetPrimaryBuffer(out primaryTextLines));
            var primaryVsTextBuffer = (IVsTextBuffer)primaryTextLines;
            var dataBuffer          = (IProjectionBuffer)_editorAdaptersFactoryService.GetDataBuffer(primaryVsTextBuffer);

            SetDataBuffer(dataBuffer);

            this.ContainedDocument = new ContainedDocument(
                this, sourceCodeKind, this.Workspace, hierarchy, itemid, componentModel, vbHelperFormattingRule);

            // TODO: Can contained documents be linked or shared?
            this.Project.AddDocument(this.ContainedDocument, isCurrentContext: true);
        }
Exemple #5
0
        public PythonContainedLanguage(IVsTextBufferCoordinator bufferCoordinator, PythonIntellisenseProvider intellisenseProject, uint itemId)
        {
            if (null == bufferCoordinator)
            {
                throw new ArgumentNullException("bufferCoordinator");
            }
            if (null == intellisenseProject)
            {
                throw new ArgumentNullException("intellisenseProject");
            }
            this.bufferCoordinator   = bufferCoordinator;
            this.intellisenseProject = intellisenseProject;
            this.itemId = itemId;
            // Make sure that the secondary buffer uses the IronPython language service.
            IVsTextLines buffer;

            ErrorHandler.ThrowOnFailure(bufferCoordinator.GetSecondaryBuffer(out buffer));
            Guid languageGuid;

            this.GetLanguageServiceID(out languageGuid);
            ErrorHandler.ThrowOnFailure(buffer.SetLanguageServiceID(ref languageGuid));
        }
 public PythonContainedLanguage(IVsTextBufferCoordinator bufferCoordinator, PythonIntellisenseProvider intellisenseProject, uint itemId)
 {
     if (null == bufferCoordinator) {
         throw new ArgumentNullException("bufferCoordinator");
     }
     if (null == intellisenseProject) {
         throw new ArgumentNullException("intellisenseProject");
     }
     this.bufferCoordinator = bufferCoordinator;
     this.intellisenseProject = intellisenseProject;
     this.itemId = itemId;
     // Make sure that the secondary buffer uses the IronPython language service.
     IVsTextLines buffer;
     ErrorHandler.ThrowOnFailure(bufferCoordinator.GetSecondaryBuffer(out buffer));
     Guid languageGuid;
     this.GetLanguageServiceID(out languageGuid);
     ErrorHandler.ThrowOnFailure(buffer.SetLanguageServiceID(ref languageGuid));
 }
Exemple #7
0
 public int GetBuffer(out IVsTextLines ppBuffer)
 {
     return(_bufferCoordinator.GetSecondaryBuffer(out ppBuffer));
 }
        public NemerleContainedLanguage(IVsTextBufferCoordinator bufferCoordinator, NemerleIntellisenseProvider intellisenseProject, uint itemId, IVsHierarchy pHierarchy)
        {
            if (null == bufferCoordinator)
            {
                throw new ArgumentNullException("bufferCoordinator");
            }
            if (null == intellisenseProject)
            {
                throw new ArgumentNullException("intellisenseProject");
            }
            _hierarchy = pHierarchy;

            object projectItem = null;
            pHierarchy.GetProperty(itemId, (int)__VSHPROPID.VSHPROPID_ExtObject, out projectItem);

            _projectItem = projectItem as EnvDTE.ProjectItem;

            EnvDTE.Property prop = _projectItem.Properties.Item("FullPath");
            if (prop != null)
                _filePath = prop.Value as string;

            var project = _projectItem.ContainingProject as NemerleOAProject;
            if(project != null)
            {
                _projectInfo = ((NemerleProjectNode)project.Project).ProjectInfo;
            }

            _typeResolutionService = null;
            DynamicTypeService typeService = LanguageService.GetService(typeof(DynamicTypeService)) as DynamicTypeService;
            if (typeService != null)
                _typeResolutionService = typeService.GetTypeResolutionService(this._hierarchy);

            this.bufferCoordinator = bufferCoordinator;
            this.intellisenseProject = intellisenseProject;
            this.itemId = itemId;

            // Make sure that the secondary buffer uses the IronPython language service.
            IVsTextLines buffer;
            ErrorHandler.ThrowOnFailure(bufferCoordinator.GetSecondaryBuffer(out buffer));

            Guid languageGuid;
            this.GetLanguageServiceID(out languageGuid);
            ErrorHandler.ThrowOnFailure(buffer.SetLanguageServiceID(ref languageGuid));

            _documentClosingEventHandler = new _dispDocumentEvents_DocumentClosingEventHandler(OnDocumentClosing);
        }