public ShaderLabTypingAssist(
            Lifetime lifetime,
            [NotNull] ISolution solution,
            [NotNull] IPsiServices psiServices,
            [NotNull] ICommandProcessor commandProcessor,
            [NotNull] ISettingsStore settingsStore,
            [NotNull] InjectedHlslDummyFormatter injectedHlslDummyFormatter,
            [NotNull] RunsProducts.ProductConfigurations productConfigurations,
            [NotNull] CachingLexerService cachingLexerService,
            [NotNull] ITypingAssistManager typingAssistManager,
            [NotNull] IExternalIntellisenseHost externalIntellisenseHost,
            [NotNull] SkippingTypingAssist skippingTypingAssist,
            [NotNull] LastTypingAction lastTypingAssistAction,
            [NotNull] StructuralRemoveManager structuralRemoveManager)
            : base(solution, settingsStore, cachingLexerService, commandProcessor, psiServices,
                   externalIntellisenseHost,
                   skippingTypingAssist, lastTypingAssistAction, structuralRemoveManager)
        {
            myInjectedHlslDummyFormatter = injectedHlslDummyFormatter;
            myCachingLexerService        = cachingLexerService;

            typingAssistManager.AddActionHandler(lifetime, TextControlActions.ActionIds.Enter, this, HandleEnterAction, IsActionHandlerAvailable);
            typingAssistManager.AddActionHandler(lifetime, TextControlActions.ActionIds.Backspace, this, HandleBackspaceAction, IsActionHandlerAvailable);
            typingAssistManager.AddActionHandler(lifetime, TextControlActions.ActionIds.Tab, this, HandleTabPressed,
                                                 IsActionHandlerAvailable);
            typingAssistManager.AddActionHandler(lifetime, TextControlActions.ActionIds.TabLeft, this,
                                                 HandleTabLeftPressed,
                                                 IsActionHandlerAvailable);
        }
Пример #2
0
        private bool OnDollarTyped(ITypingContext context)
        {
            var textControl = context.TextControl;

            if (!IsInAttributeValue(textControl))
            {
                return(false);
            }

            int offset = textControl.GetOffset();

            textControl.Selection.Delete();
            textControl.Document.InsertText(offset, "$");
            textControl.Caret.MoveTo(offset + 1, CaretVisualPlacement.DontScrollIfVisible);
            context.QueueCommand(() =>
            {
                using (CommandProcessor.UsingCommand("Inserting T4 Macro Parenthesis"))
                {
                    textControl.Document.InsertText(offset + 1, "()");
                    textControl.Caret.MoveTo(offset + 2, CaretVisualPlacement.DontScrollIfVisible);
                }

                SkippingTypingAssist.SetCharsToSkip(textControl.Document, "(");
            });
            return(true);
        }
Пример #3
0
        public T4TypingAssist(
            Lifetime lifetime,
            [NotNull] ISolution solution,
            [NotNull] ISettingsStore settingsStore,
            [NotNull] CachingLexerService cachingLexerService,
            [NotNull] ICommandProcessor commandProcessor,
            [NotNull] IPsiServices psiServices,
            [NotNull] IExternalIntellisenseHost externalIntellisenseHost,
            [NotNull] SkippingTypingAssist skippingTypingAssist,
            [NotNull] ITypingAssistManager typingAssistManager,
            [NotNull] ICodeCompletionSessionManager codeCompletionSessionManager,
            [NotNull] LastTypingAction lastTypingAction,
            [NotNull] StructuralRemoveManager structuralRemoveManager
            ) : base(
                solution,
                settingsStore,
                cachingLexerService,
                commandProcessor,
                psiServices,
                externalIntellisenseHost,
                skippingTypingAssist,
                lastTypingAction,
                structuralRemoveManager
                )
        {
            _codeCompletionSessionManager = codeCompletionSessionManager;

            typingAssistManager.AddTypingHandler(lifetime, '=', this, OnEqualTyped, IsTypingSmartParenthesisHandlerAvailable);
            typingAssistManager.AddTypingHandler(lifetime, '"', this, OnQuoteTyped, IsTypingSmartParenthesisHandlerAvailable);
            typingAssistManager.AddTypingHandler(lifetime, '#', this, OnOctothorpeTyped, IsTypingSmartParenthesisHandlerAvailable);
            typingAssistManager.AddTypingHandler(lifetime, '$', this, OnDollarTyped, IsTypingSmartParenthesisHandlerAvailable);
            typingAssistManager.AddTypingHandler(lifetime, '%', this, OnPercentTyped, IsTypingSmartParenthesisHandlerAvailable);
            typingAssistManager.AddActionHandler(lifetime, TextControlActions.ActionIds.Enter, this, OnEnterPressed, IsActionHandlerAvailable);
            typingAssistManager.AddTypingHandler(lifetime, ')', this, OnClosingParenthesisTyped, IsTypingSmartParenthesisHandlerAvailable);
        }
Пример #4
0
 public T4CSharpTypingAssist(
     Lifetime lifetime,
     [NotNull] ISolution solution,
     [NotNull] ICommandProcessor commandProcessor,
     [NotNull] SkippingTypingAssist skippingTypingAssist,
     [NotNull] CachingLexerService cachingLexerService,
     [NotNull] ISettingsStore settingsStore,
     [NotNull] ITypingAssistManager typingAssistManager,
     [NotNull] IPsiServices psiServices,
     [NotNull] IExternalIntellisenseHost externalIntellisenseHost,
     [NotNull] LastTypingAction lastTypingAction,
     [NotNull] StructuralRemoveManager structuralRemoveManager
     ) : base(
         lifetime,
         solution,
         commandProcessor,
         skippingTypingAssist,
         cachingLexerService,
         settingsStore,
         typingAssistManager,
         psiServices,
         externalIntellisenseHost,
         lastTypingAction,
         structuralRemoveManager
         )
 {
 }
Пример #5
0
        public InjectedHlslTypingAssist(
            Lifetime lifetime,
            [NotNull] ISolution solution,
            [NotNull] IPsiServices psiServices,
            [NotNull] ICommandProcessor commandProcessor,
            [NotNull] ISettingsStore settingsStore,
            [NotNull] RunsProducts.ProductConfigurations productConfigurations,
            [NotNull] CachingLexerService cachingLexerService,
            [NotNull] ITypingAssistManager typingAssistManager,
            [NotNull] IExternalIntellisenseHost externalIntellisenseHost,
            [NotNull] SkippingTypingAssist skippingTypingAssist,
            [NotNull] LastTypingAction lastTypingAssistAction,
            [NotNull] InjectedHlslDummyFormatter dummyFormatter,
            [NotNull] StructuralRemoveManager structuralRemoveManager)
            : base(solution, settingsStore, cachingLexerService, commandProcessor, psiServices, externalIntellisenseHost,
                   skippingTypingAssist, lastTypingAssistAction, structuralRemoveManager)
        {
            myCachingLexerService = cachingLexerService;
            myDummyFormatter      = dummyFormatter;
            var braceHandler  = new InjectedHlslBraceHandler(this, dummyFormatter, false, productConfigurations.IsInternalMode());
            var quoteHandler  = new CppQuoteHandler <ShaderLabLanguage>(this);
            var deleteHandler = new CppDeleteHandler <ShaderLabLanguage>(this, dummyFormatter);

            typingAssistManager.AddTypingHandler(lifetime, '{', this, c => ExecuteTypingInCppContextOnly(c, braceHandler.HandleLeftBraceTyped),
                                                 IsTypingHandlerAvailable);
            typingAssistManager.AddTypingHandler(lifetime, '}', this, c => ExecuteTypingInCppContextOnly(c, braceHandler.HandleRightBraceTyped),
                                                 IsTypingHandlerAvailable);
            typingAssistManager.AddTypingHandler(lifetime, '(', this, c => ExecuteTypingInCppContextOnly(c, braceHandler.HandleLeftBracketOrParenthTyped),
                                                 IsTypingSmartParenthesisHandlerAvailable);
            typingAssistManager.AddTypingHandler(lifetime, '<', this, c => ExecuteTypingInCppContextOnly(c, braceHandler.HandleLTTyped),
                                                 IsTypingSmartParenthesisHandlerAvailable);
            typingAssistManager.AddTypingHandler(lifetime, '>', this, c => ExecuteTypingInCppContextOnly(c, braceHandler.HandleRightBracketTyped),
                                                 IsTypingSmartParenthesisHandlerAvailable);
            typingAssistManager.AddTypingHandler(lifetime, '[', this, c => ExecuteTypingInCppContextOnly(c, braceHandler.HandleLeftBracketOrParenthTyped),
                                                 IsTypingSmartParenthesisHandlerAvailable);
            typingAssistManager.AddTypingHandler(lifetime, ']', this, c => ExecuteTypingInCppContextOnly(c, braceHandler.HandleRightBracketTyped),
                                                 IsTypingSmartParenthesisHandlerAvailable);
            typingAssistManager.AddTypingHandler(lifetime, ')', this, c => ExecuteTypingInCppContextOnly(c, braceHandler.HandleRightBracketTyped),
                                                 IsTypingSmartParenthesisHandlerAvailable);
            typingAssistManager.AddTypingHandler(lifetime, '"', this, c => ExecuteTypingInCppContextOnly(c, quoteHandler.HandleQuoteTyped),
                                                 IsTypingSmartParenthesisHandlerAvailable);
            typingAssistManager.AddTypingHandler(lifetime, '\'', this, c => ExecuteTypingInCppContextOnly(c, quoteHandler.HandleQuoteTyped),
                                                 IsTypingSmartParenthesisHandlerAvailable);
            typingAssistManager.AddTypingHandler(lifetime, ';', this, c => ExecuteTypingInCppContextOnly(c, braceHandler.HandleSemicolonTyped),
                                                 IsCorrectCommonTyposAvailable);
            typingAssistManager.AddTypingHandler(lifetime, ':', this, c => ExecuteTypingInCppContextOnly(c, braceHandler.HandleColonTyped),
                                                 IsTypingHandlerAvailable);
            typingAssistManager.AddTypingHandler(lifetime, '*', this, c => ExecuteTypingInCppContextOnly(c, braceHandler.HandleStarTyped),
                                                 IsCorrectCommonTyposAvailable);

            typingAssistManager.AddActionHandler(lifetime, TextControlActions.ActionIds.Backspace, this,
                                                 c => ExecuteActionInCppContextOnly(c, deleteHandler.HandleBackspacePressed), IsActionHandlerAvailable);
            typingAssistManager.AddActionHandler(lifetime, TextControlActions.ActionIds.Enter, this,
                                                 c => ExecuteActionInCppContextOnly(c, braceHandler.HandleEnterTyped), IsActionHandlerAvailable);
            typingAssistManager.AddActionHandler(lifetime, EditorStartNewLineBeforeAction.ACTION_ID, this,
                                                 c => ExecuteActionInCppContextOnly(c, braceHandler.HandleStartNewLineBeforePressed), IsActionHandlerAvailable);
        }
Пример #6
0
        /// <summary>When a " is typed, insert another ".</summary>
        private bool OnQuoteTyped(ITypingContext context)
        {
            ITextControl textControl = context.TextControl;

            // the " character should be skipped to avoid double insertions
            if (SkippingTypingAssist.ShouldSkip(textControl.Document, context.Char))
            {
                SkippingTypingAssist.SkipIfNeeded(textControl.Document, context.Char);
                return(true);
            }

            // get the token type after "
            CachingLexer cachingLexer = GetCachingLexer(textControl);
            int          offset       = textControl.Selection.OneDocRangeWithCaret().GetMinOffset();

            if (cachingLexer == null || offset <= 0 || !cachingLexer.FindTokenAt(offset))
            {
                return(false);
            }

            // there is already another quote after the ", swallow the typing
            TokenNodeType tokenType = cachingLexer.TokenType;

            if (tokenType == T4TokenNodeTypes.Quote)
            {
                textControl.Caret.MoveTo(offset + 1, CaretVisualPlacement.DontScrollIfVisible);
                return(true);
            }

            // we're inside or after an attribute value, simply do nothing and let the " be typed
            if (tokenType == T4TokenNodeTypes.Value)
            {
                return(false);
            }

            // insert the first "
            textControl.Selection.Delete();
            textControl.FillVirtualSpaceUntilCaret();
            textControl.Document.InsertText(offset, "\"");

            // insert the second "
            context.QueueCommand(() => {
                using (CommandProcessor.UsingCommand("Inserting \"")) {
                    textControl.Document.InsertText(offset + 1, "\"");
                    textControl.Caret.MoveTo(offset + 1, CaretVisualPlacement.DontScrollIfVisible);
                }

                // ignore if a subsequent " is typed by the user
                SkippingTypingAssist.SetCharsToSkip(textControl.Document, "\"");

                // popup auto completion
                _codeCompletionSessionManager.ExecuteAutoCompletion <T4AutopopupSettingsKey>(textControl, Solution, key => key.InDirectives);
            });

            return(true);
        }
Пример #7
0
        public T4TypingAssist([NotNull] Lifetime lifetime, [NotNull] ISolution solution, [NotNull] ISettingsStore settingsStore,
                              [NotNull] CachingLexerService cachingLexerService, [NotNull] ICommandProcessor commandProcessor, [NotNull] IPsiServices psiServices,
                              [NotNull] ITypingAssistManager typingAssistManager, [NotNull] SkippingTypingAssist skippingTypingAssist, [NotNull] IntellisenseManager intellisenseManager)
            : base(solution, settingsStore, cachingLexerService, commandProcessor, psiServices)
        {
            _skippingTypingAssist = skippingTypingAssist;
            _intellisenseManager  = intellisenseManager;

            typingAssistManager.AddTypingHandler(lifetime, '=', this, OnEqualTyped, IsTypingSmartParenthesisHandlerAvailable);
            typingAssistManager.AddTypingHandler(lifetime, '"', this, OnQuoteTyped, IsTypingSmartParenthesisHandlerAvailable);
        }
Пример #8
0
 public T4CSharpTypingAssist(
     Lifetime lifetime,
     ISolution solution,
     ICommandProcessor commandProcessor,
     [NotNull] SkippingTypingAssist skippingTypingAssist,
     CachingLexerService cachingLexerService,
     ISettingsStore settingsStore,
     ITypingAssistManager typingAssistManager,
     IPsiServices psiServices,
     IExternalIntellisenseHost externalIntellisenseHost)
     : base(
         lifetime, solution, commandProcessor, skippingTypingAssist, cachingLexerService, settingsStore,
         typingAssistManager, psiServices, externalIntellisenseHost)
 {
 }
Пример #9
0
        /// <summary>When = is typed, insert "".</summary>
        private bool OnEqualTyped(ITypingContext context)
        {
            ITextControl textControl = context.TextControl;

            // get the token type before =
            CachingLexer cachingLexer = GetCachingLexer(textControl);
            int          offset       = textControl.Selection.OneDocRangeWithCaret().GetMinOffset();

            if (cachingLexer == null || offset <= 0 || !cachingLexer.FindTokenAt(offset - 1))
            {
                return(false);
            }

            // do nothing if we're not after an attribute name
            TokenNodeType tokenType = cachingLexer.TokenType;

            if (tokenType != T4TokenNodeTypes.TOKEN)
            {
                return(false);
            }

            // insert =
            textControl.Selection.Delete();
            textControl.FillVirtualSpaceUntilCaret();
            textControl.Document.InsertText(offset, "=");
            textControl.Caret.MoveTo(offset + 1, CaretVisualPlacement.DontScrollIfVisible);

            // insert ""
            context.QueueCommand(() =>
            {
                using (CommandProcessor.UsingCommand("Inserting \"\""))
                {
                    textControl.Document.InsertText(offset + 1, "\"\"");
                    textControl.Caret.MoveTo(offset + 2, CaretVisualPlacement.DontScrollIfVisible);
                }

                // ignore if a subsequent " is typed by the user
                SkippingTypingAssist.SetCharsToSkip(textControl.Document, "\"");

                // popup auto completion
                _codeCompletionSessionManager.ExecuteAutoCompletion <T4AutopopupSettingsKey>(textControl, Solution,
                                                                                             key => key.InDirectives);
            });

            return(true);
        }
Пример #10
0
        private void InsertBlockEnd([NotNull] ITypingContext context)
        {
            var textControl = context.TextControl;
            int offset      = textControl.GetOffset();

            InsertOctothorpe(textControl);
            context.QueueCommand(() =>
            {
                using (CommandProcessor.UsingCommand("Inserting >"))
                {
                    textControl.Document.InsertText(offset + 1, ">");
                    textControl.Caret.MoveTo(offset + 2, CaretVisualPlacement.DontScrollIfVisible);
                }

                SkippingTypingAssist.SetCharsToSkip(textControl.Document, ">");
            });
        }
Пример #11
0
        public T4TypingAssist(
            Lifetime lifetime,
            [NotNull] ISolution solution,
            [NotNull] ISettingsStore settingsStore,
            [NotNull] CachingLexerService cachingLexerService,
            [NotNull] ICommandProcessor commandProcessor,
            [NotNull] IPsiServices psiServices,
            [NotNull] IExternalIntellisenseHost externalIntellisenseHost,
            [NotNull] SkippingTypingAssist skippingTypingAssist,
            [NotNull] ITypingAssistManager typingAssistManager,
            [NotNull] ICodeCompletionSessionManager codeCompletionSessionManager
            )
            : base(solution, settingsStore, cachingLexerService, commandProcessor, psiServices, externalIntellisenseHost, skippingTypingAssist)
        {
            _codeCompletionSessionManager = codeCompletionSessionManager;

            typingAssistManager.AddTypingHandler(lifetime, '=', this, OnEqualTyped, IsTypingSmartParenthesisHandlerAvailable);
            typingAssistManager.AddTypingHandler(lifetime, '"', this, OnQuoteTyped, IsTypingSmartParenthesisHandlerAvailable);
        }
        public InjectedHlslTypingAssist(
            Lifetime lifetime,
            [NotNull] ISolution solution,
            [NotNull] IPsiServices psiServices,
            [NotNull] ICommandProcessor commandProcessor,
            [NotNull] ISettingsStore settingsStore,
            [NotNull] RunsProducts.ProductConfigurations productConfigurations,
            [NotNull] CachingLexerService cachingLexerService,
            [NotNull] ITypingAssistManager typingAssistManager,
            [NotNull] IExternalIntellisenseHost externalIntellisenseHost,
            [NotNull] SkippingTypingAssist skippingTypingAssist,
            [NotNull] LastTypingAssistAction lastTypingAssistAction,
            [NotNull] HlslInShaderLabDummyFormatter inShaderLabDummyFormatter)
            : base(solution, settingsStore, cachingLexerService, commandProcessor, psiServices, externalIntellisenseHost,
                   skippingTypingAssist, lastTypingAssistAction)
        {
            myInShaderLabDummyFormatter = inShaderLabDummyFormatter;
            var braceHandler  = new InjectedHlslBraceHandler(this, inShaderLabDummyFormatter, false, productConfigurations.IsInternalMode());
            var quoteHandler  = new CppQuoteHandler <ShaderLabLanguage>(this);
            var deleteHandler = new CppDeleteHandler <ShaderLabLanguage>(this, inShaderLabDummyFormatter);

            typingAssistManager.AddTypingHandler(lifetime, '{', this, c => WrapCppAction(c, braceHandler.HandleLeftBraceTyped),
                                                 IsTypingHandlerAvailable);
            typingAssistManager.AddTypingHandler(lifetime, '}', this, c => WrapCppAction(c, braceHandler.HandleRightBraceTyped),
                                                 IsTypingHandlerAvailable);
            typingAssistManager.AddTypingHandler(lifetime, '(', this, c => WrapCppAction(c, braceHandler.HandleLeftBracketOrParenthTyped),
                                                 IsTypingSmartParenthesisHandlerAvailable);
            typingAssistManager.AddTypingHandler(lifetime, '<', this, c => WrapCppAction(c, braceHandler.HandleLTTyped),
                                                 IsTypingSmartParenthesisHandlerAvailable);
            typingAssistManager.AddTypingHandler(lifetime, '>', this, c => WrapCppAction(c, braceHandler.HandleRightBracketTyped),
                                                 IsTypingSmartParenthesisHandlerAvailable);
            typingAssistManager.AddTypingHandler(lifetime, '[', this, c => WrapCppAction(c, braceHandler.HandleLeftBracketOrParenthTyped),
                                                 IsTypingSmartParenthesisHandlerAvailable);
            typingAssistManager.AddTypingHandler(lifetime, ']', this, c => WrapCppAction(c, braceHandler.HandleRightBracketTyped),
                                                 IsTypingSmartParenthesisHandlerAvailable);
            typingAssistManager.AddTypingHandler(lifetime, ')', this, c => WrapCppAction(c, braceHandler.HandleRightBracketTyped),
                                                 IsTypingSmartParenthesisHandlerAvailable);
            typingAssistManager.AddTypingHandler(lifetime, '"', this, c => WrapCppAction(c, quoteHandler.HandleQuoteTyped),
                                                 IsTypingSmartParenthesisHandlerAvailable);
            typingAssistManager.AddTypingHandler(lifetime, '\'', this, c => WrapCppAction(c, quoteHandler.HandleQuoteTyped),
                                                 IsTypingSmartParenthesisHandlerAvailable);
            typingAssistManager.AddTypingHandler(lifetime, ';', this, c => WrapCppAction(c, braceHandler.HandleSemicolonTyped),
                                                 IsCorrectCommonTyposAvailable);
            typingAssistManager.AddTypingHandler(lifetime, ':', this, c => WrapCppAction(c, braceHandler.HandleColonTyped),
                                                 IsTypingHandlerAvailable);
            typingAssistManager.AddTypingHandler(lifetime, '*', this, c => WrapCppAction(c, braceHandler.HandleStarTyped),
                                                 IsCorrectCommonTyposAvailable);

            // TODO: # typing should respect ShaderLabIndent
            // typingAssistManager.AddTypingHandler(lifetime, '#', this, c => WrapCppAction(c, braceHandler.HandleSharpTyped),
            //   IsCorrectCommonTyposAvailable);

            typingAssistManager.AddActionHandler(lifetime, TextControlActions.ActionIds.Backspace, this,
                                                 c => WrapAction(c, deleteHandler.HandleBackspacePressed), IsActionHandlerAvailable);
            typingAssistManager.AddActionHandler(lifetime, TextControlActions.ActionIds.Enter, this,
                                                 c => WrapAction(c, braceHandler.HandleEnterTyped), IsActionHandlerAvailable);
            typingAssistManager.AddActionHandler(lifetime, TextControlActions.ActionIds.Tab, this, HandleTabPressed,
                                                 IsActionHandlerAvailable);
            typingAssistManager.AddActionHandler(lifetime, TextControlActions.ActionIds.TabLeft, this, HandleTabLeftPressed,
                                                 IsActionHandlerAvailable);
            typingAssistManager.AddActionHandler(lifetime, EditorStartNewLineBeforeAction.ACTION_ID, this,
                                                 c => WrapAction(c, braceHandler.HandleStartNewLineBeforePressed), IsActionHandlerAvailable);
        }