drccrd commented on code in PR #3717:
URL: 
https://github.com/apache/incubator-kie-tools/pull/3717#discussion_r3806221940


##########
packages/drl-vscode-extension/src/fileGrouping.ts:
##########
@@ -0,0 +1,355 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import * as vscode from "vscode";
+import { LanguageClient } from "vscode-languageclient/node";
+
+/**
+ * Shows which group of DRL files the open document compiles with, and lets the
+ * user pin it to a different one.
+ *
+ * The group map comes from the server (`drools/fileGroups`) rather than being
+ * re-derived here. The server already reads kmodule descriptors, the
+ * `drl-lsp-kbases.json` config and any manifests it adopts; parsing those a
+ * second time in the client would only create a second thing to keep correct.
+ */
+
+type Logger = {
+  info: (msg: string) => void;
+  error: (msg: string) => void;
+};
+
+/**
+ * One group as the server reports it. `kind` is set only when the server can 
be
+ * more specific than "group" — "KIE base" for a group read from a kmodule.xml 
—
+ * so a project that never declared a kmodule is never shown kmodule 
vocabulary.
+ */
+type FileGroup = {
+  /** Normalized paths, for membership tests. */
+  files: string[];
+  kind?: string;
+  /** The file that declared the group, for answering "why is this file 
here?". */
+  declaredIn?: string;
+};
+
+/** Group name to what the server last reported for it. */
+let groups = new Map<string, FileGroup>();
+/** Document fsPath to the group the user pinned it to. Persisted per 
workspace. */
+let overrides = new Map<string, string>();
+let statusItem: vscode.StatusBarItem | undefined;
+let log: Logger = { info: () => undefined, error: () => undefined };
+
+const OVERRIDES_STATE_KEY = "drools.fileGroupOverrides";
+const CONFIG_FILE_GLOB = "**/{drl-lsp-kbases.json,kmodule.xml}";

Review Comment:
   Added code comment in 
[b547731](https://github.com/apache/incubator-kie-tools/pull/3717/commits/b54773184018ca0b4643f40cdc0caf975154446b)



-- 
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]

Reply via email to