Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azp: vscode extension completions #403

Merged
merged 13 commits into from
Oct 9, 2024
38 changes: 38 additions & 0 deletions src/Sdk/Actions/ActionsDescriptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;

using Newtonsoft.Json;

namespace Sdk.Actions {

public class ActionsDescriptions
{

public static Dictionary<string, TSource> ToOrdinalIgnoreCaseDictionary<TSource>(IEnumerable<KeyValuePair<string, TSource>> source) {
var ret = new Dictionary<string, TSource>(StringComparer.OrdinalIgnoreCase);
foreach(var kv in source) {
ret[kv.Key] = kv.Value;
}
return ret;
}

public string Description { get; set; }

public Dictionary<string, string> Versions { get; set; }
public static Dictionary<string, Dictionary<string, ActionsDescriptions>> LoadDescriptions() {
var assembly = Assembly.GetExecutingAssembly();
var json = default(String);
using (var stream = assembly.GetManifestResourceStream("descriptions.json"))
using (var streamReader = new StreamReader(stream))
{
json = streamReader.ReadToEnd();
}

return ToOrdinalIgnoreCaseDictionary(JsonConvert.DeserializeObject<Dictionary<string, Dictionary<string, ActionsDescriptions>>>(json).Select(kv => new KeyValuePair<string, Dictionary<string, ActionsDescriptions>>(kv.Key, ToOrdinalIgnoreCaseDictionary(kv.Value))));
}
}

}
282 changes: 282 additions & 0 deletions src/Sdk/Actions/descriptions.json

Large diffs are not rendered by default.

959 changes: 959 additions & 0 deletions src/Sdk/AzurePipelines/AutoCompleteHelper.cs

Large diffs are not rendered by default.

232 changes: 203 additions & 29 deletions src/Sdk/AzurePipelines/AzureDevops.cs

Large diffs are not rendered by default.

62 changes: 62 additions & 0 deletions src/Sdk/AzurePipelines/CompletionItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using System.Reflection.Emit;

using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;

namespace Runner.Server.Azure.Devops {

[JsonObject("", NamingStrategyType = typeof(CamelCaseNamingStrategy), ItemNullValueHandling = NullValueHandling.Ignore)]
public class CompletionItemLabel {
public string Label { get; set; }
public string Description { get; set; }
public string Detail { get; set; }
}
[JsonObject("", NamingStrategyType = typeof(CamelCaseNamingStrategy), ItemNullValueHandling = NullValueHandling.Ignore)]
public class MarkdownString {
public string Value { get; set; }
public bool? SupportThemeIcons { get; set; }
public bool? SupportHtml { get; set; }
}

[JsonObject("", NamingStrategyType = typeof(CamelCaseNamingStrategy), ItemNullValueHandling = NullValueHandling.Ignore)]
public class SnippedString {
public string Value { get; set; }
}

[JsonObject("", NamingStrategyType = typeof(CamelCaseNamingStrategy), ItemNullValueHandling = NullValueHandling.Ignore)]
public class Position {
public long Character { get; set; }
public long Line { get; set; }
}

[JsonObject("", NamingStrategyType = typeof(CamelCaseNamingStrategy), ItemNullValueHandling = NullValueHandling.Ignore)]
public class Range {
public Position Start { get; set; }
public Position End { get; set; }
public bool? IsEmpty { get; set; }
public bool? IsSingleLine { get; set; }
}
[JsonObject("", NamingStrategyType = typeof(CamelCaseNamingStrategy), ItemNullValueHandling = NullValueHandling.Ignore)]
public class InsertReplaceRange {
public Range Inserting { get; set; }
public Range Replacing { get; set; }
}

[JsonObject("", NamingStrategyType = typeof(CamelCaseNamingStrategy), ItemNullValueHandling = NullValueHandling.Ignore)]
public class CompletionItem {
public CompletionItemLabel Label { get; set; }
public string FilterText { get; set; }
public SnippedString InsertText { get; set; }
public string SortText { get; set; }
public bool? Preselect { get; set; }
public string Detail { get; set; }
public string[] CommitCharacters { get; set; }
public bool? KeepWhitespace { get; set; }
public int? Kind { get; set; }
public InsertReplaceRange Range { get; set; }
public MarkdownString Documentation { get; set; }

[JsonIgnore]
public int Priority { get; set; } = 0;
}
}
8 changes: 8 additions & 0 deletions src/Sdk/AzurePipelines/Context.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using GitHub.DistributedTask.Expressions2;
using GitHub.DistributedTask.ObjectTemplating;
using GitHub.DistributedTask.ObjectTemplating.Tokens;
using System;
using System.Collections.Generic;
Expand All @@ -17,6 +18,10 @@ public class Context {
public ITaskByNameAndVersionProvider TaskByNameAndVersion { get; set; }
public IRequiredParametersProvider RequiredParametersProvider { get; set; }
public List<string> FileTable { get; set; } = new List<string>();
public int Column { get; internal set; }
public int Row { get; internal set; }
internal List<AutoCompleteEntry> AutoCompleteMatches { get; set; }
public List<int> SemTokens { get; internal set; }

public Context Clone() {
return MemberwiseClone() as Context;
Expand All @@ -28,6 +33,9 @@ public Context ChildContext(MappingToken template, string path = null) {
}
var childContext = Clone();
childContext.RequiredParametersProvider = null;
childContext.AutoCompleteMatches = null;
childContext.Column = 0;
childContext.Row = 0;
foreach(var kv in template) {
switch(kv.Key.AssertString("key").Value) {
case "resources":
Expand Down
Loading
Loading