Пример #1
0
        internal static VsProjectAnalyzer GetAnalyzer(this ITextBuffer buffer)
        {
            NodejsProjectNode pyProj;
            VsProjectAnalyzer analyzer;

            if (!buffer.Properties.TryGetProperty <NodejsProjectNode>(typeof(NodejsProjectNode), out pyProj))
            {
                var project = buffer.GetProject();
                if (project != null)
                {
                    pyProj = project.GetNodejsProject();
                    if (pyProj != null)
                    {
                        buffer.Properties.AddProperty(typeof(NodejsProjectNode), pyProj);
                    }
                }
            }

            if (pyProj != null)
            {
                analyzer = pyProj.Analyzer;
                return(analyzer);
            }

            // exists for tests where we don't run in VS and for the existing changes preview
            if (buffer.Properties.TryGetProperty <VsProjectAnalyzer>(typeof(VsProjectAnalyzer), out analyzer))
            {
                return(analyzer);
            }

            if (NodejsPackage.Instance == null)
            {
                // The REPL is open on restart, but our package isn't loaded yet.  Force
                // it to load now.
                var        shell       = (IVsShell)NodejsPackage.GetGlobalService(typeof(SVsShell));
                Guid       packageGuid = typeof(NodejsPackage).GUID;
                IVsPackage package;
                if (ErrorHandler.Failed(shell.LoadPackage(ref packageGuid, out package)))
                {
                    return(null);
                }
                Debug.Assert(NodejsPackage.Instance != null);
            }
            return(NodejsPackage.Instance.DefaultAnalyzer);
        }
Пример #2
0
        public int?GetDesiredIndentation(VisualStudio.Text.ITextSnapshotLine line)
        {
            var dte = (EnvDTE.DTE)NodejsPackage.GetGlobalService(typeof(EnvDTE.DTE));

            var props = dte.get_Properties("TextEditor", "Node.js");

            switch ((EnvDTE._vsIndentStyle)(int) props.Item("IndentStyle").Value)
            {
            case EnvDTE._vsIndentStyle.vsIndentStyleNone:
                return(null);

            case EnvDTE._vsIndentStyle.vsIndentStyleDefault:
                return(DoBlockIndent(line));

            case EnvDTE._vsIndentStyle.vsIndentStyleSmart:
                return(DoSmartIndent(line));
            }

            return(null);
        }
Пример #3
0
        /// <summary>
        /// Opens the find symbols dialog with a list of results.  This is done by requesting
        /// that VS does a search against our library GUID.  Our library then responds to
        /// that request by extracting the prvoided symbol list out and using that for the
        /// search results.
        /// </summary>
        private static void ShowFindSymbolsDialog(ExpressionAnalysis provider, IVsNavInfo symbols) {
            // ensure our library is loaded so find all references will go to our library
            //Package.GetGlobalService(typeof(IPythonLibraryManager));

            if (provider.Expression != String.Empty) {
                var findSym = (IVsFindSymbol)NodejsPackage.GetGlobalService(typeof(SVsObjectSearch));
                VSOBSEARCHCRITERIA2 searchCriteria = new VSOBSEARCHCRITERIA2();
                searchCriteria.eSrchType = VSOBSEARCHTYPE.SO_ENTIREWORD;
                searchCriteria.pIVsNavInfo = symbols;
                searchCriteria.grfOptions = (uint)_VSOBSEARCHOPTIONS2.VSOBSO_LISTREFERENCES;
                searchCriteria.szName = provider.Expression;

                Guid guid = Guid.Empty;
                //  new Guid("{a5a527ea-cf0a-4abf-b501-eafe6b3ba5c6}")
                ErrorHandler.ThrowOnFailure(findSym.DoSearch(new Guid(CommonConstants.LibraryGuid), new VSOBSEARCHCRITERIA2[] { searchCriteria }));
            } else {
                var statusBar = (IVsStatusbar)CommonPackage.GetGlobalService(typeof(SVsStatusbar));
                statusBar.SetText("The caret must be on valid expression to find all references.");
            }
        }