Пример #1
0
        public int GetMemberNavigationPoint(string pszClassName, string pszUniqueMemberID, TextSpan[] pSpanNavPoint, out uint pItemID)
        {
            uint     itemId    = 0;
            TextSpan textSpan  = default(TextSpan);
            var      succeeded = false;

            var waitIndicator = this.ComponentModel.GetService <IWaitIndicator>();

            waitIndicator.Wait(
                "Intellisense",
                allowCancel: false,
                action: c =>
            {
                Document targetDocument;
                if (ContainedLanguageCodeSupport.TryGetMemberNavigationPoint(GetThisDocument(), pszClassName, pszUniqueMemberID, out textSpan, out targetDocument, c.CancellationToken))
                {
                    succeeded = true;
                    itemId    = this.ContainedDocument.FindItemIdOfDocument(targetDocument);
                }
            });

            pItemID          = itemId;
            pSpanNavPoint[0] = textSpan;
            return(succeeded ? VSConstants.S_OK : VSConstants.E_FAIL);
        }
        public int GetCompatibleEventHandlers(
            string pszClassName,
            string pszObjectTypeName,
            string pszNameOfEvent,
            out int pcMembers,
            IntPtr ppbstrEventHandlerNames,
            IntPtr ppbstrMemberIDs)
        {
            IEnumerable <Tuple <string, string> > membersAndIds = null;

            var uiThreadOperationExecutor = ComponentModel.GetService <IUIThreadOperationExecutor>();

            uiThreadOperationExecutor.Execute(
                "Intellisense",
                defaultDescription: "",
                allowCancellation: false,
                showProgress: false,
                action: c => membersAndIds = ContainedLanguageCodeSupport.GetCompatibleEventHandlers(GetThisDocument(), pszClassName, pszObjectTypeName, pszNameOfEvent, c.UserCancellationToken));

            pcMembers = membersAndIds.Count();
            CreateBSTRArray(ppbstrEventHandlerNames, membersAndIds.Select(t => t.Item1));
            CreateBSTRArray(ppbstrMemberIDs, membersAndIds.Select(t => t.Item2));

            return(VSConstants.S_OK);
        }
Пример #3
0
        public int OnRenamed(ContainedLanguageRenameType clrt, string bstrOldID, string bstrNewID)
        {
            int result = 0;

            var waitIndicator = this.ComponentModel.GetService <IWaitIndicator>();

            waitIndicator.Wait(
                "Intellisense",
                allowCancel: false,
                action: c =>
            {
                var refactorNotifyServices = this.ComponentModel.DefaultExportProvider.GetExportedValues <IRefactorNotifyService>();

                if (!ContainedLanguageCodeSupport.TryRenameElement(GetThisDocument(), clrt, bstrOldID, bstrNewID, refactorNotifyServices, c.CancellationToken))
                {
                    result = s_CONTAINEDLANGUAGE_CANNOTFINDITEM;
                }
                else
                {
                    result = VSConstants.S_OK;
                }
            });

            return(result);
        }
Пример #4
0
        public int CreateUniqueEventName(
            string pszClassName,
            string pszObjectName,
            string pszNameOfEvent,
            out string pbstrEventHandlerName
            )
        {
            string result = null;

            var waitIndicator = ComponentModel.GetService <IWaitIndicator>();

            waitIndicator.Wait(
                "Intellisense",
                allowCancel: false,
                action: c =>
                result = ContainedLanguageCodeSupport.CreateUniqueEventName(
                    GetThisDocument(),
                    pszClassName,
                    pszObjectName,
                    pszNameOfEvent,
                    c.CancellationToken
                    )
                );

            pbstrEventHandlerName = result;
            return(VSConstants.S_OK);
        }
Пример #5
0
        public int GetEventHandlerMemberID(
            string pszClassName,
            string pszObjectTypeName,
            string pszNameOfEvent,
            string pszEventHandlerName,
            out string pbstrUniqueMemberID
            )
        {
            string memberId = null;

            var waitIndicator = this.ComponentModel.GetService <IWaitIndicator>();

            waitIndicator.Wait(
                "Intellisense",
                allowCancel: false,
                action: c =>
                memberId = ContainedLanguageCodeSupport.GetEventHandlerMemberId(
                    GetThisDocument(),
                    pszClassName,
                    pszObjectTypeName,
                    pszNameOfEvent,
                    pszEventHandlerName,
                    c.CancellationToken
                    )
                );

            pbstrUniqueMemberID = memberId;
            return(pbstrUniqueMemberID == null ? VSConstants.S_FALSE : VSConstants.S_OK);
        }
Пример #6
0
        public int GetCompatibleEventHandlers(
            string pszClassName,
            string pszObjectTypeName,
            string pszNameOfEvent,
            out int pcMembers,
            IntPtr ppbstrEventHandlerNames,
            IntPtr ppbstrMemberIDs
            )
        {
            IEnumerable <Tuple <string, string> > membersAndIds = null;

            var waitIndicator = this.ComponentModel.GetService <IWaitIndicator>();

            waitIndicator.Wait(
                "Intellisense",
                allowCancel: false,
                action: c =>
                membersAndIds = ContainedLanguageCodeSupport.GetCompatibleEventHandlers(
                    GetThisDocument(),
                    pszClassName,
                    pszObjectTypeName,
                    pszNameOfEvent,
                    c.CancellationToken
                    )
                );

            pcMembers = membersAndIds.Count();
            CreateBSTRArray(ppbstrEventHandlerNames, membersAndIds.Select(t => t.Item1));
            CreateBSTRArray(ppbstrMemberIDs, membersAndIds.Select(t => t.Item2));

            return(VSConstants.S_OK);
        }
Пример #7
0
        public int EnsureEventHandler(
            string pszClassName,
            string pszObjectTypeName,
            string pszNameOfEvent,
            string pszEventHandlerName,
            uint itemidInsertionPoint,
            out string pbstrUniqueMemberID,
            out string pbstrEventBody,
            TextSpan[] pSpanInsertionPoint
            )
        {
            var thisDocument     = GetThisDocument();
            var targetDocumentId = this.ContainedDocument.FindProjectDocumentIdWithItemId(
                itemidInsertionPoint
                );
            var targetDocument = thisDocument.Project.Solution.GetDocument(targetDocumentId);

            if (targetDocument == null)
            {
                // Can't generate into this itemid
                pbstrUniqueMemberID = null;
                pbstrEventBody      = null;
                return(VSConstants.E_FAIL);
            }

            Tuple <string, string, TextSpan> idBodyAndInsertionPoint = null;
            var waitIndicator = ComponentModel.GetService <IWaitIndicator>();

            waitIndicator.Wait(
                "Intellisense",
                allowCancel: false,
                action: c =>
                idBodyAndInsertionPoint = ContainedLanguageCodeSupport.EnsureEventHandler(
                    thisDocument,
                    targetDocument,
                    pszClassName,
                    null     /*objectName*/
                    ,
                    pszObjectTypeName,
                    pszNameOfEvent,
                    pszEventHandlerName,
                    itemidInsertionPoint,
                    useHandlesClause: false,
                    additionalFormattingRule: targetDocument.Project.LanguageServices
                    .GetService <IAdditionalFormattingRuleLanguageService>()
                    .GetAdditionalCodeGenerationRule(),
                    cancellationToken: c.CancellationToken
                    )
                );

            pbstrUniqueMemberID    = idBodyAndInsertionPoint.Item1;
            pbstrEventBody         = idBodyAndInsertionPoint.Item2;
            pSpanInsertionPoint[0] = idBodyAndInsertionPoint.Item3;
            return(VSConstants.S_OK);
        }
        public int GetBaseClassName(string pszClassName, out string pbstrBaseClassName)
        {
            var    result        = false;
            var    waitIndicator = this.ComponentModel.GetService <IWaitIndicator>();
            string baseClassName = null;

            waitIndicator.Wait(
                "Intellisense",
                allowCancel: false,
                action: c => result = ContainedLanguageCodeSupport.TryGetBaseClassName(GetThisDocument(), pszClassName, c.CancellationToken, out baseClassName));

            pbstrBaseClassName = baseClassName;
            return(result ? VSConstants.S_OK : VSConstants.E_FAIL);
        }
        public int GetBaseClassName(string pszClassName, out string pbstrBaseClassName)
        {
            var    result                    = false;
            string baseClassName             = null;
            var    uiThreadOperationExecutor = ComponentModel.GetService <IUIThreadOperationExecutor>();

            uiThreadOperationExecutor.Execute(
                "Intellisense",
                defaultDescription: "",
                allowCancellation: false,
                showProgress: false,
                action: c => result = ContainedLanguageCodeSupport.TryGetBaseClassName(GetThisDocument(), pszClassName, c.UserCancellationToken, out baseClassName));

            pbstrBaseClassName = baseClassName;
            return(result ? VSConstants.S_OK : VSConstants.E_FAIL);
        }
        public int GetEventHandlerMemberID(string pszClassName, string pszObjectTypeName, string pszNameOfEvent, string pszEventHandlerName, out string pbstrUniqueMemberID)
        {
            string memberId = null;

            var uiThreadOperationExecutor = ComponentModel.GetService <IUIThreadOperationExecutor>();

            uiThreadOperationExecutor.Execute(
                "Intellisense",
                defaultDescription: "",
                allowCancellation: false,
                showProgress: false,
                action: c => memberId = ContainedLanguageCodeSupport.GetEventHandlerMemberId(GetThisDocument(), pszClassName, pszObjectTypeName, pszNameOfEvent, pszEventHandlerName, c.UserCancellationToken));

            pbstrUniqueMemberID = memberId;
            return(pbstrUniqueMemberID == null ? VSConstants.S_FALSE : VSConstants.S_OK);
        }
        public int CreateUniqueEventName(string pszClassName, string pszObjectName, string pszNameOfEvent, out string pbstrEventHandlerName)
        {
            string result = null;

            var uiThreadOperationExecutor = ComponentModel.GetService <IUIThreadOperationExecutor>();

            uiThreadOperationExecutor.Execute(
                "Intellisense",
                defaultDescription: "",
                allowCancellation: false,
                showProgress: false,
                action: c =>
                result = ContainedLanguageCodeSupport.CreateUniqueEventName(GetThisDocument(), GlobalOptions, pszClassName, pszObjectName, pszNameOfEvent, c.UserCancellationToken));

            pbstrEventHandlerName = result;
            return(VSConstants.S_OK);
        }
        public int GetMemberNavigationPoint(string pszClassName, string pszUniqueMemberID, TextSpan[] pSpanNavPoint, out uint pItemID)
        {
            uint     itemId    = 0;
            TextSpan textSpan  = default;
            var      succeeded = false;

            var uiThreadOperationExecutor = ComponentModel.GetService <IUIThreadOperationExecutor>();

            uiThreadOperationExecutor.Execute(
                "Intellisense",
                defaultDescription: "",
                allowCancellation: false,
                showProgress: false,
                action: c =>
            {
                if (ContainedLanguageCodeSupport.TryGetMemberNavigationPoint(GetThisDocument(), GlobalOptions, pszClassName, pszUniqueMemberID, out textSpan, out var targetDocument, c.UserCancellationToken))
                {
                    succeeded = true;
                    itemId    = this.ContainedDocument.FindItemIdOfDocument(targetDocument);
                }
            });
Пример #13
0
 public int IsValidID(string bstrID, out bool pfIsValidID)
 {
     pfIsValidID = ContainedLanguageCodeSupport.IsValidId(GetThisDocument(), bstrID);
     return(VSConstants.S_OK);
 }