/// <summary> /// Do the initialization here (such as loading flavor specific /// information from the project) /// </summary> protected override void InitializeForOuter(string fileName, string location, string name, uint flags, ref Guid guidProject, out bool cancel) { base.InitializeForOuter(fileName, location, name, flags, ref guidProject, out cancel); // register the open command with the menu service provided by the base class. We can't just handle this // internally because we kick off the context menu, pass ourselves as the IOleCommandTarget, and then our // base implementation dispatches via the menu service. So we could either have a different IOleCommandTarget // which handles the Open command programmatically, or we can register it with the menu service. CommandID menuCommandID = new CommandID(VSConstants.GUID_VSStandardCommandSet97, (int)VSConstants.VSStd97CmdID.Open); OleMenuCommand menuItem = new OleMenuCommand(OpenFile, null, OpenFileBeforeQueryStatus, menuCommandID); AddCommand(menuItem); menuCommandID = new CommandID(VSConstants.GUID_VSStandardCommandSet97, (int)VSConstants.VSStd97CmdID.ViewCode); menuItem = new OleMenuCommand(OpenFile, null, OpenFileBeforeQueryStatus, menuCommandID); AddCommand(menuItem); menuCommandID = new CommandID(VSConstants.VSStd2K, (int)VSConstants.VSStd2KCmdID.ECMD_VIEWMARKUP); menuItem = new OleMenuCommand(OpenFile, null, OpenFileBeforeQueryStatus, menuCommandID); AddCommand(menuItem); menuCommandID = new CommandID(VSConstants.GUID_VSStandardCommandSet97, (int)VSConstants.VSStd97CmdID.AddNewItem); menuItem = new OleMenuCommand(AddNewItem, menuCommandID); AddCommand(menuItem); var pyProj = _innerVsHierarchy.GetProject().GetPythonProject(); if (pyProj != null) { Analyzer.OnNewAnalyzer(pyProj.GetProjectAnalyzer().Project); pyProj.ProjectAnalyzerChanging += OnProjectAnalyzerChanging; } object extObject; ErrorHandler.ThrowOnFailure( _innerVsHierarchy.GetProperty( VSConstants.VSITEMID_ROOT, (int)__VSHPROPID.VSHPROPID_ExtObject, out extObject ) ); var proj = extObject as EnvDTE.Project; if (proj != null) { try { dynamic webAppExtender = proj.get_Extender("WebApplication"); if (webAppExtender != null) { webAppExtender.StartWebServerOnDebug = false; } } catch (COMException) { // extender doesn't exist... } } }
private void OnProjectAnalyzerChanging(object sender, AnalyzerChangingEventArgs e) { var pyProj = sender as IPythonProject; if (pyProj != null) { _analyzer.OnNewAnalyzer(e.New); } }
private DjangoAnalyzer AnalyzerTest(string path) { string djangoDbPath = TestData.GetPath("TestData\\DjangoDB"); Assert.IsTrue( PythonTypeDatabase.IsDatabaseVersionCurrent(djangoDbPath), "TestData\\DjangoDB needs updating." ); var testFact = InterpreterFactoryCreator.CreateAnalysisInterpreterFactory( new Version(2, 7), "Django Test Interpreter", TestData.GetPath("CompletionDB"), djangoDbPath ); var serviceProvider = PythonToolsTestUtilities.CreateMockServiceProvider(); PythonAnalyzer analyzer = PythonAnalyzer.CreateAsync(testFact).WaitAndUnwrapExceptions(); DjangoAnalyzer djangoAnalyzer = new DjangoAnalyzer(serviceProvider); djangoAnalyzer.OnNewAnalyzer(analyzer); analyzer.AddAnalysisDirectory(path); List<IPythonProjectEntry> entries = new List<IPythonProjectEntry>(); foreach (string file in Directory.EnumerateFiles(path, "*.py", SearchOption.AllDirectories)) { var entry = analyzer.AddModule(ModulePath.FromFullPath(file).ModuleName, file); var parser = Parser.CreateParser( new FileStream(file, FileMode.Open, FileAccess.Read), PythonLanguageVersion.V27 ); entry.UpdateTree(parser.ParseFile(), null); entries.Add(entry); } foreach (var entry in entries) { entry.Analyze(CancellationToken.None, false); } return djangoAnalyzer; }