private static async Task RunAsync( string projectSolutionOrRspPath, ImmutableArray <string> ruleTypes, ImmutableArray <string> fileNames, ImmutableArray <string[]> preprocessorConfigurations, ImmutableArray <string> copyrightHeader, string language, bool allowTables, bool convertUnicode, bool verbose, FormattingLevel formattingLevel, CancellationToken cancellationToken) { var engine = FormattingEngine.Create(ruleTypes); engine.PreprocessorConfigurations = preprocessorConfigurations; engine.FileNames = fileNames; engine.CopyrightHeader = copyrightHeader; engine.AllowTables = allowTables; engine.ConvertUnicodeCharacters = convertUnicode; engine.Verbose = verbose; engine.FormattingLevel = formattingLevel; Console.WriteLine(Path.GetFileName(projectSolutionOrRspPath)); string extension = Path.GetExtension(projectSolutionOrRspPath); if (StringComparer.OrdinalIgnoreCase.Equals(extension, ".rsp")) { using (var workspace = ResponseFileWorkspace.Create()) { Project project = workspace.OpenCommandLineProject(projectSolutionOrRspPath, language); await engine.FormatProjectAsync(project, cancellationToken); } } else if (StringComparer.OrdinalIgnoreCase.Equals(extension, ".sln")) { using (var workspace = MSBuildWorkspace.Create()) { workspace.LoadMetadataForReferencedProjects = true; var solution = await workspace.OpenSolutionAsync(projectSolutionOrRspPath, cancellationToken); await engine.FormatSolutionAsync(solution, cancellationToken); } } else { using (var workspace = MSBuildWorkspace.Create()) { workspace.LoadMetadataForReferencedProjects = true; var project = await workspace.OpenProjectAsync(projectSolutionOrRspPath, cancellationToken); await engine.FormatProjectAsync(project, cancellationToken); } } }
public StyleCollection GetStyle(int characterPosition, FormattingLevel level) { List<Prl[]> prls = new List<Prl[]>(); if(level >= FormattingLevel.Character) { foreach (CharacterFormatting formatting in formattings) { if (formatting.FileCharacterPosition.Contains(characterPosition)) { if (level >= FormattingLevel.CharacterStyle) { StyleDefinition definition = formatting.Style; if (definition != null) definition.ExpandStyles(prls); } } } } if (level >= FormattingLevel.Paragraph) { foreach (Paragraph paragraph in paragraphs) { if (paragraph.FileCharacterPosition.Contains(characterPosition)) { if (level >= FormattingLevel.ParagraphStyle) { StyleDefinition definition = paragraph.Style; definition.ExpandStyles(prls); } } } } if (level >= FormattingLevel.Part) { foreach (FileCharacterPosition fcp in fileCharacterPositions) { if (fcp.Contains(characterPosition)) { prls.Add(fcp.Prls); } } } if (level >= FormattingLevel.Global) { prls.Add(defaultPrls); } return new StyleCollection(prls); }
public StyleCollection GetStyles(FormattingLevel level) { if(level != FormattingLevel.Character && level != FormattingLevel.CharacterStyle) throw new ArgumentOutOfRangeException("level"); List<Prl[]> prls = new List<Prl[]>(); prls.Add(Chpx.grpprl); if (level == FormattingLevel.CharacterStyle) { StyleDefinition def = this.Style; if (def != null) def.ExpandStyles(prls); } return new StyleCollection(prls); }
public StyleCollection GetStyles(FormattingLevel level) { if (level != FormattingLevel.Paragraph && level != FormattingLevel.ParagraphStyle) throw new ArgumentOutOfRangeException("level"); List<Prl[]> prls = new List<Prl[]>(); prls.Add(PapxInFkps.grpprlInPapx.grpprl); if (level == FormattingLevel.ParagraphStyle) { this.Style.ExpandStyles(prls); } return new StyleCollection(prls); }