public SolutionTreeNode(ISolutionAssemblyList solutionAssemblyList)
 {
     if (solutionAssemblyList == null)
         throw new ArgumentNullException("solutionAssemblyList");
     this.solutionAssemblyList = solutionAssemblyList;
     this.solution = solutionAssemblyList.Solution;
 }
		public TestableSolutionPackageRepository (
			ISolution solution,
			IMonoDevelopPackageRepositoryFactory repositoryFactory,
			PackageManagementOptions options)
			: base (solution, repositoryFactory, options)
		{
		}
 public CheckReadyStatusModule(ISolution solution)
 {
     Post["/checkreadystatus"] = x =>
         {
             return Response.AsJson(solution.Loaded);
         };
 }
        public void Execute(ISolution solution, ITextControl textControl)
        {
            // TODO extract add attribute to another class
            // method name  IDeclaredParameter AddDeclaredParameter()

            if (missedParameterError.Descriptor.IsAttribute)
            {
                IDocument document = textControl.Document;
                using (ModificationCookie cookie = document.EnsureWritable())
                {
                    int navigationOffset = -1;

                    try
                    {
                        CommandProcessor.Instance.BeginCommand("TextControl:AddAttribute");
                        string toInsert = " " + this.missedParameterError.Descriptor.Name + "=\"\"";
                        document.InsertText(this.headerNameRange.TextRange.EndOffset, toInsert);
                        navigationOffset = (this.headerNameRange.TextRange.EndOffset + toInsert.Length) - 1;
                    }
                    finally
                    {
                        CommandProcessor.Instance.EndCommand();
                    }
                    if (navigationOffset != -1)
                    {
                        textControl.CaretModel.MoveTo(navigationOffset, TextControlScrollType.MAKE_VISIBLE);
                        // todo run Completion Action
                    }
                }
            }
            else
            {
                Assert.Fail();
            }
        }
        /// <summary>
        /// The execute transaction inner.
        /// </summary>
        /// <param name="solution">
        /// The solution.
        /// </param>
        /// <param name="textControl">
        /// The text control.
        /// </param>
        public override void ExecuteTransactionInner(ISolution solution, ITextControl textControl)
        {
            ITreeNode element = Utils.GetElementAtCaret(solution, textControl);
            IBlock containingBlock = element.GetContainingNode<IBlock>(true);

            if (containingBlock != null)
            {
                //// CSharpFormatterHelper.FormatterInstance.Format(containingBlock);
                ICSharpCodeFormatter codeFormatter = (ICSharpCodeFormatter)CSharpLanguage.Instance.LanguageService().CodeFormatter;
                codeFormatter.Format(containingBlock);

                new LayoutRules().CurlyBracketsForMultiLineStatementsMustNotShareLine(containingBlock);
            }
            else
            {
                IFieldDeclaration fieldDeclarationNode = element.GetContainingNode<IFieldDeclaration>(true);
                if (fieldDeclarationNode != null)
                {
                    //// CSharpFormatterHelper.FormatterInstance.Format(fieldDeclarationNode);
                    ICSharpCodeFormatter codeFormatter = (ICSharpCodeFormatter)CSharpLanguage.Instance.LanguageService().CodeFormatter;
                    codeFormatter.Format(fieldDeclarationNode);

                    new LayoutRules().CurlyBracketsForMultiLineStatementsMustNotShareLine(fieldDeclarationNode);
                }
            }
        }
 /// <summary>
 /// The execute transaction inner.
 /// </summary>
 /// <param name="solution">
 /// The solution.
 /// </param>
 /// <param name="textControl">
 /// The text control.
 /// </param>
 public override void ExecuteTransactionInner(ISolution solution, ITextControl textControl)
 {
     string documentation = this.DocumentRange.GetText();
     Regex regEx = new Regex("(((///[ ^ ] *)))|((///))");
     documentation = regEx.Replace(documentation, "/// ");
     textControl.Document.ReplaceText(this.DocumentRange.TextRange, documentation);
 }
 /// <summary>
 /// Creates a new instance of the <see cref="WindowsFileImporter"/> class.
 /// </summary>
 public WindowsFileImporter(ISolution solution, IUriReferenceService uriService, IProductElement currentElement, string targetPath)
 {
     this.solution = solution;
     this.uriService = uriService;
     this.currentElement = currentElement;
     this.targetPath = targetPath;
 }
        /// <summary>
        /// The execute transaction inner.
        /// </summary>
        /// <param name="solution">
        /// The solution.
        /// </param>
        /// <param name="textControl">
        /// The text control.
        /// </param>
        public override void ExecuteTransactionInner(ISolution solution, ITextControl textControl)
        {
            IElement element = Utils.GetElementAtCaret(solution, textControl);

            if (element == null)
            {
                return;
            }

            IUsingListNode usingList = element.GetContainingElement(typeof(IUsingListNode), false) as IUsingListNode;

            if (usingList == null)
            {
                return;
            }

            ICSharpFile file = Utils.GetCSharpFile(solution, textControl);

            // This violation will only run if there are some using statements and definately at least 1 namespace
            // so [0] index will always be OK.
            ICSharpNamespaceDeclaration firstNamespace = file.NamespaceDeclarations[0];

            foreach (IUsingDirectiveNode usingDirectiveNode in usingList.Imports)
            {
                firstNamespace.AddImportBefore(usingDirectiveNode, null);

                file.RemoveImport(usingDirectiveNode);
            }
        }
		public override async Task<IProject> Generate(ISolution solution, string name)
		{
			var shell = IoC.Get<IShell>();
			var project = await base.Generate(solution, name);

			project.ToolChain = shell.ToolChains.FirstOrDefault(tc => tc is LocalGCCToolchain);

            project.ToolChain.ProvisionSettings(project);

			project.Debugger = shell.Debuggers.FirstOrDefault(db => db is LocalDebugAdaptor);

			var code = new StringBuilder();

			code.AppendLine("#include <stdio.h>");
			code.AppendLine();
			code.AppendLine("int main (void)");
			code.AppendLine("{");
			code.AppendLine("    printf(\"Hello World\");");
			code.AppendLine("    return 0;");
			code.AppendLine("}");
			code.AppendLine();

			await SourceFile.Create(project, "main.cpp", code.ToString());

			project.Save();

			return project;
		}
        public IPackageInitializationScripts CreatePackageInitializationScripts(
			ISolution solution)
        {
            var repository = new SolutionPackageRepository(solution);
            var scriptFactory = new PackageScriptFactory();
            return new PackageInitializationScripts(repository, scriptFactory);
        }
Example #11
0
            public void Initialize()
            {
                this.solutionEvents = new SolutionEvents(VsIdeTestHostContext.ServiceProvider);

                this.solution = VsIdeTestHostContext.ServiceProvider.GetService<ISolution>();
                this.solution.CreateInstance(Path.GetTempPath(), Path.GetFileName(Path.GetRandomFileName()));
            }
        /// <summary>
        /// The execute transaction inner.
        /// </summary>
        /// <param name="solution">
        /// The solution.
        /// </param>
        /// <param name="textControl">
        /// The text control.
        /// </param>
        public override void ExecuteTransactionInner(ISolution solution, ITextControl textControl)
        {
            ICSharpFile file = Utils.GetCSharpFile(solution, textControl);

            // Fixes SA1639
            DocumentationRules.InsertFileHeaderSummary(file);
        }
		public SolutionPackageRepository(ISolution solution)
			: this(
				solution,
				new SharpDevelopPackageRepositoryFactory(),
				PackageManagementServices.Options)
		{
		}
 internal CorrectAllSignaturesInSolution(ISolution solution, SyntaxNode declaration,
                                         IEnumerable<Tuple<int, int>> mappings)
 {
     this.solution = solution;
     this.declaration = declaration;
     this.mappings = mappings;
 }
        protected override Action<ITextControl> ExecutePsiTransaction(ISolution solution, IProgressIndicator progress)
        {
            if (_invocationExpression.ArgumentList.Arguments.Count == 4)
            {
                _invocationExpression.RemoveArgument(_invocationExpression.ArgumentList.Arguments[3]);
                var argument = Provider.ElementFactory.CreateArgument(ParameterKind.VALUE, Provider.ElementFactory.CreateExpression("false"));
                _invocationExpression.AddArgumentAfter(argument, _invocationExpression.ArgumentList.Arguments[2]);
            }
            else
            {
                if (_invocationExpression.ArgumentList.Arguments.Count == 1)
                {
                    var argument = Provider.ElementFactory.CreateArgument(ParameterKind.VALUE, Provider.ElementFactory.CreateExpression("default($0)", PropertyDeclaration.Type));
                    _invocationExpression.AddArgumentAfter(argument, _invocationExpression.ArgumentList.Arguments[0]);
                }

                if (_invocationExpression.ArgumentList.Arguments.Count == 2)
                {
                    var argument = Provider.ElementFactory.CreateArgument(ParameterKind.VALUE, Provider.ElementFactory.CreateExpression("null"));
                    _invocationExpression.AddArgumentAfter(argument, _invocationExpression.ArgumentList.Arguments[1]);
                }

                if (_invocationExpression.ArgumentList.Arguments.Count == 3)
                {
                    var argument = Provider.ElementFactory.CreateArgument(ParameterKind.VALUE, Provider.ElementFactory.CreateExpression("false"));
                    _invocationExpression.AddArgumentAfter(argument, _invocationExpression.ArgumentList.Arguments[2]);
                }
            }

            return null;
        }
        protected override Action<ITextControl> ExecutePsiTransaction(ISolution solution, IProgressIndicator progress)
        {
            ITypeDeclaration typeDeclaration = GetTargetTypeDeclaration(_highlighting.DeclaredTypeUsage);
            if (typeDeclaration == null)
                return null;

            MemberSignature signature = CreateTransformTextSignature(typeDeclaration);
            TypeTarget target = CreateTarget(typeDeclaration);

            var context = new CreateMethodDeclarationContext {
                AccessRights = AccessRights.PUBLIC,
                ExecuteTemplateOverMemberBody = false,
                ExecuteTemplateOverName = false,
                ExecuteTemplateOverParameters = false,
                ExecuteTemplateOverReturnType = false,
                IsAbstract = true,
                IsStatic = false,
                MethodSignatures = new[] { signature },
                MethodName = T4CSharpCodeGenerator.TransformTextMethodName,
                SourceReferenceExpressionReference = null,
                Target = target,
            };

            IntentionResult intentionResult = MethodDeclarationBuilder.Create(context);
            intentionResult.ExecuteTemplate();
            return null;
        }
		public SolutionPackageRepositoryPath (
			ISolution solution,
			PackageManagementOptions options)
		{
			this.solution = solution;
			PackageRepositoryPath = GetSolutionPackageRepositoryPath (options);
		}
Example #18
0
 public Bootstrapper(ISolution solution, IFileSystem fileSystem, bool verbose)
 {
     _fileSystem = fileSystem;
     _solution = solution;
     _verbose = verbose;
     JsonSettings.MaxJsonLength = int.MaxValue;
 }
        /// <inheritdoc />
        public override void ExecuteTransactionInner(ISolution solution, ITextControl textControl)
        {
            IDeclaration declaration = Utils.GetTypeClosestToTextControl<IDeclaration>(solution, textControl);

            // Fixes SA1604, 1605
            new DocumentationRules().InsertMissingSummaryElement(declaration);
        }
		void CreateSolution(string fileName)
		{
			solution = MockRepository.GenerateStrictMock<ISolution>();
			var file = FileName.Create(fileName);
			solution.Stub(s => s.FileName).Return(file);
			solution.Stub(s => s.Directory).Return(file.GetParentDirectory());
		}
 public ZenCodingEngine(ISolution solution)
 {
     ScriptEngine engine = Python.CreateEngine();
       ScriptScope scope = engine.CreateScope();
       string folder = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);
       var searchPaths = new List<string>(engine.GetSearchPaths())
       {
     Path.Combine(folder, "zencoding"), Path.Combine(folder, "sys")
       };
       engine.SetSearchPaths(searchPaths);
       var code = new StringBuilder()
     .AppendLine("import zen_settings")
     .AppendLine("import zen_core")
     .AppendLine("from zen_core import *")
     .AppendLine("from zen_settings import zen_settings")
     .AppendFormat("zen_core.insertion_point = '{0}'", InsertionPoint)
       .AppendLine()
     .AppendFormat("zen_settings['variables']['indentation'] = '{0}'", GlobalFormatSettingsHelper.GetService(solution).GetSettingsForLanguage(PsiLanguageType.ANY).GetIndentStr())
       .AppendLine()
     .AppendFormat("zen_core.newline = '{0}'", Regex.Escape(Environment.NewLine))
       .AppendLine();
       ScriptSource source = engine.CreateScriptSourceFromString(code.ToString(), SourceCodeKind.Statements);
       source.Execute(scope);
       expandAbbr = engine.GetVariable<Func<string, string, string>>(scope, "expand_abbreviation");
       PadString = engine.GetVariable<Func<string, int, string>>(scope, "pad_string");
       findAbbrInLine = engine.GetVariable<Func<string, int, PythonTuple>>(scope, "find_abbr_in_line");
       wrapWithAbbr = engine.GetVariable<Func<string, string, string, string>>(scope, "wrap_with_abbreviation");
 }
    public static IUnitTestElement ReadFromXml(XmlElement parent, IUnitTestElement parentElement, MSpecUnitTestProvider provider, ISolution solution
#if RESHARPER_61
      , IUnitTestElementManager manager, PsiModuleManager psiModuleManager, CacheManager cacheManager
#endif
      )
    {
      var projectId = parent.GetAttribute("projectId");
      var project = ProjectUtil.FindProjectElementByPersistentID(solution, projectId) as IProject;
      if (project == null)
      {
        return null;
      }

      var context = parentElement as ContextElement;
      if (context == null)
      {
        return null;
      }

      var typeName = parent.GetAttribute("typeName");
      var methodName = parent.GetAttribute("methodName");
      var isIgnored = bool.Parse(parent.GetAttribute("isIgnored"));

      return ContextSpecificationFactory.GetOrCreateContextSpecification(provider,
#if RESHARPER_61
                manager, psiModuleManager, cacheManager,
#endif
                project, context, ProjectModelElementEnvoy.Create(project), new ClrTypeName(typeName), methodName, EmptyArray<string>.Instance, isIgnored);
    }
		MonitoredSolution FindMonitoredSolution (ISolution solutionToMatch)
		{
			if (monitoredSolutions.Count == 1)
				return monitoredSolutions [0];

			return monitoredSolutions.FirstOrDefault (monitoredSolution => monitoredSolution.Solution.FileName == solutionToMatch.FileName);
		}
    public static IUnitTestElement ReadFromXml(XmlElement parent, IUnitTestElement parentElement, MSpecUnitTestProvider provider, ISolution solution
#if RESHARPER_61
      , IUnitTestElementManager manager, PsiModuleManager psiModuleManager, CacheManager cacheManager
#endif
      )
    {
      var projectId = parent.GetAttribute("projectId");
      var project = ProjectUtil.FindProjectElementByPersistentID(solution, projectId) as IProject;
      if (project == null)
      {
        return null;
      }

      var behavior = parentElement as BehaviorElement;
      if (behavior == null)
      {
        return null;
      }

      var typeName = parent.GetAttribute("typeName");
      var methodName = parent.GetAttribute("methodName");
      var isIgnored = bool.Parse(parent.GetAttribute("isIgnored"));

      return BehaviorSpecificationFactory.GetOrCreateBehaviorSpecification(provider,
#if RESHARPER_61
        manager, psiModuleManager, cacheManager,
#endif
        project, behavior, ProjectModelElementEnvoy.Create(project), typeName, methodName, isIgnored);
    }
    /// <summary>
    /// Executes QuickFix or ContextAction. Returns post-execute method.
    /// </summary>
    /// <param name="solution">The solution.</param>
    /// <param name="progress">The progress.</param>
    /// <returns>Action to execute after document and PSI transaction finish. Use to open TextControls, navigate caret, etc.</returns>
    protected override Action<ITextControl> ExecutePsiTransaction(ISolution solution, IProgressIndicator progress)
    {
      var model = this.GetModel();
      if (model == null)
      {
        return null;
      }

      var code = model.Method.GetText();
      if (string.IsNullOrEmpty(code))
      {
        return null;
      }

      var typeMember = this.provider.ElementFactory.CreateTypeMemberDeclaration(code);

      var classDeclaration = model.ContainingType as IClassLikeDeclaration;
      if (classDeclaration == null)
      {
        return null;
      }

      var memberDeclaration = typeMember as IClassMemberDeclaration;
      Debug.Assert(memberDeclaration != null, "memberDeclaration != null");

      var result = classDeclaration.AddClassMemberDeclarationBefore(memberDeclaration, model.Method);

      FormattingUtils.Format(result);

      return null;
    }
        /// <summary>
        /// Executes action. Called after Update, that set <c>ActionPresentation.Enabled</c> to true.
        /// </summary>
        /// <param name="solution">The solution.</param>
        /// <param name="context">The context.</param>
        protected override void Execute(ISolution solution, IDataContext context)
        {
            if (!context.CheckAllNotNull(DataConstants.SOLUTION)) {
                return;
            }

            ITextControl textControl = context.GetData(DataConstants.TEXT_CONTROL);
            if (textControl == null) {
                return;
            }

            IElement element = GetElementAtCaret(context);
            if (element == null) {
                return;
            }

            var enumDeclaration = element.ToTreeNode().Parent as IEnumDeclaration;
            if (enumDeclaration == null) {
                return;
            }

            using (ModificationCookie cookie = textControl.Document.EnsureWritable()) {
                if (cookie.EnsureWritableResult != EnsureWritableResult.SUCCESS) {
                    return;
                }

                using (CommandCookie.Create("Context Action Sort Enum By Name")) {
                    PsiManager.GetInstance(solution).DoTransaction(delegate { Execute(solution, enumDeclaration); });
                }
            }
        }
        /// <summary>
        /// Loads the specified solution.
        /// </summary>
        /// <param name="solution">
        /// The solution.
        /// </param>
        public void LoadChanges(ISolution solution)
        {
            this.solution = solution;

              var locations = RecentFilesManager.GetInstance(solution).EditLocations;

              var count = 0;
              foreach (var locationInfo in locations)
              {
            var projectFile = locationInfo.ProjectFile;
            var project = projectFile.GetProject();

            var solutionName = project.GetSolution().Name;
            var fileName = projectFile.Location.ConvertToRelativePath(project.Location).FullPath;

            int line;
            int position;
            int selectionStart;
            int selectionLength;

            if (EditorManager.GetInstance(solution).IsOpenedInTextControl(projectFile))
            {
              var textControl = EditorManager.GetInstance(solution).TryGetTextControl(projectFile);
              if (textControl == null)
              {
            return;
              }

              var documentText = textControl.Document.GetText();

              ReadText(new StringReader(documentText), locationInfo.CaretOffset, out line, out position, out selectionStart, out selectionLength);
            }
            else
            {
              ReadFile(projectFile, locationInfo.CaretOffset, out line, out position, out selectionStart, out selectionLength);
            }

            var labelText = "<" + solutionName + ">\\" + fileName + " (Ln " + line + ", Col " + position + ")";

            var l = new Selection
            {
              Text = labelText,
              SelectionStart = selectionStart,
              SelectionLength = selectionLength,
            };

            this.Listbox.Items.Add(l);

            count++;
            if (count >= 25)
            {
              break;
            }
              }

              if (this.Listbox.Items.Count > 0)
              {
            this.Listbox.SelectedIndex = 0;
              }
        }
        /// <summary>
        /// The execute transaction inner.
        /// </summary>
        /// <param name="solution">
        /// The solution.
        /// </param>
        /// <param name="textControl">
        /// The text control.
        /// </param>
        public override void ExecuteTransactionInner(ISolution solution, ITextControl textControl)
        {
            ICSharpFile file = Utils.GetCSharpFile(solution, textControl);

            IRangeMarker marker = this.DocumentRange.CreateRangeMarker();
            file.ArrangeThisQualifier(marker);
        }
 protected override Action<ITextControl> ExecutePsiTransaction(ISolution solution, IProgressIndicator progress)
 {
     var methodDeclaration = _highlighting.MethodDeclaration;
     methodDeclaration.SetExtern(true);
     methodDeclaration.SetStatic(true);
     return null;
 }
Example #30
0
 public RenameHandler(ISolution solution, BufferParser bufferParser, OmniSharpConfiguration config, FindUsagesHandler findUsagesHandler)
 {
     _solution = solution;
     _bufferParser = bufferParser;
     _findUsagesHandler = findUsagesHandler;
     _config = config;
 }
Example #31
0
        public override void Accept(
            ITextControl textControl, DocumentRange nameRange,
            LookupItemInsertType insertType, Suffix suffix, ISolution solution, bool keepCaretStill)
        {
            var psiServices             = solution.GetPsiServices();
            var updateMethodDeclaration = TextControlToPsi.GetElement <IMethodDeclaration>(solution, textControl);

            if (UpdateExistingMethod(updateMethodDeclaration, psiServices))
            {
                return;
            }

            var isCoroutine = updateMethodDeclaration?.TypeUsage is IUserTypeUsage userTypeUsage &&
                              userTypeUsage.ScalarTypeName?.ShortName == "IEnumerator";

            var fixedNameRange = nameRange.SetStartTo(Info.MemberReplaceRanges.InsertRange.StartOffset);
            var memberRange    = Info.MemberReplaceRanges.GetAcceptRange(fixedNameRange, insertType);

            // Insert a dummy method declaration, as text, which means the PSI is reparsed. This will remove empty type
            // usages and merge leading attributes into a method declaration, such that we can copy them and replace
            // them once the declared element has expanded. This also fixes up the case where the type usage picks up
            // the attribute of the next code construct as an array specifier. E.g. `OnAni{caret} [SerializeField]`
            using (WriteLockCookie.Create())
            {
                textControl.Document.ReplaceText(memberRange, "void Foo(){}");
            }

            psiServices.Files.CommitAllDocuments();

            var methodDeclaration = TextControlToPsi.GetElement <IMethodDeclaration>(solution, textControl);

            if (methodDeclaration == null)
            {
                return;
            }

            var methodDeclarationCopy = methodDeclaration.Copy();
            var nodesBeforeCopyRange  = NodesBeforeMethodHeader(methodDeclarationCopy);

            using (new PsiTransactionCookie(psiServices, DefaultAction.Commit, "RemoveInsertedDeclaration"))
                using (WriteLockCookie.Create())
                {
                    LowLevelModificationUtil.DeleteChild(methodDeclaration);
                }

            var classDeclaration = TextControlToPsi.GetElement <IClassLikeDeclaration>(solution, textControl);

            Assertion.AssertNotNull(classDeclaration, "classDeclaration != null");

            var factory = CSharpElementFactory.GetInstance(classDeclaration);

            GenerateCodeWorkflowBase.ExecuteNonInteractive(
                GeneratorUnityKinds.UnityEventFunctions, solution, textControl, methodDeclaration.Language,
                configureContext: context =>
            {
                // Note that the generated code will use the access rights, if specified. However, if they haven't
                // been specified (NONE) or they are the default for methods (PRIVATE), the generated code will be
                // whatever the current code style setting is - implicit or explicit
                var knownTypesCache = solution.GetComponent <KnownTypesCache>();
                var declaredElement = myEventFunction.CreateDeclaration(factory, knownTypesCache, classDeclaration,
                                                                        myAccessRights, makeCoroutine: isCoroutine)
                                      .DeclaredElement.NotNull("declaredElement != null");
                context.InputElements.Clear();
                context.InputElements.Add(new GeneratorDeclaredElement(declaredElement));
            },
                onCompleted: context =>
            {
                if (nodesBeforeCopyRange.IsEmpty)
                {
                    return;
                }

                foreach (var outputElement in context.OutputElements)
                {
                    if (outputElement is GeneratorDeclarationElement declarationElement)
                    {
                        using (new PsiTransactionCookie(psiServices, DefaultAction.Commit, "BringBackAttributes"))
                            using (WriteLockCookie.Create())
                            {
                                var newDeclaration = declarationElement.Declaration;
                                ModificationUtil.AddChildRangeAfter(newDeclaration, anchor: null, nodesBeforeCopyRange);
                            }

                        return;
                    }
                }
            });

            ITreeRange NodesBeforeMethodHeader(IMethodDeclaration declaration)
            {
                var firstNode = declaration.ModifiersList ?? declaration.TypeUsage as ITreeNode;

                var smthBeforeTypeUsage = firstNode?.PrevSibling;

                if (smthBeforeTypeUsage == null)
                {
                    return(TreeRange.Empty);
                }

                return(new TreeRange(declaration.FirstChild, smthBeforeTypeUsage));
            }
        }
 public void SetUp()
 {
     Solution = new FakeSolution(@"c:\test\fake.sln");
 }
Example #33
0
        protected override Action <ITextControl> ExecutePsiTransaction(ISolution _, IProgressIndicator __)
        {
            Highlighting.MethodDeclaration.RemoveParameterDeclaration(Highlighting.ParameterDeclaration);

            return(null);
        }
Example #34
0
 public ProjectReference(ISolution solution, string projectTitle, Guid projectGuid)
 {
     _solution     = solution;
     _projectTitle = projectTitle;
     _projectGuid  = projectGuid;
 }
Example #35
0
 public AddReferenceHandler(ISolution solution, IAddReferenceProcessorFactory addReferenceProcessorFactory)
 {
     _solution = solution;
     _addReferenceProcessorFactory = addReferenceProcessorFactory;
 }
 public UnityAssetRiderUsageGroupingProjectItemProvider(ISolution solution, ProjectModelIcons projectModelIcons, IconHost iconHost)
 {
     mySolution          = solution;
     myProjectModelIcons = projectModelIcons;
     myIconHost          = iconHost;
 }
 public abstract IProject Load(ISolution solution, string filePath);
Example #38
0
 internal SolutionItem(ISolution f, IEnumerable <IDependentItemRef> projects)
 {
     _solution = f;
     _projects = projects;
 }
 public UnityPluginDetector(ISolution solution, ILogger logger)
 {
     mySolution = solution;
     myLogger   = logger;
 }
Example #40
0
        /// <summary>
        /// Creates a new <see cref="SolutionDependencyContext"/>, possibly for a different subset of projects
        /// of the <see cref="Solutions"/> than the default set (all projects except build projects).
        /// </summary>
        /// <param name="m">The monitor to use.</param>
        /// <param name="traceGraphDetails">True to trace the details of the input and output (sorted) graphs.</param>
        /// <param name="projectFilter">
        /// Optional project filter.
        /// By default all projects are considered except build projects (see <see cref="Solution.BuildProject"/>).
        /// </param>
        /// <returns>The context or null on error.</returns>
        public SolutionDependencyContext CreateDependencyContext(IActivityMonitor m, bool traceGraphDetails, Func <IProject, bool> projectFilter = null)
        {
            if (projectFilter == null)
            {
                projectFilter = p => !p.IsBuildProject;
            }
            var sortables = new Dictionary <ISolution, SolutionItem>();

            foreach (var s in _solutions)
            {
                // The Solution contains its Projects.
                var children = s.Projects.Where(p => projectFilter(p)).Select(p => _projects[p]);
                var sItem    = new SolutionItem(s, children);
                sortables.Add(s, sItem);
            }

            var options = new DependencySorterOptions();

            if (traceGraphDetails)
            {
                options.HookInput  = i => i.Debug(m);
                options.HookOutput = i => i.Debug(m);
            }
            IDependencySorterResult result = DependencySorter.OrderItems(m, sortables.Values, null, options);

            if (!result.IsComplete)
            {
                result.LogError(m);
                return(new SolutionDependencyContext(this, result, GetBuildProjectInfo(m)));
            }
            // Building the list of SolutionDependencyContext.DependencyRow.
            var table = result.SortedItems
                        // 1 - Selects solutions along with their ordered index.
                        .Where(sorted => sorted.GroupForHead == null && sorted.Item is SolutionItem)
                        .Select(sorted =>
                                (
                                    Solution: (Solution)sorted.StartValue,
                                    // The projects from this solution that reference packages that are
                                    // produced by local solutions have a direct requires to a Package
                                    // that has a local Project.
                                    // 2 - First Map: LocalRefs is a set of value tuple (Project Origin, Package Target).
                                    LocalRefs: sorted.Children
                                    .Select(c => (SProject: c, Project: (Project)c.StartValue))
                                    .SelectMany(c => c.SProject.DirectRequires
                                                .Select(r => r.Item)
                                                .OfType <LocalPackageItem>()
                                                .Select(package => (Origin: c.Project, Target: package))
                                                )))
                        // 3 - Second Map: Expands the LocalRefs.
                        .SelectMany(s => s.LocalRefs.Any()
                                                ? s.LocalRefs.Select(r => new DependentSolution.Row
                                                                     (
                                                                         s.Solution,
                                                                         r.Origin,
                                                                         r.Target.Project
                                                                     ))
                                                : new[] { new DependentSolution.Row(s.Solution, null, null) }
                                    )
                        .ToList();

            // Now that the table of SolutionDependencyContext.DependencyRow is built, use it to compute the
            // pure solution dependency graph.
            //
            var       index        = new Dictionary <object, DependentSolution>();
            ISolution current      = null;
            var       depSolutions = new DependentSolution[sortables.Count];

            int idx = 0;

            foreach (var r in table)
            {
                if (current != r.Solution)
                {
                    current = r.Solution;
                    var newDependent = new DependentSolution(current, table, s => index[s]);
                    depSolutions[idx++] = newDependent;
                    index.Add(current.Name, newDependent);
                    index.Add(current, newDependent);
                }
            }
            Array.Sort(depSolutions, (d1, d2) =>
            {
                int cmp = d1.Rank - d2.Rank;
                if (cmp == 0)
                {
                    cmp = d1.Solution.Name.CompareTo(d2.Solution.Name);
                }
                return(cmp);
            });
            for (int i = 0; i < depSolutions.Length; ++i)
            {
                depSolutions[i].Index = i;
            }

            return(new SolutionDependencyContext(this, index, result, table, depSolutions, GetBuildProjectInfo(m)));
        }
Example #41
0
        public Result Optimize(
            int maxSteps,
            float criteria,
            Func <ISolution> initialSolution,
            int runs             = 1,
            int evalsPerSolution = 1)
        {
            int evaluations = 0;

            BestEvaluation = float.NaN;
            BestSolution   = null;

            // Perform algorithm runs
            for (int i = 0; i < runs; i++)
            {
                BestSolutionInRun = null;

                // For current run, get an initial solution
                CurrentSolution   = initialSolution();
                CurrentEvaluation = evaluate(CurrentSolution);
                evaluations++;
                BestSolutionInRun   = CurrentSolution;
                BestEvaluationInRun = CurrentEvaluation;

                // Perform a run of the algorithm
                for (int j = 0; j < maxSteps; j++)
                {
                    // Find random neighbor
                    ISolution neighborSolution   = findNeighbor(CurrentSolution);
                    float     neighborEvaluation = 0;

                    // Evaluate neighbor
                    for (int k = 0; k < evalsPerSolution; k++)
                    {
                        neighborEvaluation += evaluate(neighborSolution);
                        evaluations++;
                    }
                    neighborEvaluation = neighborEvaluation / evalsPerSolution;

                    // Select solution (either keep current solution or
                    // select neighbor solution)
                    if (select(neighborEvaluation, CurrentEvaluation))
                    {
                        CurrentSolution   = neighborSolution;
                        CurrentEvaluation = neighborEvaluation;

                        if (compare(CurrentEvaluation, BestEvaluationInRun))
                        {
                            BestSolutionInRun   = CurrentSolution;
                            BestEvaluationInRun = CurrentEvaluation;
                        }
                    }

                    // If we reached the criteria, break loop
                    if (compare(CurrentEvaluation, criteria))
                    {
                        break;
                    }
                }

                // Is last run's best solution better than the best solution
                // found so far in all runs?
                if (compare(BestEvaluationInRun, BestEvaluation) ||
                    BestSolution == null)
                {
                    BestSolution   = BestSolutionInRun;
                    BestEvaluation = BestEvaluationInRun;
                }
            }
            return(new Result(BestSolution, BestEvaluation, evaluations));
        }
 void ImportRemoved(object sender, DotNetProjectImportEventArgs e)
 {
     solutionContainingProjectBuildersToDispose = e.Project.ParentSolution;
 }
Example #43
0
 public RenameHandler(ISolution solution, BufferParser bufferParser)
 {
     _solution          = solution;
     _bufferParser      = bufferParser;
     _findUsagesHandler = new FindUsagesHandler(bufferParser, solution);
 }
        private static IDataContext CreateDataContext(IComponentContainer componentContainer, ISolution solution, ITextControl control)
        {
            var actionManager = componentContainer.GetComponent <IActionManager>();

            var dataRules = DataRules
                            .AddRule("Test", ProjectModelDataConstants.SOLUTION, x => solution)
                            .AddRule("Test", TextControlDataConstants.TEXT_CONTROL, x => control)
                            .AddRule("Test", DocumentModelDataConstants.DOCUMENT, x => control.Document)
                            .AddRule("Test", DocumentModelDataConstants.EDITOR_CONTEXT, x => new DocumentEditorContext(new DocumentOffset(control.Document, control.Caret.Position.Value.ToDocOffset())));

            return(actionManager.DataContexts.CreateWithDataRules(control.Lifetime, dataRules));
        }
        /// <summary>
        /// The execute transaction inner.
        /// </summary>
        /// <param name="solution">
        /// The solution.
        /// </param>
        /// <param name="textControl">
        /// The text control.
        /// </param>
        public override void ExecuteTransactionInner(ISolution solution, ITextControl textControl)
        {
            ICSharpFile file = Utils.GetCSharpFile(solution, textControl);

            new DocumentationRules().InsertCopyrightText(file);
        }
Example #46
0
        public override ILexerFactory GetMixedLexerFactory(ISolution solution, IBuffer buffer, IPsiSourceFile sourceFile = null)
        {
            var service = GherkinLanguage.Instance.LanguageService();

            return(service?.GetPrimaryLexerFactory());
        }
Example #47
0
        public static bool HasUnityReference([NotNull] this ISolution solution)
        {
            var tracker = solution.GetComponent <UnityReferencesTracker>();

            return(tracker.HasUnityReference.Value);
        }
Example #48
0
 public ISolutionPackageRepository CreateSolutionPackageRepository(ISolution solution)
 {
     return(new SolutionPackageRepository(solution, repositoryFactory, options));
 }
Example #49
0
 public ProviderCustomOptionsControl GetCustomOptionsControl(ISolution solution)
 {
     return(null);
 }
 public ISolutionPackageRepository CreateSolutionPackageRepository(ISolution solution)
 {
     SolutionPassedToCreateSolutionPackageRepository = solution;
     return(FakeSolutionPackageRepository);
 }
Example #51
0
 public Examiner(ISolution solution)
 {
     Solution = solution;
 }
Example #52
0
 public UnitTestElement Deserialize(ISolution solution, string elementString)
 {
     throw new NotImplementedException();
 }
Example #53
0
 public void SetUp()
 {
     _solution = new FakeSolution(@"c:\test\fake.sln");
     _fs       = new MockFileSystem();
 }
Example #54
0
 public void ExploreSolution(ISolution solution, UnitTestElementConsumer consumer)
 {
 }
Example #55
0
 public string GetPresentation(ISolution solution, IDeclaredElement declaredElement, bool prefabImport)
 {
     return($"x: {X}, y: {Y}");
 }
 protected override Action <ITextControl> ExecutePsiTransaction(ISolution solution, IProgressIndicator progress)
 {
     AttributeUtil.AddAttributeToSingleDeclaration(myClassDeclaration, KnownTypes.RequireComponent,
                                                   new[] { new AttributeValue(myType) }, null, myClassDeclaration.GetPsiModule(), myFactory, true);
     return(null);
 }
 public ISolution Apply(ISolution solution, int configuration)
 {
     return(Apply(solution, Configurations[configuration]));
 }
Example #58
0
 public string GetFullPresentation(ISolution solution, IDeclaredElement declaredElement, bool prefabImport)
 {
     return(GetPresentation(solution, declaredElement, prefabImport));
 }
 public abstract ISolution Apply(ISolution solution, Configuration configuration);
 public bool Navigate(ISolution solution, PopupWindowContextSource windowContext, bool transferFocus,
                      TabOptions tabOptions = TabOptions.Default)
 {
     return(solution.GetComponent <UnityAssetOccurrenceNavigator>().Navigate(solution, DeclaredElementPointer, AttachedElementLocation));
 }