Skip to content

Commit

Permalink
clean up comment out code
Browse files Browse the repository at this point in the history
  • Loading branch information
tg123 committed Apr 10, 2024
1 parent 9ce636d commit 2526fc8
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 410 deletions.
59 changes: 1 addition & 58 deletions src/LibKubernetesGenerator/GeneralNameHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace LibKubernetesGenerator
{
internal class GeneralNameHelper: IScriptObjectHelper
internal class GeneralNameHelper : IScriptObjectHelper
{
private readonly ClassNameHelper classNameHelper;

Expand All @@ -18,13 +18,6 @@ public GeneralNameHelper(ClassNameHelper classNameHelper)
this.classNameHelper = classNameHelper;
}

// public void RegisterHelper()
// {
// Helpers.Register(nameof(GetInterfaceName), GetInterfaceName);
// Helpers.Register(nameof(GetMethodName), GetMethodName);
// Helpers.Register(nameof(GetDotNetName), GetDotNetName);
// }

public void RegisterHelper(ScriptObject scriptObject)
{
scriptObject.Import(nameof(GetInterfaceName), new Func<JsonSchema, string>(GetInterfaceName));
Expand All @@ -33,16 +26,6 @@ public void RegisterHelper(ScriptObject scriptObject)
scriptObject.Import(nameof(GetDotNetNameOpenApiParameter), new Func<OpenApiParameter, string, string>(GetDotNetNameOpenApiParameter));
}


//public void GetInterfaceName(RenderContext context, IList<object> arguments,
// IDictionary<string, object> options, RenderBlock fn, RenderBlock inverse)
//{
// if (arguments != null && arguments.Count > 0 && arguments[0] != null && arguments[0] is JsonSchema)
// {
// context.Write(GetInterfaceName(arguments[0] as JsonSchema));
// }
//}

private string GetInterfaceName(JsonSchema definition)
{
var interfaces = new List<string>();
Expand Down Expand Up @@ -78,46 +61,6 @@ private string GetInterfaceName(JsonSchema definition)
return string.Join(", ", interfaces);
}

//public void GetMethodName(RenderContext context, IList<object> arguments, IDictionary<string, object> options,
// RenderBlock fn, RenderBlock inverse)
//{
// if (arguments != null && arguments.Count > 0 && arguments[0] != null && arguments[0] is OpenApiOperation)
// {
// string suffix = null;
// if (arguments.Count > 1)
// {
// suffix = arguments[1] as string;
// }

// context.Write(GetMethodName(arguments[0] as OpenApiOperation, suffix));
// }
//}

//public void GetDotNetName(RenderContext context, IList<object> arguments, IDictionary<string, object> options,
// RenderBlock fn, RenderBlock inverse)
//{
// if (arguments != null && arguments.Count > 0 && arguments[0] != null && arguments[0] is OpenApiParameter)
// {
// var parameter = arguments[0] as OpenApiParameter;
// context.Write(GetDotNetName(parameter.Name));

// if (arguments.Count > 1 && (arguments[1] as string) == "true" && !parameter.IsRequired)
// {
// context.Write(" = null");
// }
// }
// else if (arguments != null && arguments.Count > 0 && arguments[0] != null && arguments[0] is string)
// {
// var style = "parameter";
// if (arguments.Count > 1)
// {
// style = arguments[1] as string;
// }

// context.Write(GetDotNetName((string)arguments[0], style));
// }
//}

public string GetDotNetNameOpenApiParameter(OpenApiParameter parameter, string init)
{
var name = GetDotNetName(parameter.Name);
Expand Down
5 changes: 0 additions & 5 deletions src/LibKubernetesGenerator/GeneratorExecutionContextExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ namespace LibKubernetesGenerator
{
internal static class GeneratorExecutionContextExt
{
public static void RenderToContext(this IncrementalGeneratorPostInitializationContext context, string templatefile, object sc, string generatedfile)
{
// TODO remove
}

public static void RenderToContext(this IncrementalGeneratorPostInitializationContext context, string templatefile, ScriptObject sc, string generatedfile)
{
var tc = new TemplateContext();
Expand Down
6 changes: 3 additions & 3 deletions src/LibKubernetesGenerator/KubernetesClientSourceGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ public void Initialize(IncrementalGeneratorInitializationContext generatorContex
container.Resolve<VersionGenerator>().Generate(swagger, ctx);
container.Resolve<ModelGenerator>().Generate(swagger, ctx);
container.Resolve<ModelExtGenerator>().Generate(swagger, ctx);
container.Resolve<VersionConverterStubGenerator>().Generate(swagger, ctx);
container.Resolve<ApiGenerator>().Generate(swagger, ctx);
container.Resolve<ModelExtGenerator>().Generate(swagger, ctx);
container.Resolve<VersionConverterStubGenerator>().Generate(swagger, ctx);
container.Resolve<ApiGenerator>().Generate(swagger, ctx);
}
});
#endif
Expand Down
95 changes: 0 additions & 95 deletions src/LibKubernetesGenerator/ParamHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@ public ParamHelper(GeneralNameHelper generalNameHelper, TypeHelper typeHelper)
this.typeHelper = typeHelper;
}

//public void RegisterHelper()
//{
// //Helpers.Register(nameof(IfParamContains), IfParamContains);
// //Helpers.Register(nameof(IfParamDoesNotContain), IfParamDoesNotContain);
// Helpers.Register(nameof(GetModelCtorParam), GetModelCtorParam);
//}

public void RegisterHelper(ScriptObject scriptObject)
{
scriptObject.Import(nameof(GetModelCtorParam), new Func<JsonSchema, string>(GetModelCtorParam));
Expand All @@ -46,94 +39,6 @@ public static bool IfParamContains(OpenApiOperation operation, string name)
return found;
}



//public static void IfParamContains(RenderContext context, IList<object> arguments,
// IDictionary<string, object> options,
// RenderBlock fn, RenderBlock inverse)
//{
// var operation = arguments?.FirstOrDefault() as OpenApiOperation;
// if (operation != null)
// {
// string name = null;
// if (arguments.Count > 1)
// {
// name = arguments[1] as string;
// }

// var found = false;

// foreach (var param in operation.Parameters)
// {
// if (param.Name == name)
// {
// found = true;
// break;
// }
// }

// if (found)
// {
// fn(null);
// }
// }
//}

//public static void IfParamDoesNotContain(RenderContext context, IList<object> arguments,
// IDictionary<string, object> options,
// RenderBlock fn, RenderBlock inverse)
//{
// var operation = arguments?.FirstOrDefault() as OpenApiOperation;
// if (operation != null)
// {
// string name = null;
// if (arguments.Count > 1)
// {
// name = arguments[1] as string;
// }

// var found = false;

// foreach (var param in operation.Parameters)
// {
// if (param.Name == name)
// {
// found = true;
// break;
// }
// }

// if (!found)
// {
// fn(null);
// }
// }
//}

//public void GetModelCtorParam(RenderContext context, IList<object> arguments,
// IDictionary<string, object> options,
// RenderBlock fn, RenderBlock inverse)
//{
// var schema = arguments[0] as JsonSchema;

// if (schema != null)
// {
// context.Write(string.Join(", ", schema.Properties.Values
// .OrderBy(p => !p.IsRequired)
// .Select(p =>
// {
// var sp =
// $"{typeHelper.GetDotNetType(p)} {generalNameHelper.GetDotNetName(p.Name, "fieldctor")}";

// if (!p.IsRequired)
// {
// sp = $"{sp} = null";
// }

// return sp;
// })));
// }
//}
public string GetModelCtorParam(JsonSchema schema)
{
return string.Join(", ", schema.Properties.Values
Expand Down
23 changes: 0 additions & 23 deletions src/LibKubernetesGenerator/PluralHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,11 @@ public PluralHelper(ClassNameHelper classNameHelper, OpenApiDocument swagger)
_classNameToPluralMap = InitClassNameToPluralMap(swagger);
}

//public void RegisterHelper()
//{
// Helpers.Register(nameof(GetPlural), GetPlural);
//}

public void RegisterHelper(ScriptObject scriptObject)
{
scriptObject.Import(nameof(GetPlural), new Func<JsonSchema, string>(GetPlural));
}


//public void GetPlural(RenderContext context, IList<object> arguments, IDictionary<string, object> options,
// RenderBlock fn, RenderBlock inverse)
//{
// if (arguments != null && arguments.Count > 0 && arguments[0] != null && arguments[0] is JsonSchema)
// {
// var plural = GetPlural(arguments[0] as JsonSchema);
// if (plural != null)
// {
// context.Write($"\"{plural}\"");
// }
// else
// {
// context.Write("null");
// }
// }
//}

public string GetPlural(JsonSchema definition)
{
var className = classNameHelper.GetClassNameForSchemaDefinition(definition);
Expand Down
61 changes: 1 addition & 60 deletions src/LibKubernetesGenerator/StringHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,52 +19,13 @@ public StringHelpers(GeneralNameHelper generalNameHelper)
this.generalNameHelper = generalNameHelper;
}

//public void RegisterHelper()
//{
// Helpers.Register(nameof(ToXmlDoc), ToXmlDoc);
// Helpers.Register(nameof(ToInterpolationPathString), ToInterpolationPathString);
// Helpers.Register(nameof(IfGroupPathParamContainsGroup), IfGroupPathParamContainsGroup);
//}


public void RegisterHelper(ScriptObject scriptObject)
{
scriptObject.Import(nameof(ToXmlDoc), new Func<string, string>(ToXmlDoc));
scriptObject.Import(nameof(ToInterpolationPathString), ToInterpolationPathString);
scriptObject.Import(nameof(IfGroupPathParamContainsGroup), IfGroupPathParamContainsGroup);
}


//private void ToXmlDoc(RenderContext context, IList<object> arguments, IDictionary<string, object> options,
// RenderBlock fn, RenderBlock inverse)
//{
// if (arguments != null && arguments.Count > 0 && arguments[0] != null && arguments[0] is string)
// {
// var first = true;

// using (var reader = new StringReader(arguments[0] as string))
// {
// string line = null;
// while ((line = reader.ReadLine()) != null)
// {
// foreach (var wline in WordWrap(line, 80))
// {
// if (!first)
// {
// context.Write("\n");
// context.Write(" /// ");
// }
// else
// {
// first = false;
// }

// context.Write(SecurityElement.Escape(wline));
// }
// }
// }
// }
//}
public static string ToXmlDoc(string arg)
{
if (arg == null)
Expand Down Expand Up @@ -135,34 +96,14 @@ private static IEnumerable<string> WordWrap(string text, int width)
}
}

//public void ToInterpolationPathString(RenderContext context, IList<object> arguments, IDictionary<string, object> options,
// RenderBlock fn, RenderBlock inverse)
//{
// var p = arguments?.FirstOrDefault() as string;
// if (p != null)
// {
// context.Write(Regex.Replace(p, "{(.+?)}", (m) => "{" + generalNameHelper.GetDotNetName(m.Groups[1].Value) + "}"));
// }
//}

public string ToInterpolationPathString(string arg)
{
return Regex.Replace(arg, "{(.+?)}", (m) => "{" + generalNameHelper.GetDotNetName(m.Groups[1].Value) + "}");
}
}

public static bool IfGroupPathParamContainsGroup(string arg)
{
return arg.StartsWith("apis/{group}");
}

//public void IfGroupPathParamContainsGroup(RenderContext context, IList<object> arguments, IDictionary<string, object> options,
// RenderBlock fn, RenderBlock inverse)
//{
// var p = arguments?.FirstOrDefault() as string;
// if (p?.StartsWith("apis/{group}") == true)
// {
// fn(null);
// }
//}
}
}
Loading

0 comments on commit 2526fc8

Please sign in to comment.