コード例 #1
0
        public NancyMvcViewReference([NotNull] IExpression owner,
                                     [NotNull] ICollection <JetTuple <string, string, MvcUtil.DeterminationKind, ICollection <IClass> > > names,
                                     MvcKind mvcKind, Version version)
            : base(owner, names, mvcKind, version)
        {
            this.names   = names;
            this.mvcKind = mvcKind;
            this.version = version;
            psiServices  = owner.GetPsiServices();
            mvcCache     = psiServices.GetComponent <MvcCache>();

            ResolveFilter = element =>
            {
                var pathDeclaredElement = element as IPathDeclaredElement;
                if (pathDeclaredElement == null || pathDeclaredElement.GetProjectItem() == null)
                {
                    return(false);
                }

                if (pathDeclaredElement.Path.ExistsDirectory)
                {
                    return(false);
                }
                return(true);
            };
        }
コード例 #2
0
        public static ISymbolTable GetReferenceSymbolTableByLocation(IPsiServices psiServices, string name, IProject project)
        {
            var mvcCache    = psiServices.GetComponent <MvcCache>();
            var symbolTable = new SymbolTable(psiServices);

            try
            {
                bool hasExtension = Path.HasExtension(name);

                foreach (string location in mvcCache.GetLocations(project, MvcUtil.GetViewLocationType(MvcKind.View, null)))
                {
                    string path = string.Format(location, name, null, null);
                    if (hasExtension)
                    {
                        path = Path.ChangeExtension(path, null);
                    }
                    symbolTable.AddSymbol(new PathDeclaredElement(psiServices, FileSystemPath.Parse(path)));
                }
            }
            catch (InvalidPathException)
            {
            }

            return(symbolTable.Distinct(PathInfoComparer.Instance));
        }
コード例 #3
0
        public TutorialStepPresenter(IStepView view, string contentPath, Lifetime lifetime, ISolution solution, IPsiFiles psiFiles,
                                     TextControlManager textControlManager, IShellLocks shellLocks, IEditorManager editorManager,
                                     DocumentManager documentManager, IUIApplication environment, IActionManager actionManager,
                                     IPsiServices psiServices, IActionShortcuts shortcutManager)
        {
            _stepView          = view;
            Lifetime           = lifetime;
            Solution           = solution;
            PsiFiles           = psiFiles;
            TextControlManager = textControlManager;
            ShellLocks         = shellLocks;
            EditorManager      = editorManager;
            DocumentManager    = documentManager;
            Environment        = environment;
            ActionManager      = actionManager;
            _contentPath       = contentPath;
            _codeNavigator     = new SourceCodeNavigator(lifetime, solution, psiFiles, textControlManager, shellLocks, editorManager,
                                                         documentManager, environment);
            _steps = new Dictionary <int, TutorialStep>();
            _steps = TutorialXmlReader.ReadTutorialSteps(contentPath);

            _currentStepId = TutorialXmlReader.ReadCurrentStep(contentPath);
            CurrentStep    = _steps[_currentStepId];

            lifetime.AddBracket(
                () => { _stepView.NextStep += GoNext; },
                () => { _stepView.NextStep -= GoNext; });

            ProcessStep();
        }
コード例 #4
0
 public PrefixDeclaredElement(IFile file, string name, IPsiServices services)
 {
     this.myFile     = file;
     this.myName     = name;
     this.myNewName  = name;
     this.myServices = services;
 }
コード例 #5
0
        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);
        }
コード例 #6
0
        public T4FileDependencyManager(Lifetime lifetime, [NotNull] IPsiServices psiServices)
        {
            _psiServices = psiServices;

            psiServices.Files.ObserveBeforeCommit(lifetime, OnBeforeFilesCommit);
            psiServices.Files.ObserveAfterCommit(lifetime, OnAfterFilesCommit);
        }
コード例 #7
0
        public ITypeElement GetTypeElement(IPsiServices psiServices, IClrTypeName clrTypeName)
        {
            var symbolCache = psiServices.Symbols;
            var symbolScope = symbolCache.GetSymbolScope(LibrarySymbolScope.FULL, caseSensitive: false, context: UniversalModuleReferenceContext.Instance);

            return(symbolScope.GetTypeElementByCLRName(clrTypeName));
        }
コード例 #8
0
 private GeneratorDataProvider(
     ISolution solution,
     IProject project,
     IPsiModule psiModule,
     IPsiServices psiServices,
     IPsiSourceFile sourceFile,
     ICSharpFile psiFile,
     ITreeNode selectedElement,
     IDocument document,
     TreeTextRange selectedTreeRange,
     DocumentRange documentSelection,
     ITreeNode tokenAfterCaret,
     ITreeNode tokenBeforeCaret,
     CSharpElementFactory elementFactory)
 {
     this.Solution          = solution;
     this.Project           = project;
     this.PsiModule         = psiModule;
     this.PsiServices       = psiServices;
     this.SourceFile        = sourceFile;
     this.PsiFile           = psiFile;
     this.SelectedElement   = selectedElement;
     this.Document          = document;
     this.SelectedTreeRange = selectedTreeRange;
     this.DocumentSelection = documentSelection;
     this.TokenAfterCaret   = tokenAfterCaret;
     this.TokenBeforeCaret  = tokenBeforeCaret;
     this.ElementFactory    = elementFactory;
 }
コード例 #9
0
 public PrefixDeclaredElement(IFile file, string name, IPsiServices services)
 {
     this.myFile = file;
     this.myName = name;
     this.myNewName = name;
     this.myServices = services;
 }
コード例 #10
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
         )
 {
 }
コード例 #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,
            [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);
        }
コード例 #12
0
            public SolutionStateNotifier([NotNull] Lifetime lifetime,
                                         [NotNull] ISolution solution,
                                         [NotNull] ISolutionLoadTasksScheduler scheduler,
                                         [NotNull] SolutionStateTracker solutionStateTracker,
                                         [NotNull] IPsiServices psiServices)
            {
                if (lifetime == null)
                {
                    throw new ArgumentNullException("lifetime");
                }
                if (solution == null)
                {
                    throw new ArgumentNullException("solution");
                }
                if (scheduler == null)
                {
                    throw new ArgumentNullException("scheduler");
                }
                if (solutionStateTracker == null)
                {
                    throw new ArgumentNullException("solutionStateTracker");
                }

                scheduler.EnqueueTask(new SolutionLoadTask("SolutionStateTracker",
                                                           SolutionLoadTaskKinds.SolutionContainer, () => solutionStateTracker.HandleSolutionContainerCreated(solution)));
                scheduler.EnqueueTask(new SolutionLoadTask("SolutionStateTracker",
                                                           SolutionLoadTaskKinds.Done, () => solutionStateTracker.HandleSolutionOpened(solution)));
                scheduler.EnqueueTask(new SolutionLoadTask("SolutionStateTracker",
                                                           SolutionLoadTaskKinds.AfterDone, () => psiServices.CachesState.IsIdle.WhenTrueOnce(lifetime, () =>
                                                                                                                                              solutionStateTracker.HandlePsiLoaded(solution))));
                lifetime.AddAction(solutionStateTracker.HandleSolutionClosed);
            }
コード例 #13
0
        public TutorialWindowRunner([NotNull] Lifetime lifetime, ISolution solution, IPsiFiles psiFiles,
                                    ChangeManager changeManager, [NotNull] ISolutionStateTracker solutionStateTracker,
                                    [NotNull] GlobalSettings globalSettings, TextControlManager textControlManager, IShellLocks shellLocks,
                                    IEditorManager editorManager, DocumentManager documentManager, IUIApplication environment,
                                    IActionManager actionManager,
                                    WindowsHookManager windowsHookManager, IPsiServices psiServices, IActionShortcuts shortcutManager,
                                    IColorThemeManager colorThemeManager, IThreading threading)
        {
            if (lifetime == null)
            {
                throw new ArgumentNullException("lifetime");
            }
            if (solutionStateTracker == null)
            {
                throw new ArgumentNullException("solutionStateTracker");
            }
            if (globalSettings == null)
            {
                throw new ArgumentNullException("globalSettings");
            }


            foreach (var tutorial in globalSettings.AvailableTutorials)
            {
                if (VsIntegration.GetCurrentSolutionPath() == tutorial.Value)
                {
                    solutionStateTracker.AfterSolutionOpened.Advise(lifetime,
                                                                    () =>
                                                                    RunTutorial(globalSettings, tutorial.Key, lifetime, solution, psiFiles, changeManager,
                                                                                textControlManager, shellLocks, editorManager, documentManager, environment,
                                                                                actionManager, windowsHookManager, psiServices, shortcutManager, colorThemeManager,
                                                                                threading));
                }
            }
        }
コード例 #14
0
        public static void OrginizeUsingsAndFormatFile(ISolution solution, IDocument document)
        {
            IPsiSourceFile sourceFile  = document.GetPsiSourceFile(solution);
            IPsiServices   psiServices = solution.GetPsiServices();

            psiServices.Files.CommitAllDocuments();

            PsiTransactionCookie.ExecuteConditionally(
                psiServices,
                () =>
            {
                if (sourceFile?.GetPsiFile(CSharpLanguage.Instance, new DocumentRange(document, 0)) is ICSharpFile psiFile)
                {
                    SortImports(psiFile);

                    psiFile.OptimizeImportsAndRefs(
                        new RangeMarker(document.ToPointer(), new TextRange(0, document.DocumentRange.Length)),
                        true /* optimizeUsings */,
                        true /* shortenReferences */,
                        NullProgressIndicator.Create()
                        );

                    psiFile.FormatNode();
                }

                return(true);
            },
                "Format T4 Generated File"
                );
        }
コード例 #15
0
 public RoleDeclaredElement(IFile file, string name, IPsiServices services)
 {
     myFile     = file;
     myName     = name;
     myNewName  = name;
     myServices = services;
 }
コード例 #16
0
        public static void FormatFileRangeAndAddUsingDirectives(
            ISolution solution,
            IDocument document,
            TreeTextRange treeTextRange,
            IReadOnlyCollection <IUsingDirective> usingDirectives)
        {
            IPsiSourceFile sourceFile  = document.GetPsiSourceFile(solution);
            IPsiServices   psiServices = solution.GetPsiServices();

            psiServices.Files.CommitAllDocuments();

            PsiTransactionCookie.ExecuteConditionally(
                psiServices,
                () =>
            {
                if (sourceFile?.GetPsiFile(CSharpLanguage.Instance, new DocumentRange(document, 0)) is ICSharpFile psiFile)
                {
                    psiFile.FormatFileRange(treeTextRange);

                    foreach (IUsingDirective usingDirective in usingDirectives)
                    {
                        psiFile.AddImport(usingDirective);
                    }
                }

                return(true);
            },
                "Format T4 Generated File"
                );
        }
コード例 #17
0
        public void Execute(Action <DaemonStageResult> committer)
        {
            IPsiSourceFile sourceFile  = DaemonProcess.SourceFile;
            IPsiServices   psiServices = sourceFile.GetPsiServices();
            ISymbolScope   symbolScope = psiServices.Symbols.GetSymbolScope(LibrarySymbolScope.FULL, false, sourceFile.ResolveContext);

            ITypeElement typeElement = symbolScope.GetTypeElementByCLRName("TestStack.BDDfy.BDDfyExtensions");

            if (typeElement == null)
            {
                return;
            }

            IEnumerable <IMethod> bddfyMethods = typeElement.Methods.Where(method => method.ShortName == "BDDfy" || method.ShortName == "LazyBDDfy");
            ISearchDomain         searchDomain = searchDomainFactory.CreateSearchDomain(sourceFile);

            IReference[] references = bddfyMethods.SelectMany(method => psiServices.Finder.FindReferences(method, searchDomain, NullProgressIndicator.Instance)).ToArray();
            foreach (IReference reference in references)
            {
                var node = reference.GetTreeNode() as ICSharpTreeNode;
                if (node != null)
                {
                    var classDeclaration = node.GetContainingTypeDeclaration() as IClassDeclaration;
                    if (classDeclaration != null)
                    {
                        SetClassAndMembersUsed(classDeclaration);
                    }
                }
            }
        }
コード例 #18
0
        public ITypeElement GetTypeElement(IPsiServices psiServices, IClrTypeName clrTypeName)
        {
            var symbolCache = psiServices.Symbols;
            var symbolScope = symbolCache.GetSymbolScope(LibrarySymbolScope.FULL, caseSensitive: false);

            return(symbolScope.GetTypeElementByCLRName(clrTypeName));
        }
コード例 #19
0
        public TutorialRunner([NotNull] Lifetime lifetime, ISolution solution, IPsiFiles psiFiles,
                              [NotNull] ISolutionStateTracker solutionStateTracker,
                              [NotNull] GlobalSettings globalSettings, TextControlManager textControlManager, IShellLocks shellLocks,
                              IEditorManager editorManager, DocumentManager documentManager, IUIApplication environment,
                              IActionManager actionManager, ToolWindowManager toolWindowManager, TutorialWindowDescriptor tutorialWindowDescriptor,
                              IWindowsHookManager windowsHookManager, IPsiServices psiServices, IActionShortcuts shortcutManager,
                              IColorThemeManager colorThemeManager)
        {
            if (lifetime == null)
            {
                throw new ArgumentNullException("lifetime");
            }
            if (solutionStateTracker == null)
            {
                throw new ArgumentNullException("solutionStateTracker");
            }
            if (globalSettings == null)
            {
                throw new ArgumentNullException("globalSettings");
            }


            foreach (var tutorial in globalSettings.AvailableTutorials)
            {
                if (VsCommunication.GetCurrentSolutionPath() == tutorial.Value)
                {
                    solutionStateTracker.AfterPsiLoaded.Advise(lifetime,
                                                               sol => RunTutorial(globalSettings.GetPath(tutorial.Key, PathType.WorkCopyContentFile), lifetime, solution, psiFiles,
                                                                                  textControlManager, shellLocks, editorManager, documentManager, environment, actionManager, toolWindowManager,
                                                                                  tutorialWindowDescriptor, windowsHookManager, psiServices, shortcutManager, colorThemeManager));
                }
            }
        }
コード例 #20
0
 public RoleDeclaredElement(IFile file, string name, IPsiServices services)
 {
   myFile = file;
   myName = name;
   myNewName = name;
   myServices = services;
 }
 public AngularJsHtmlAttributeDeclaredElement(IPsiServices psiServices, string shortName,
     IHtmlAttributeValueType type, IHtmlTagDeclaredElement tag)
 {
     ShortName = shortName;
     ValueType = type;
     Tag = tag;
     this.psiServices = psiServices;
 }
コード例 #22
0
 public AngularJsHtmlAttributeDeclaredElement(IPsiServices psiServices, string shortName,
                                              IHtmlAttributeValueType type, IHtmlTagDeclaredElement tag)
 {
     ShortName        = shortName;
     ValueType        = type;
     Tag              = tag;
     this.psiServices = psiServices;
 }
コード例 #23
0
 public T4FileDependencyInvalidator(
     Lifetime lifetime,
     [NotNull] IT4FileGraphNotifier notifier,
     [NotNull] IPsiServices services,
     [NotNull] IPsiCachesState state
     ) : base(lifetime, notifier, services, state)
 {
 }
コード例 #24
0
        public override ISymbolTable GetReferenceSymbolTable(bool useReferenceName)
        {
            IPsiServices psiServices = myOwner.GetPsiServices();
            string       name        = GetName();
            IProject     project     = myOwner.GetProject();

            return(NancyReferenceSymbolTableUtil.GetReferenceSymbolTable(psiServices, name, project));
        }
コード例 #25
0
 /// <summary>
 /// Translates changes in generated code-behind file to original file.
 /// </summary>
 /// <param name="psiServices">The PSI services.</param>
 /// <param name="addAction">The action that will add C# statements.</param>
 /// <param name="block">The C# block where the statement will be inserted.</param>
 /// <param name="anchor">The anchor.</param>
 /// <param name="before">Whether to add the statements before of after <paramref name="anchor"/>.</param>
 /// <param name="strict">If true, HTML whitespace statements on bounds are not included. Use for single added statement to be returned.</param>
 /// <returns>An instance of <see cref="ICSharpStatementsRange"/>.</returns>
 public ICSharpStatementsRange HandleAddStatementsRange(IPsiServices psiServices, Func <ITreeNode, ICSharpStatementsRange> addAction, IBlock block, ITreeNode anchor, bool before, bool strict)
 {
     using (CustomGeneratedChangePromotionCookie.Create(block)) {
         ICSharpStatementsRange range = addAction(anchor);
         FinishAddStatementsRange(range.TreeRange, before);
         return(range);
     }
 }
コード例 #26
0
 public AngularJsHtmlTagDeclaredElement(IPsiServices psiServices, HtmlDeclaredElementsCache declaredElementsCache,
     string shortName, IEnumerable<AttributeInfo> ownAttributes, IEnumerable<AttributeInfo> inheritedAttributes)
 {
     ShortName = shortName;
     this.psiServices = psiServices;
     this.declaredElementsCache = declaredElementsCache;
     OwnAttributes = ownAttributes;
     InheritedAttributes = inheritedAttributes;
 }
コード例 #27
0
        public static T DoTransaction <T>(
            [NotNull] this IPsiServices services, [NotNull] string commandName,
            [NotNull, InstantHandle] Func <T> func)
        {
            var value = default(T);

            services.Transactions.Execute(commandName, () => value = func());
            return(value);
        }
コード例 #28
0
 public AngularJsHtmlTagDeclaredElement(IPsiServices psiServices, HtmlDeclaredElementsCache declaredElementsCache,
                                        string shortName, IEnumerable <AttributeInfo> ownAttributes, IEnumerable <AttributeInfo> inheritedAttributes)
 {
     ShortName                  = shortName;
     this.psiServices           = psiServices;
     this.declaredElementsCache = declaredElementsCache;
     OwnAttributes              = ownAttributes;
     InheritedAttributes        = inheritedAttributes;
 }
コード例 #29
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);
        }
コード例 #30
0
 public T4FileDependencyInvalidatorMock(
     Lifetime lifetime,
     [NotNull] IT4FileGraphNotifier notifier,
     [NotNull] IPsiServices services,
     [NotNull] IPsiCachesState state,
     [NotNull] IShellLocks locks
     ) : base(lifetime, notifier, services, state, locks)
 {
 }
コード例 #31
0
        protected ContextActionExecutorBase(ICSharpStatement statement)
        {
            Contract.Requires(statement != null);

            _psiModule = statement.GetPsiModule();
            _psiServices = statement.GetPsiServices();
            _factory = CSharpElementFactory.GetInstance(statement);
            _currentFile = (ICSharpFile)statement.GetContainingFile();
        }
コード例 #32
0
        protected ContextActionExecutorBase(ICSharpStatement statement)
        {
            Contract.Requires(statement != null);

            _psiModule   = statement.GetPsiModule();
            _psiServices = statement.GetPsiServices();
            _factory     = CSharpElementFactory.GetInstance(statement);
            _currentFile = (ICSharpFile)statement.GetContainingFile();
        }
コード例 #33
0
ファイル: NancyUtil.cs プロジェクト: pil0t/Nancy.ReSharper
        private static ISearchDomain GetSearchDomain(IPsiModule module, IModuleReferenceResolveContext context)
        {
            IPsiServices  psiServices  = module.GetPsiServices();
            ISearchDomain searchDomain = psiServices.SearchDomainFactory.CreateSearchDomain(
                module.GetPsiServices().Modules.GetModules()
                .Where(m => m.References(module, context) || module.References(m, context))
                .Prepend(module));

            return(searchDomain);
        }
コード例 #34
0
        public static IReference[] FindReferences([NotNull] this ITreeNode treeNode, [NotNull] IDeclaredElement declaredElement)
        {
            IPsiServices psiServices = treeNode.GetPsiServices();

            return(psiServices.Finder.FindReferences(
                       declaredElement,
                       psiServices.SearchDomainFactory.CreateSearchDomain(treeNode),
                       NullProgressIndicator.Create()
                       ));
        }
コード例 #35
0
        public T4FileDependencyInvalidator(
            Lifetime lifetime,
            [NotNull] IT4FileGraphNotifier notifier,
            [NotNull] IPsiServices services,
            [NotNull] ISolution solution,
            [NotNull] IPsiServices psiServices
            )
        {
            Solution    = solution;
            PsiServices = psiServices;
            services.Files.ObserveAfterCommit(lifetime, () =>
            {
                if (CommitStage == T4CommitStage.DependencyInvalidation)
                {
                    return;
                }
                CommitStage = T4CommitStage.DependencyInvalidation;
                try
                {
                    using (WriteLockCookie.Create())
                    {
                        // Filter just in case a miracle happens and the file gets deleted before being marked as dirty
                        foreach (var file in IndirectDependencies.Where(file => file.IsValid()))
                        {
                            services.Files.MarkAsDirty(file);
                            services.Caches.MarkAsDirty(file);
                        }
                    }

                    IndirectDependencies.Clear();
                    services.Files.CommitAllDocuments();
                }
                finally
                {
                    CommitStage = T4CommitStage.UserChangeApplication;
                }
            });
            notifier.OnFilesIndirectlyAffected += paths =>
            {
                if (CommitStage == T4CommitStage.DependencyInvalidation)
                {
                    return;
                }
                // We want all files that were included before the update
                // and all the files that have become included now
                // to be updated, so we'll mark them as dirty later
                IndirectDependencies.AddRange(paths
                                              .Distinct()
                                              .SelectMany(Solution.FindProjectItemsByLocation)
                                              .OfType <IProjectFile>()
                                              .Select(PsiServices.Modules.GetPsiSourceFilesFor)
                                              .SelectMany(sourceFiles => sourceFiles.AsEnumerable()));
            };
        }
コード例 #36
0
        public static ISymbolTable GetReferenceSymbolTable(IPsiServices psiServices, [CanBeNull] string view, [CanBeNull] IProject project)
        {
            if (project == null || String.IsNullOrEmpty(view))
            {
                return EmptySymbolTable.INSTANCE;
            }

            if (view.IndexOfAny(FileSystemDefinition.InvalidPathChars) != -1 || view == "???")
            {
                return EmptySymbolTable.INSTANCE;
            }

            return GetReferenceSymbolTableByLocation(psiServices, view, project);
        }
コード例 #37
0
        protected ContextActionExecutorBase(ICSharpContextActionDataProvider provider)
        {
            Contract.Requires(provider != null);


            _factory = provider.ElementFactory;

            Contract.Assert(provider.SelectedElement != null,
                "Can't create executor if SelectedElement is null");

            _currentFile = (ICSharpFile)provider.SelectedElement.GetContainingFile();
            _psiServices = provider.PsiServices;
            _psiModule = provider.PsiModule;
        }
コード例 #38
0
ファイル: T4CSharpTypingAssist.cs プロジェクト: MrJul/ForTea
		public T4CSharpTypingAssist(
			Lifetime lifetime,
			ISolution solution,
			ICommandProcessor commandProcessor,
			[NotNull] SkippingTypingAssist skippingTypingAssist,
			CachingLexerService cachingLexerService,
			ISettingsStore settingsStore,
			ITypingAssistManager typingAssistManager,
			IPsiServices psiServices,
			IExternalIntellisenseHost externalIntellisenseHost,
			ISmartDocCommentConfiguration smartDocCommentConfiguration)
			: base(
				lifetime, solution, commandProcessor, skippingTypingAssist, cachingLexerService, settingsStore,
				typingAssistManager, psiServices, externalIntellisenseHost, smartDocCommentConfiguration) {
		}
コード例 #39
0
 public UriIdentifierDeclaredElement(
     IFile file,
     string @namespace,
     string localName,
     IdentifierInfo info,
     IPsiServices services,
     bool filterDeclarations = false,
     IUriIdentifierDeclaredElement parent = null)
 {
     this.myFile = file;
     this.ns = @namespace;
     this.localName = localName;
     this.myName = localName;
     this.myNewName = localName;
     this.myServices = services;
     this.filterDeclarations = filterDeclarations;
     this.parent = parent;
     this.info = info;
 }
コード例 #40
0
        public static ISymbolTable GetReferenceSymbolTableByLocation(IPsiServices psiServices, string name, IProject project)
        {
            var mvcCache = psiServices.GetComponent<MvcCache>();
            var symbolTable = new SymbolTable(psiServices);
            try
            {
                bool hasExtension = Path.HasExtension(name);

                foreach (string location in mvcCache.GetLocations(project, MvcUtil.GetViewLocationType(MvcKind.View, null)))
                {
                    string path = string.Format(location, name, null, null);
                    if (hasExtension)
                    {
                        path = Path.ChangeExtension(path, null);
                    }
                    symbolTable.AddSymbol(new PathDeclaredElement(psiServices, FileSystemPath.Parse(path)));
                }
            }
            catch (InvalidPathException)
            {
            }

            return symbolTable.Distinct(PathInfoComparer.Instance);
        }
 public ITreeRange HandleChangeStatements(IPsiServices psiServices, ITreeRange rangeBeforeChange, Func<ITreeRange> changeAction,
   bool strict)
 {
   return changeAction();
 }
 public void HandleRemoveTypeMember(IPsiServices psiServices, ITreeNode node, Action action)
 {
   action();
 }
 public UnresolvedNamespacePrefixDeclaredElement(IPsiSourceFile file, string name, IPsiServices services)
 {
     this.myFile = file;
     this.myName = name;
     this.myServices = services;
 }
 public void HandleRemoveImport(IPsiServices psiServices, ICSharpTypeAndNamespaceHolderDeclaration scope, IUsingDirective usingDirective, Action action)
 {
   action();
 }
コード例 #45
0
		public T4CSharpTypingAssist(Lifetime lifetime, ISolution solution, ICommandProcessor commandProcessor, CachingLexerService cachingLexerService,
			ISettingsStore settingsStore, ITypingAssistManager typingAssistManager, IPsiServices psiServices, IExternalIntellisenseHost externalIntellisenseHost)
			: base(lifetime, solution, commandProcessor, cachingLexerService, settingsStore, typingAssistManager, psiServices, externalIntellisenseHost) {
		}
コード例 #46
0
		public T4FileDependencyManager([NotNull] Lifetime lifetime, [NotNull] IPsiServices psiServices) {
			_psiServices = psiServices;

			psiServices.Files.ObserveBeforeCommit(lifetime, OnBeforeFilesCommit);
			psiServices.Files.ObserveAfterCommit(lifetime, OnAfterFilesCommit);
		}
 public ITreeNode HandleAddTypeMember(IPsiServices psiServices, Func<ITreeNode> action, IFile generatedFile)
 {
   return action();
 }
コード例 #48
0
 public ITypeElement GetTypeElement(IPsiServices psiServices, IClrTypeName clrTypeName)
 {
     var symbolCache = psiServices.Symbols;
       var symbolScope = symbolCache.GetSymbolScope(LibrarySymbolScope.FULL, caseSensitive: false);
       return symbolScope.GetTypeElementByCLRName(clrTypeName);
 }
コード例 #49
0
 public ITypeElement GetTypeElement(IPsiServices psiServices, IClrTypeName clrTypeName)
 {
     var symbolCache = psiServices.Symbols;
       var symbolScope = symbolCache.GetSymbolScope(LibrarySymbolScope.FULL, caseSensitive: false, context: UniversalModuleReferenceContext.Instance);
       return symbolScope.GetTypeElementByCLRName(clrTypeName);
 }
 public ITreeNode HandleSuperClassChange(IPsiServices psiServices, Func<ITreeNode> action, ITreeNode classDeclaration)
 {
   return action();
 }
 public ITreeNode FixupAnchorForAddingTypeMember(IPsiServices psiServices, IFile generatedFile, ITreeNode anchor, bool willInsertBefore,
                              ITreeNode classDeclaration)
 {
   return anchor;
 }
コード例 #52
0
 public DeclaredElementProvider(IPsiServices psiServices)
 {
     this.psiServices = psiServices;
 }
 public IUsingDirective HandleAddImport(IPsiServices psiServices, Func<IUsingDirective> action, IUsingDirective generatedAnchor, bool before, IFile generatedFile)
 {
   return action();
 }
コード例 #54
0
 /// <summary>
 /// Handles the addition of an import directive
 /// </summary>
 /// <param name="psiServices">The PSI services.</param>
 /// <param name="action">The action to perform to add the directive.</param>
 /// <param name="generatedAnchor">The existing using anchor.</param>
 /// <param name="before">Whether to add the statements before of after <paramref name="generatedAnchor"/>.</param>
 /// <param name="generatedFile">The generated file.</param>
 /// <returns>An instance of <see cref="IUsingDirective"/>.</returns>
 public IUsingDirective HandleAddImport(IPsiServices psiServices, Func<IUsingDirective> action, ITreeNode generatedAnchor, bool before, IFile generatedFile)
 {
     return (IUsingDirective) HandleAddImportInternal(psiServices, action, generatedAnchor, before, CSharpLanguage.Instance, generatedFile);
 }
 public UnresolvedRuleInterfacesDeclaredElement(IPsiSourceFile file, string name, IPsiServices services)
 {
   myFile = file;
   myName = name;
   myServices = services;
 }
 public void HandleChangeExpressionInStatement(IPsiServices psiServices, IStatement statement, Action changeAction)
 {
   changeAction();
 }
 public void HandleRemoveStatementsRange(IPsiServices psiServices, ITreeRange treeRange, Action action)
 {
   action();
 }
 public ICSharpStatementsRange HandleAddStatementsRange(IPsiServices psiServices, Func<ITreeNode, ICSharpStatementsRange> addAction,
   IBlock block, ITreeNode anchor, bool before, bool strict)
 {
   return addAction(anchor);
 }
コード例 #59
0
 public OptionPropertyDeclaredElement(IPsiSourceFile file, string name, IPsiServices services)
 {
   myFile = file;
   myName = name;
   myServices = services;
 }
コード例 #60
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:System.Object" /> class.
 /// </summary>
 /// <param name="psiServices">The psi services.</param>
 /// <param name="owner">The source file.</param>
 /// <param name="itemName">Name of the item.</param>
 public ItemDeclaredElement(IPsiServices psiServices, XmlTagHeaderNode owner, string itemName)
 {
   this.psiServices = psiServices;
   this.owner = owner;
   this.ItemName = itemName;
 }