コード例 #1
0
        private List <ProjectReferenceNode> GetProjectReferencesContainingThisProject(IVsHierarchy inputHierarchy)
        {
            List <ProjectReferenceNode> projectReferences = new List <ProjectReferenceNode>();

            if (this.Solution == null || inputHierarchy == null)
            {
                return(projectReferences);
            }

            uint             flags            = (uint)(__VSENUMPROJFLAGS.EPF_ALLPROJECTS | __VSENUMPROJFLAGS.EPF_LOADEDINSOLUTION);
            Guid             enumOnlyThisType = Guid.Empty;
            IEnumHierarchies enumHierarchies  = null;

            ErrorHandler.ThrowOnFailure(this.Solution.GetProjectEnum(flags, ref enumOnlyThisType, out enumHierarchies));
            Debug.Assert(enumHierarchies != null, "Could not get list of hierarchies in solution");

            IVsHierarchy[] hierarchies = new IVsHierarchy[1];
            uint           fetched;
            int            returnValue = VSConstants.S_OK;

            do
            {
                returnValue = enumHierarchies.Next(1, hierarchies, out fetched);
                Debug.Assert(fetched <= 1, "We asked one project to be fetched VSCore gave more than one. We cannot handle that");
                if (returnValue == VSConstants.S_OK && fetched == 1)
                {
                    IVsHierarchy hierarchy = hierarchies[0];
                    Debug.Assert(hierarchy != null, "Could not retrieve a hierarchy");
                    IReferenceContainerProvider provider = hierarchy as IReferenceContainerProvider;
                    if (provider != null)
                    {
                        IReferenceContainer referenceContainer = provider.GetReferenceContainer();

                        Debug.Assert(referenceContainer != null, "Could not found the References virtual node");
                        ProjectReferenceNode projectReferenceNode = GetProjectReferenceOnNodeForHierarchy(referenceContainer.EnumReferences(), inputHierarchy);
                        if (projectReferenceNode != null)
                        {
                            projectReferences.Add(projectReferenceNode);
                        }
                    }
                }
            } while(returnValue == VSConstants.S_OK && fetched == 1);

            return(projectReferences);
        }
コード例 #2
0
ファイル: Utilities.cs プロジェクト: yangfan79/MPFProj10
        internal static ProjectReferenceNode AddProjectReference(ProjectNode project, ProjectNode projectReference)
        {
            VSCOMPONENTSELECTORDATA selectorData = new VSCOMPONENTSELECTORDATA();

            selectorData.bstrFile = projectReference.ProjectFolder;
            IVsSolution solution = (IVsSolution)project.Site.GetService(typeof(IVsSolution));

            solution.GetProjrefOfItem(projectReference, VSConstants.VSITEMID_ROOT, out selectorData.bstrProjRef);
            selectorData.bstrTitle = projectReference.Caption;
            selectorData.type      = VSCOMPONENTTYPE.VSCOMPONENTTYPE_Project;

            // Get the ReferenceContainerNode for this project.
            IReferenceContainer container = project.GetReferenceContainer();

            container.AddReferenceFromSelectorData(selectorData);

            return((ProjectReferenceNode)((ReferenceContainerNode)container).FindChild(projectReference.GetMKDocument()));
        }
コード例 #3
0
ファイル: Utilities.cs プロジェクト: modulexcite/PowerStudio
        internal static ProjectReferenceNode AddProjectReference(ProjectNode project, ProjectNode projectReference)
        {
            VSCOMPONENTSELECTORDATA selectorData = new VSCOMPONENTSELECTORDATA();

            selectorData.bstrFile = projectReference.ProjectFolder;
            IVsSolution solution = (IVsSolution)project.Site.GetService(typeof(IVsSolution));

            solution.GetProjrefOfItem(projectReference, VSConstants.VSITEMID_ROOT, out selectorData.bstrProjRef);
            selectorData.bstrTitle = projectReference.Caption;
            selectorData.type      = VSCOMPONENTTYPE.VSCOMPONENTTYPE_Project;

            // Get the ReferenceContainerNode for this project.
            IReferenceContainer container = project.GetReferenceContainer();

            container.AddReferenceFromSelectorData(selectorData);

            MethodInfo mi = typeof(ReferenceContainerNode).GetMethod("FindChild", BindingFlags.NonPublic | BindingFlags.Instance);

            return(mi.Invoke(container, new object[] { projectReference.GetMkDocument() }) as ProjectReferenceNode);
        }
コード例 #4
0
 public DefaultReferenceLoader(IReferenceContainer referenceContainer, ILogger <DefaultReferenceLoader> logger)
 {
     _referenceContainer = referenceContainer;
     _logger             = logger;
 }
コード例 #5
0
 public PluginsController(IPluginManager pluginManager,
                          IReferenceContainer referenceContainer)
 {
     _pluginManager      = pluginManager;
     _referenceContainer = referenceContainer;
 }
コード例 #6
0
ファイル: ProjectConfig.cs プロジェクト: ugurlu2001/CodePlex
        private void Build(uint options, IVsOutputWindowPane output, string target)
        {
            bool shouldRepaintReferences = false;

            if (!this.config.ProjectMgr.HasPassedSecurityChecks)
            {
                // From a security perspective, if there was something truly malicious about the project,
                // the user is about to toast himself by requesting a build.  Any further attempts at
                // preventing damage by avoiding MSBuild targets/tasks are futile.  So, from this point
                // forward, we might as well pretend that this project has passed all security checks,
                // and we're free to run any targets we like.
                this.config.ProjectMgr.HasPassedSecurityChecks = true;
                shouldRepaintReferences = true;
            }


            int shouldContinue = 1;

            foreach (IVsBuildStatusCallback cb in callbacks)
            {
                try
                {
                    ErrorHandler.ThrowOnFailure(cb.BuildBegin(ref shouldContinue));
                    if (shouldContinue == 0)
                    {
                        return;
                    }
                }
                catch (Exception e)
                {
                    // If those who ask for status have bugs in their code it should not prevent the build/notification from happening
                    Debug.Fail(String.Format("Exception was thrown during BuildBegin event\n{0}", e.Message));
                }
            }

            MSBuildResult result = MSBuildResult.Failed;

            try
            {
                result = config.ProjectMgr.Build(options, this.config.ConfigName, output, target);
            }
            catch (Exception e)
            {
                Trace.WriteLine("Exception : " + e.Message);
                ErrorHandler.ThrowOnFailure(output.OutputStringThreadSafe("Unhandled Exception:" + e.Message + "\n"));
                throw e;
            }
            finally
            {
                int success = ((result == MSBuildResult.Sucessful) ? 1 : 0);

                foreach (IVsBuildStatusCallback cb in callbacks)
                {
                    try
                    {
                        ErrorHandler.ThrowOnFailure(cb.BuildEnd(success));
                    }
                    catch (Exception e)
                    {
                        // If those who ask for status have bugs in their code it should not prevent the build/notification from happening
                        Debug.Fail(String.Format("Exception was thrown during BuildEnd event\n{0}", e.Message));
                    }
                }
                ErrorHandler.ThrowOnFailure(output.FlushToTaskList());

                // Now repaint references if that is needed.
                // We hardly rely here on the fact the ResolveAssemblyReferences target has been run as part of the build.
                if (shouldRepaintReferences)
                {
                    // Repaint references
                    IReferenceContainer referenceContainer = this.config.ProjectMgr.GetReferenceContainer();
                    foreach (ReferenceNode node in referenceContainer.EnumReferences())
                    {
                        node.RefreshReference();
                    }
                }
            }
        }
コード例 #7
0
 public DefaultReferenceLoader(IReferenceContainer referenceContainer, ILogger <DefaultReferenceLoader> logger)
 {
     this.referenceContainer = referenceContainer;
     this.logger             = logger;
 }
コード例 #8
0
        public override int DebugLaunch(uint grfLaunch)
        {
            DebugTargetInfo info = new DebugTargetInfo();

            CommandLineBuilder commandLine = new CommandLineBuilder();

            bool   x64 = Platform.EndsWith("X64", StringComparison.OrdinalIgnoreCase) || (Platform.EndsWith("Any CPU", StringComparison.OrdinalIgnoreCase) && Environment.Is64BitOperatingSystem);
            string agentBaseFileName = "Tvl.Java.DebugHostWrapper";

            if (x64)
            {
                agentBaseFileName += "X64";
            }

            bool useDevelopmentEnvironment = (grfLaunch & (uint)__VSDBGLAUNCHFLAGS.DBGLAUNCH_NoDebug) == 0;

            string debugAgentName = GetConfigurationProperty(JavaConfigConstants.DebugAgent, _PersistStorageType.PST_USER_FILE, false);
            bool   useJdwp        = string.Equals(DebugAgent.Jdwp.ToString(), debugAgentName, StringComparison.OrdinalIgnoreCase);

            if (useJdwp)
            {
                commandLine.AppendSwitch("-Xdebug");
                string serverValue = useDevelopmentEnvironment ? "y" : "n";
                commandLine.AppendSwitch("-Xrunjdwp:transport=dt_socket,server=" + serverValue + ",address=6777");
            }
            else
            {
                string agentFolder   = Path.GetDirectoryName(typeof(JavaProjectConfig).Assembly.Location);
                string agentFileName = agentBaseFileName + ".dll";
                string agentPath     = Path.GetFullPath(Path.Combine(agentFolder, agentFileName));
                commandLine.AppendSwitchIfNotNull("-agentpath:", agentPath);

                string agentArguments = GetConfigurationProperty(JavaConfigConstants.DebugAgentArguments, _PersistStorageType.PST_USER_FILE, false);
                if (!string.IsNullOrEmpty(agentArguments))
                {
                    commandLine.AppendTextUnquoted("=" + agentArguments);
                }
            }

            switch (GetConfigurationProperty(JavaConfigConstants.DebugStartAction, _PersistStorageType.PST_USER_FILE, false))
            {
            case "Class":
                string jvmArguments = GetConfigurationProperty(JavaConfigConstants.DebugJvmArguments, _PersistStorageType.PST_USER_FILE, false);
                if (!string.IsNullOrEmpty(jvmArguments))
                {
                    commandLine.AppendTextUnquoted(" " + jvmArguments);
                }

                commandLine.AppendSwitch("-cp");
                commandLine.AppendFileNameIfNotNull(GetConfigurationProperty("TargetPath", _PersistStorageType.PST_PROJECT_FILE, false));

                string startupObject = GetConfigurationProperty(JavaConfigConstants.DebugStartClass, _PersistStorageType.PST_USER_FILE, false);
                if (!string.IsNullOrEmpty(startupObject))
                {
                    commandLine.AppendFileNameIfNotNull(startupObject);
                }

                break;

            default:
                throw new NotImplementedException("This preview version of the Java debugger only supports starting execution in a named class; the class name may be configured in the project properties on the Debug tab.");
            }

            string debugArgs = GetConfigurationProperty(JavaConfigConstants.DebugExtraArgs, _PersistStorageType.PST_USER_FILE, false);

            if (!string.IsNullOrEmpty(debugArgs))
            {
                commandLine.AppendTextUnquoted(" " + debugArgs);
            }

            string workingDirectory = GetConfigurationProperty(JavaConfigConstants.DebugWorkingDirectory, _PersistStorageType.PST_USER_FILE, false);

            if (string.IsNullOrEmpty(workingDirectory))
            {
                workingDirectory = GetConfigurationProperty(JavaConfigConstants.OutputPath, _PersistStorageType.PST_PROJECT_FILE, false);
            }

            if (!Path.IsPathRooted(workingDirectory))
            {
                workingDirectory = Path.GetFullPath(Path.Combine(this.ProjectManager.ProjectFolder, workingDirectory));
            }

            // Pass the project references via the CLASSPATH environment variable
            List <string>         classPathEntries   = new List <string>();
            IReferenceContainer   referenceContainer = ProjectManager.GetReferenceContainer();
            IList <ReferenceNode> references         = referenceContainer.EnumReferences();

            foreach (var referenceNode in references)
            {
                JarReferenceNode jarReferenceNode = referenceNode as JarReferenceNode;
                if (jarReferenceNode != null)
                {
                    if (File.Exists(jarReferenceNode.InstalledFilePath) || Directory.Exists(jarReferenceNode.InstalledFilePath))
                    {
                        classPathEntries.Add(jarReferenceNode.InstalledFilePath);
                    }
                }
            }

            if (classPathEntries != null)
            {
                string classPath = string.Join(";", classPathEntries);
                info.Environment.Add("CLASSPATH", classPath);
            }

            //List<string> arguments = new List<string>();
            //arguments.Add(@"-agentpath:C:\dev\SimpleC\Tvl.Java.DebugHost\bin\Debug\Tvl.Java.DebugHostWrapper.dll");
            ////arguments.Add(@"-verbose:jni");
            ////arguments.Add(@"-cp");
            ////arguments.Add(@"C:\dev\JavaProjectTest\JavaProject\out\Debug");
            //arguments.Add("tvl.school.ee382v.a3.problem1.program1");
            ////arguments.Add(GetConfigurationProperty("OutputPath", true));
            ////arguments.Add(GetConfigurationProperty(JavaConfigConstants.DebugStartClass, false, _PersistStorageType.PST_USER_FILE));
            ////arguments.Add(GetConfigurationProperty(JavaConfigConstants.DebugExtraArgs, false, _PersistStorageType.PST_USER_FILE));

            //info.Arguments = string.Join(" ", arguments);

            info.Arguments = commandLine.ToString();

            info.Executable = FindJavaBinary("java.exe", useDevelopmentEnvironment);

            //info.CurrentDirectory = GetConfigurationProperty("WorkingDirectory", false, _PersistStorageType.PST_USER_FILE);
            info.CurrentDirectory   = workingDirectory;
            info.SendToOutputWindow = false;
            info.DebugEngines       = new Guid[]
            {
                typeof(JavaDebugEngine).GUID,
                //VSConstants.DebugEnginesGuids.ManagedOnly_guid,
                //VSConstants.DebugEnginesGuids.NativeOnly_guid,
            };
            Guid localPortSupplier = new Guid("{708C1ECA-FF48-11D2-904F-00C04FA302A1}");

            info.PortSupplier    = localPortSupplier;
            info.LaunchOperation = DEBUG_LAUNCH_OPERATION.DLO_CreateProcess;
            info.LaunchFlags     = (__VSDBGLAUNCHFLAGS)grfLaunch | (__VSDBGLAUNCHFLAGS)__VSDBGLAUNCHFLAGS2.DBGLAUNCH_MergeEnv;

            var debugger = (IVsDebugger2)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SVsShellDebugger));
            int result   = debugger.LaunchDebugTargets(info);

            if (result != VSConstants.S_OK)
            {
                IVsUIShell uishell = (IVsUIShell)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SVsUIShell));
                string     message = uishell.GetErrorInfo();
            }

            return(result);
        }
コード例 #9
0
ファイル: PluginsController.cs プロジェクト: QJesus/Mystique
 public PluginsController(IReferenceContainer referenceContainer, PluginPackage pluginPackage, IPluginManager pluginManager)
 {
     this.referenceContainer = referenceContainer;
     this.pluginPackage      = pluginPackage;
     this.pluginManager      = pluginManager;
 }
コード例 #10
0
 public PluginsController(IPluginManager pluginManager, ApplicationPartManager partManager, IReferenceContainer referenceContainer)
 {
     _pluginManager      = pluginManager;
     _partManager        = partManager;
     _referenceContainer = referenceContainer;
 }