Ondrej-Douda commented on code in PR #6079:
URL: https://github.com/apache/netbeans/pull/6079#discussion_r1234252282


##########
java/java.lsp.server/vscode/src/propertiesView/controlTypes.ts:
##########
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Licensed under the Universal Permissive License v 1.0 as shown at 
https://oss.oracle.com/licenses/upl.
+ */
+import { EnumType, KeyOfArray, Typed } from "../typesUtil";
+
+export type ID = number;
+
+export const PropTypes: KeyOfArray<PropTypeMap> = [
+    "java.lang.String",
+    "java.lang.Boolean",
+    "java.util.Properties",
+    "unknown"
+];// unfortunate but necessary duplication
+export type PropTypeMap = {
+    "java.lang.String": string;
+    "java.lang.Boolean": boolean;
+    "java.util.Properties": Record<string, string>;
+    "unknown": unknown
+};
+export type Property<T extends keyof PropTypeMap = keyof PropTypeMap> = T 
extends T ? {
+    propPref: boolean;
+    propDispName: string;
+    propShortName: string;
+    propWrite: boolean;
+    propHidden: boolean;
+    propExpert: boolean;
+    propType: T;
+    propValue: PropTypeMap[T];
+    propName: string;
+} : never; // Distributive type
+export type Properties = {
+    propPref: boolean;
+    propDispName: string;
+    propShortName: string;
+    propHidden: boolean;
+    propExpert: boolean;
+    propName: string;
+    props: Property[];
+};
+
+export type MessageProp = {
+    name: string;
+    value: string | boolean | Record<string, string>;
+};
+
+export type Command = "Save" | "Cancel" | "Error" | "Info";

Review Comment:
   The code is made so it is imperative to be complete...
   The Value of 'enum' has to be exactly the same as the Key and has to contain 
all of Type union and nothing more...
   Found no other way of achieving this behavior...



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to