Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
490994dbab | ||
|
|
16608cb994 | ||
|
|
250ec0c227 | ||
|
|
f78b4836f9 | ||
|
|
3fbe4f9243 | ||
|
|
5a020f7d07 | ||
|
|
cf6a39b51d | ||
|
|
b264f20baf | ||
|
|
4ef697190a | ||
|
|
896e9f6c1f | ||
|
|
52a2b2f774 | ||
|
|
ee5240c861 | ||
|
|
61fb0bc5d2 | ||
|
|
95ddae6d13 | ||
|
|
a6f616a89d | ||
|
|
632fc32c3e | ||
|
|
9c5b76510d | ||
|
|
1b6b25c137 | ||
|
|
e84a08e22b | ||
|
|
1070429039 | ||
|
|
b17a4f8ba0 | ||
|
|
65732ffac8 |
@@ -78,7 +78,8 @@ export async function getWorkspaceSettings(
|
||||
path: resolveVariables(config.get<string[]>(`path`) ?? [], workspace),
|
||||
interpreter: resolveVariables(interpreter, workspace),
|
||||
importStrategy: config.get<string>(`importStrategy`) ?? "useBundled",
|
||||
showNotifications: config.get<string>(`showNotifications`) ?? "off"
|
||||
showNotifications: config.get<string>(`showNotifications`) ?? "off",
|
||||
formatter: config.get<boolean>(`formatter`) ?? true
|
||||
}
|
||||
return workspaceSetting
|
||||
}
|
||||
@@ -109,7 +110,8 @@ export async function getGlobalSettings(
|
||||
path: getGlobalValue<string[]>(config, "path", []),
|
||||
interpreter: interpreter,
|
||||
importStrategy: getGlobalValue<string>(config, "importStrategy", "useBundled"),
|
||||
showNotifications: getGlobalValue<string>(config, "showNotifications", "off")
|
||||
showNotifications: getGlobalValue<string>(config, "showNotifications", "off"),
|
||||
formatter: config.get<boolean>(`formatter`) ?? true
|
||||
}
|
||||
return setting
|
||||
}
|
||||
@@ -123,7 +125,8 @@ export function checkIfConfigurationChanged(
|
||||
`${namespace}.path`,
|
||||
`${namespace}.interpreter`,
|
||||
`${namespace}.importStrategy`,
|
||||
`${namespace}.showNotifications`
|
||||
`${namespace}.showNotifications`,
|
||||
`${namespace}.formatter`
|
||||
]
|
||||
const changed = settings.map((s) => e.affectsConfiguration(s))
|
||||
return changed.includes(true)
|
||||
|
||||
+6
-1
@@ -2,7 +2,7 @@
|
||||
"name": "nx-post-support",
|
||||
"displayName": "NX Postprocessor Support",
|
||||
"description": "",
|
||||
"version": "0.4.2",
|
||||
"version": "0.4.8",
|
||||
"publisher": "Christoph",
|
||||
"serverInfo": {
|
||||
"name": "NX Postprocessor Support",
|
||||
@@ -79,6 +79,11 @@
|
||||
],
|
||||
"configuration": {
|
||||
"properties": {
|
||||
"nx-post-support.formatter": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Use the TCL formatter from `NX Postprocessor Support`"
|
||||
},
|
||||
"nx-post-support.importStrategy": {
|
||||
"default": "useBundled",
|
||||
"description": "Defines where `NX Postprocessor Support` is imported from.",
|
||||
|
||||
@@ -4,6 +4,22 @@
|
||||
"label": "proc",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"label": "array",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"label": "lappend",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"label": "string",
|
||||
"kind": "function"
|
||||
},
|
||||
{
|
||||
"label": "switch",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"label": "if",
|
||||
"kind": "keyword"
|
||||
@@ -19,6 +35,14 @@
|
||||
{
|
||||
"label": "puts",
|
||||
"kind": "function"
|
||||
},
|
||||
{
|
||||
"label": "set",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"label": "namespace",
|
||||
"kind": "keyword"
|
||||
}
|
||||
],
|
||||
"MOM_procs": [
|
||||
@@ -234,18 +258,358 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "MOM_ask_ude_info",
|
||||
"label": "MOM_ask_ess_exp_value",
|
||||
"kind": "function",
|
||||
"description": "This command is used to retrieve the information about a user-defined event (UDE) of a specified object.",
|
||||
"format": "MOM_ask_ude_info object_name object_type <Start/End/\"\">",
|
||||
"description": "This function provides access to the variables of the NX Expression module. The NX Expression module allows users to define variables and expressions to use as parameters for NX entities such as modeling features.",
|
||||
"format": "MOM_ask_ess_exp_value <variable_name>",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "Object_name",
|
||||
"desc": "The name of the object to which the UDE is attached. It can be a group, an operation, a tool, a geometry, or a method."
|
||||
"name": "variable_name",
|
||||
"desc": "Name of the NX Expression variable."
|
||||
}
|
||||
],
|
||||
"returns": [
|
||||
"Value of the NX Expression variable."
|
||||
],
|
||||
"example": [
|
||||
"MOM_ask_ess_exp_value diameter"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "object_type",
|
||||
"desc": "The type of the object to which the UDE is attached. The following types are available.(group || operation/oper || tool || geometry/geom || method/meth)"
|
||||
"label": "MOM_ask_event_type",
|
||||
"kind": "function",
|
||||
"description": "This procedure returns the name of the current event. This is the last event that the event generator executed.",
|
||||
"format": "MOM_ask_event_type",
|
||||
"parameters": [],
|
||||
"returns": [
|
||||
"Name of current event."
|
||||
],
|
||||
"example": [
|
||||
"set event [MOM_ask_event_type]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "MOM_ask_group_info",
|
||||
"kind": "function",
|
||||
"description": "This command retrieves group information in a CAM setup from the operation navigator views for the specified operation or group name. Returns an integer value (-1, 0, or 1) and stores the result in the variables mom_result and mom_result1.",
|
||||
"format": "MOM_ask_group_info <node_name> <view> <parent|children>",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "node_name",
|
||||
"desc": "Operation or group name."
|
||||
},
|
||||
{
|
||||
"name": "view",
|
||||
"desc": "View in the operation navigator (ONT). (program|prog, tool, geometry|geom, method|meth)"
|
||||
},
|
||||
{
|
||||
"name": "parent|children",
|
||||
"desc": "Type of node."
|
||||
}
|
||||
],
|
||||
"returns": [
|
||||
"-1: Query failed, or the node does not exist.",
|
||||
"0: Current node is root node, or no child node.",
|
||||
"1: Get current group information."
|
||||
],
|
||||
"example": [
|
||||
"MOM_ask_group_info UGT0361_019 tool children",
|
||||
"mom_result(0) = CHAMFER_S1H_CSINK",
|
||||
"mom_result(1) = CHAMFER_S1H_CSINK1",
|
||||
"mom_result1(CHAMFER_S1H_CSINK) = Drilling",
|
||||
"mom_result1(CHAMFER_S1H_CSINK1) = Drilling",
|
||||
"MOM_ask_group_info CHAMFER_S1H_CSINK tool parent",
|
||||
"mom_result = UGT0361_019",
|
||||
"mom_result1 = Countersink"
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "MOM_ask_init_junction_xform",
|
||||
"kind": "function",
|
||||
"description": "This command returns the transformation matrix of the junction at its initial state with respect to the absolute coordinate system (ACS). It passes the results to mom_sim_result (matrix: list of 9) and mom_sim_result1 (origin: list of 3).",
|
||||
"format": "MOM_ask_init_junction_xform <junction_name>",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "junction_name",
|
||||
"desc": "Name of junction."
|
||||
}
|
||||
],
|
||||
"example": []
|
||||
},
|
||||
{
|
||||
"label": "MOM_ask_library_attributes",
|
||||
"kind": "function",
|
||||
"description": "This function retrieves attributes for an item from the specified library.",
|
||||
"format": "MOM_ask_library_attributes <library_key> <libref> <db_alias>+",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "library_key",
|
||||
"desc": "The entry in the CAM configuration file for the desired library."
|
||||
},
|
||||
{
|
||||
"name": "libref",
|
||||
"desc": "Unique identifier of specified item in the library."
|
||||
},
|
||||
{
|
||||
"name": "db_alias",
|
||||
"desc": "The db_alias names are found in the definition file for that library. There can be a list of more than one name."
|
||||
}
|
||||
],
|
||||
"returns": [
|
||||
"The returned values are placed in the array mom_lib_attr_value."
|
||||
],
|
||||
"example": [
|
||||
"global mom_lib_attr_value mom_libref",
|
||||
"MOM_ask_library_attributes LIBRARY_TOOL $mom_libref Type SubType",
|
||||
"MOM_output_literal \"Type = $mom_lib_attr_value(Type)\"",
|
||||
"MOM_output_literal \"SubType = $mom_lib_attr_value(SubType)\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "MOM_ask_machine_zero_junction_name",
|
||||
"kind": "function",
|
||||
"description": "This command returns the name of the MACHINE_ZERO junction.",
|
||||
"format": "MOM_ask_machine_zero_junction_name",
|
||||
"parameters": [],
|
||||
"returns": [
|
||||
"Name of the MACHINE_ZERO junction."
|
||||
],
|
||||
"example": [
|
||||
"set jct_name [MOM_ask_machine_zero_junction_name]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "MOM_ask_oper_csys",
|
||||
"kind": "function",
|
||||
"description": "Fetches the coordinate system (CSYS) information of the named operation. The command passes the results in three MOM variables mom_result, mom_result1, and mom_result2.",
|
||||
"format": "MOM_ask_oper_csys <operation_name>",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "operation_name",
|
||||
"desc": "Name of the operation."
|
||||
}
|
||||
],
|
||||
"returns": [
|
||||
"mom_result is the Special Purpose setting of the MCS.\n0 = None\n1 = Use Main MCS\n2 = Fixture Offset\n3 = CSYS Rotation",
|
||||
"`mom_result1` is a list of 12 double precision values defining the mom_csys_matrix of the operation.",
|
||||
"`mom_result2` is a list of 12 double precision values defining the `mom_machine_csys_matrix` of the operation."
|
||||
],
|
||||
"example": [
|
||||
"set jct_name [MOM_ask_machine_zero_junction_name]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "MOM_ask_oper_info",
|
||||
"kind": "function",
|
||||
"description": "Retrieves operation information at the start of a program and stores the result in the array variable `mom_operation_info`. Called from Post Configurator procedure `MOM_start_of_path_LIB`.",
|
||||
"format": "MOM_ask_oper_info <opr_list>",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "opr_list",
|
||||
"desc": "List of operations."
|
||||
}
|
||||
],
|
||||
"example": [
|
||||
"set opr_list \"PLANER_MILL FACE_MILLING1 GENERIC_MOTION1\"",
|
||||
"MOM_ask_oper_info opr_list"
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "MOM_ask_oper_nc_axes_info",
|
||||
"kind": "function",
|
||||
"description": "This command is used to get all the nc axis names in a kinematic chain from the workpiece to the device. A workpiece and tool (device) are attached to each operation. The results for linear axis names are saved in the array variable `mom_result`, and the rotary axis names are stored in the array variable `mom_result1`.",
|
||||
"format": "MOM_ask_oper_nc_axes_info <operation_name>",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "operation_name",
|
||||
"desc": "Name of the operation."
|
||||
}
|
||||
],
|
||||
"example": [
|
||||
"set opr_name FACE_MILL_FLOOR",
|
||||
"MOM_ask_oper_nc_axes_info $opr_name"
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "MOM_ask_oper_tool_path_type",
|
||||
"kind": "function",
|
||||
"description": "This command is used to retrieve the tool path type for a specific operation or optimized group.",
|
||||
"format": "MOM_ask_oper_tool_path_type <opr_name>",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "opr_name",
|
||||
"desc": "Name of the operation or optimized group from which the tool path type is to be retrieved."
|
||||
}
|
||||
],
|
||||
"returns": [
|
||||
"`mom_sys_tool_path_type(oper_name)` The parameter contains the tool path type for the specified operation or optimized group. The possible values are:",
|
||||
" NO_MOVE—Indicates no movement in the tool path.",
|
||||
" NO_CUT—Indicates no cutting motion in the tool path.",
|
||||
" FIXED_AXIS—Indicates tool axis is fixed throughout the cutting motions.",
|
||||
" POSITIONING—Indicates tool axis changes in the non-cutting motion. However, the tool axis is fixed in all cutting motions.",
|
||||
" MULTI_PLANES—Indicates tool axis does not have continuous changes in the cutting motions.",
|
||||
" SIMULTANEOUS—Indicates simultaneous tool motions in the tool path.",
|
||||
"`mom_init_tool_axis` - The parameter contains tool axis vector of the first motion in the specified operation.",
|
||||
"0 - The command execution failed.",
|
||||
"1 - The command executed successfully."
|
||||
],
|
||||
"example": [
|
||||
"set opr_name FACE_MILL_FLOOR",
|
||||
"MOM_ask_oper_nc_axes_info $opr_name"
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "MOM_ask_part_units",
|
||||
"kind": "function",
|
||||
"description": "This command sets the units of the current work part in a variable `mom_part_units`.",
|
||||
"format": "MOM_ask_part_units",
|
||||
"parameters": [],
|
||||
"returns": [
|
||||
"The possible values for mom_part_units are \"metric\" or \"english\"."
|
||||
],
|
||||
"example": [
|
||||
"global mom_part_units",
|
||||
"MOM_ask_part_units",
|
||||
"set part_units $mom_part_units"
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "MOM_ask_syslog_name",
|
||||
"kind": "function",
|
||||
"description": "This command returns the name of syslog file of current session.",
|
||||
"format": "MOM_ask_syslog_name",
|
||||
"parameters": [],
|
||||
"returns": [
|
||||
"String."
|
||||
],
|
||||
"example": [
|
||||
"set syslog [MOM_ask_syslog_name]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "MOM_cancel_suppress_force_once_per_event",
|
||||
"kind": "function",
|
||||
"description": "Resets the state of the `MOM_force` and `MOM_suppress` commands that use the Once option at the end of each event.",
|
||||
"format": "MOM_cancel_suppress_force_once_per_event <On|Off>",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "On|Off",
|
||||
"desc": "Turn the Once option for `MOM_force` and `MOM_suppress` commands on or off."
|
||||
}
|
||||
],
|
||||
"returns": [
|
||||
"1 - On",
|
||||
"0 - Off"
|
||||
],
|
||||
"example": []
|
||||
},
|
||||
{
|
||||
"label": "MOM_check_out_license",
|
||||
"kind": "function",
|
||||
"description": "Obtains Flexlm license until the end of the posting job. Returns 1 (true) for success or 0 (false) for failure.",
|
||||
"format": "MOM_check_out_license <license>",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "license",
|
||||
"desc": "String name of a valid license."
|
||||
}
|
||||
],
|
||||
"returns": [
|
||||
"1 - True",
|
||||
"0 - False"
|
||||
],
|
||||
"example": []
|
||||
},
|
||||
{
|
||||
"label": "MOM_close_output_file",
|
||||
"kind": "function",
|
||||
"description": "This procedure allows you to suspend writing output to a particular file until it is opened again.",
|
||||
"format": "MOM_close_output_file <filename>",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "filename",
|
||||
"desc": "Name of output file."
|
||||
}
|
||||
],
|
||||
"example": [
|
||||
"# Example 1",
|
||||
"MOM_close_output_file $mom_output_doc_file2"
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "MOM_convert_point",
|
||||
"kind": "function",
|
||||
"description": "Converts a point from a tool path position to an MCS position in machine tool coordinates.",
|
||||
"format": "MOM_convert_point <point> <vector>",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "point",
|
||||
"desc": "Array variable of three values defining tool path position."
|
||||
},
|
||||
{
|
||||
"name": "vector",
|
||||
"desc": "Array variable of three values defining vector of tool axis."
|
||||
}
|
||||
],
|
||||
"returns": [
|
||||
"Returns pimary and alternate solutions as TCL lists of X, Y, Z, 4th, and 5th axes in the variables `mom_post_result` for the primary and `mom_post_result1` for the alternate."
|
||||
],
|
||||
"example": []
|
||||
},
|
||||
{
|
||||
"label": "MOM_disable_address",
|
||||
"kind": "function",
|
||||
"description": "Suppresses all output for an address. The commands `MOM_force` ONCE and `MOM_force` ALWAYS are ignored while `MOM_disable_address` is active. `MOM_enable_address` cancels `MOM_disable_address`.",
|
||||
"format": "MOM_disable_address <address>",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "address",
|
||||
"desc": "Name of output address."
|
||||
}
|
||||
],
|
||||
"example": []
|
||||
},
|
||||
{
|
||||
"label": "MOM_display_message",
|
||||
"kind": "function",
|
||||
"description": "Displays a message dialog box in NX.",
|
||||
"format": "MOM_display_message <message> <title> <type> [<button1>] [<button2>] [<button3>]",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "message",
|
||||
"desc": "Text string for message."
|
||||
},
|
||||
{
|
||||
"name": "title",
|
||||
"desc": "Text string for title."
|
||||
},
|
||||
{
|
||||
"name": "type",
|
||||
"desc": "Style of the message box, I|E|W|Q, where I is info, E is error, W is warning, and Q is question."
|
||||
},
|
||||
{
|
||||
"name": "button1, button2, button3",
|
||||
"desc": "Optional. Text string for button label."
|
||||
}
|
||||
],
|
||||
"returns": [
|
||||
"Returns the number of the button (1, 2, or 3) that the user clicks. Displays OK button if no label specified, and returns 1."
|
||||
],
|
||||
"example": []
|
||||
},
|
||||
{
|
||||
"label": "MOM_do_template",
|
||||
"kind": "function",
|
||||
"description": "This procedure generates output based upon the block template.",
|
||||
"format": "MOM_do_template <template_name> [BUFFER|CREATE]",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "template",
|
||||
"desc": "Name of block template."
|
||||
},
|
||||
{
|
||||
"name": "BUFFER|CREATE",
|
||||
"desc": "Optional. `BUFFER` has the usual meaning and generates the value for the block template and adds it to the output buffer. It does not send the value to the output file yet. `CREATE` generates the value for the block template but does not output to the output buffer, and hence, does not output it to the output file."
|
||||
},
|
||||
{
|
||||
"name": "Start/End/\"\"",
|
||||
@@ -253,10 +617,128 @@
|
||||
}
|
||||
],
|
||||
"returns": [
|
||||
"0 - The UDE information retrieval failed.",
|
||||
"1 - The UDE information successfully retrieved."
|
||||
"String"
|
||||
],
|
||||
"example": [
|
||||
"# Example 1",
|
||||
"MOM_do_template linear_move"
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "MOM_do_template_file",
|
||||
"kind": "function",
|
||||
"description": "This command opens the specified Shop Documentation template file and executes each line in the file accordingly.",
|
||||
"format": "MOM_do_template_file <template_file>",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "template_file",
|
||||
"desc": "Shop Documentation template file name (.tpl)."
|
||||
}
|
||||
],
|
||||
"example": [
|
||||
"# Example 1",
|
||||
"MOM_do_template_file tool_list.tpl"
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "MOM_enable_address",
|
||||
"kind": "function",
|
||||
"description": "Restores output status for an address that MOM_disable_address suppressed.",
|
||||
"format": "MOM_enable_address <address>",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "address",
|
||||
"desc": "Name of address."
|
||||
}
|
||||
],
|
||||
"returns": [
|
||||
"Returns output status to the initial state."
|
||||
],
|
||||
"example": []
|
||||
},
|
||||
{
|
||||
"label": "MOM_force",
|
||||
"kind": "function",
|
||||
"description": "This procedure sets the modality of the address.",
|
||||
"format": "MOM_force <Always|Once|Off> <address_1 ... address_n>",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "Always|Once|Off",
|
||||
"desc": "Always - Sets the address to be to be non-modal (always output).\nOnce - The next time that a block template that contains a reference to any of the input address names is evaluated, the word that contains that address is not output regardless of its modality attribute. If both `MOM_force` Once and `MOM_suppress` Once are programmed, the last one will take effect. If `MOM_suppress` Always is programmed, the address is never output. All MOM_force Once and `MOM_suppress` Once commands are ignored.\nff - Sets the address to be to be modal (output only if value changes)."
|
||||
},
|
||||
{
|
||||
"name": "address_1 ... address_n",
|
||||
"desc": "Name of output address(es)."
|
||||
}
|
||||
],
|
||||
"example": [
|
||||
"# Example 1",
|
||||
"MOM_force Once \"X\" \"Y\" \"Z\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "MOM_force_block",
|
||||
"kind": "function",
|
||||
"description": "Same as `MOM_force` for entire block insead of single address.",
|
||||
"format": "MOM_force_block <Always|Once|Off> <block_1 ... block_n>",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "Always|Once|Off",
|
||||
"desc": "`Always` - Sets the block to be to be non-modal (always output). `Once` - The next time that a block template is evaluated, the block is output regardless of its modality attribute. `Off` - Sets the block to be to be modal (output only if value changes)."
|
||||
},
|
||||
{
|
||||
"name": "block_1 ... block_n",
|
||||
"desc": "Name of output block(s)."
|
||||
}
|
||||
],
|
||||
"example": [
|
||||
"# Example 1",
|
||||
"MOM_force_block \"Once\" \"linear_move\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "MOM_source",
|
||||
"kind": "function",
|
||||
"description": "Allows you to specify TCL files to be included as a source of commands and data during postprocessing.",
|
||||
"format": "MOM_source <filename>+",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "filename(s)",
|
||||
"desc": "Name of TCL file(s) to be included at runtime."
|
||||
}
|
||||
],
|
||||
"example": [
|
||||
"MOM_source my_header.tcl"
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "MOM_suppress",
|
||||
"kind": "function",
|
||||
"description": "The next time that a block template that contains a reference to any of the input address names is evaluated, the word that contains the address is not be output regardless of its modality attribute.",
|
||||
"format": "MOM_suppress <Always|Once|Off> <address_1 ... address_n>",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "Always|Once|Off",
|
||||
"desc": "Always - Sets the address to be to be non-modal (always output).\nOnce - The next time that a block template that contains a reference to any of the input address names is evaluated, the word that contains that address is not output regardless of its modality attribute. If both MOM_force Once and MOM_suppress Once are programmed, the last one will take effect. If MOM_suppress Always is programmed, the address is never output. All MOM_force Once and MOM_suppress Once commands are ignored.\nff - Sets the address to be to be modal (output only if value changes)."
|
||||
},
|
||||
{
|
||||
"name": "address_1 ... address_n",
|
||||
"desc": "Name of output address(es)."
|
||||
}
|
||||
],
|
||||
"example": [
|
||||
"MOM_suppress_address Always N X Y"
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "MOM_update_kinematics",
|
||||
"kind": "function",
|
||||
"description": "Maps the following legacy kinematics variables to the current kinematics variables, and is required after specifying them: mom_kin_4th_axis_center_offset, mom_kin_5th_axis_center_offset, mom_kin_pivot_gauge_offset.",
|
||||
"format": "MOM_update_kinematics",
|
||||
"parameters": [],
|
||||
"example": [
|
||||
"MOM_update_kinematics"
|
||||
]
|
||||
}
|
||||
],
|
||||
"mom_variables": [
|
||||
|
||||
@@ -15,43 +15,48 @@ def format_tcl(src: str, indent_str=" ") -> str:
|
||||
for raw_line in src.splitlines():
|
||||
stripped = raw_line.strip()
|
||||
|
||||
# 1) Single-line 'if {cond} {action}' → no indent change
|
||||
# Comments are ignored
|
||||
if stripped.startswith("#"):
|
||||
out_lines.append(indent_str * level + stripped)
|
||||
continue
|
||||
|
||||
# Single-line 'if {cond} {action}' → no indent change
|
||||
if re.match(r"^(if|elseif)\s*\{[^}]+\}\s*\{[^}]+\}$", stripped):
|
||||
out_lines.append(indent_str * level + stripped)
|
||||
continue
|
||||
|
||||
# 2) Combined '} else {' → dedent, print, then indent
|
||||
# Combined '} else {' → dedent, print, then indent
|
||||
if re.match(r"^\}\s*(elseif|else)\b.*\{$", stripped):
|
||||
level = max(level - 1, 0)
|
||||
out_lines.append(indent_str * level + stripped)
|
||||
level += 1
|
||||
continue
|
||||
|
||||
# 3) SPECIAL: closing brace plus tag on same line: '} Tag'
|
||||
m = re.match(r"^\}\s+(\w+)", stripped)
|
||||
if m:
|
||||
# SPECIAL: closing brace plus tag on same line: '} Tag'
|
||||
m = re.match(r"^\}\s+(.+)", stripped)
|
||||
if m and not stripped.startswith("#"):
|
||||
# close one block
|
||||
level = max(level - 1, 0)
|
||||
# stay on one line: "} Tag"
|
||||
out_lines.append(f"{indent_str * level}}} {m.group(1)}")
|
||||
continue
|
||||
|
||||
# 4) Pure '}' → dedent then print
|
||||
# Pure '}' → dedent then print
|
||||
if stripped == "}":
|
||||
level = max(level - 1, 0)
|
||||
out_lines.append(f"{indent_str * level}{stripped}")
|
||||
continue
|
||||
|
||||
# 5) 'elseif' or 'else' alone → align with matching 'if'
|
||||
# 'elseif' or 'else' alone → align with matching 'if'
|
||||
if re.match(r"^(elseif|else)\b(?!.*\{)", stripped):
|
||||
level = max(level - 1, 0)
|
||||
out_lines.append(f"{indent_str * level}{stripped}")
|
||||
continue
|
||||
|
||||
# 6) Default: print at current indent
|
||||
# Default: print at current indent
|
||||
out_lines.append(f"{indent_str * level}{stripped}")
|
||||
|
||||
# 7) Open a new block on lines ending with '{'
|
||||
# Open a new block on lines ending with '{'
|
||||
if re.match(r"^(if|elseif)\b.*\{$", stripped) or stripped.endswith("{"):
|
||||
level += 1
|
||||
|
||||
|
||||
@@ -17,10 +17,15 @@ KIND_MAP = {
|
||||
|
||||
class StandardCompletionItems:
|
||||
def __init__(self):
|
||||
self.__json_data: dict = self.__load_json()
|
||||
self.__tcl_keyword_list = self.__load_tcl_keyword()
|
||||
self.__nx_procs = self.__load_nx_procs()
|
||||
self.__nx_variables = self.__load_nx_variables()
|
||||
|
||||
@property
|
||||
def json_data(self):
|
||||
return self.__json_data
|
||||
|
||||
@property
|
||||
def tcl_keyword_list(self):
|
||||
return self.__tcl_keyword_list
|
||||
@@ -33,11 +38,15 @@ class StandardCompletionItems:
|
||||
def nx_variables(self):
|
||||
return self.__nx_variables
|
||||
|
||||
def __load_tcl_keyword(self) -> list[lsp.CompletionItem]:
|
||||
def __load_json(self) -> dict:
|
||||
with open(
|
||||
pathlib.Path(__file__).parent.joinpath("completion_list.json"), "r"
|
||||
) as f:
|
||||
data = json.load(f)
|
||||
return data
|
||||
|
||||
def __load_tcl_keyword(self) -> list[lsp.CompletionItem]:
|
||||
data = self.json_data
|
||||
|
||||
items = []
|
||||
for i in data.get("tcl", []):
|
||||
@@ -50,10 +59,7 @@ class StandardCompletionItems:
|
||||
return items
|
||||
|
||||
def __load_nx_variables(self):
|
||||
with open(
|
||||
pathlib.Path(__file__).parent.joinpath("completion_list.json"), "r"
|
||||
) as f:
|
||||
data = json.load(f)
|
||||
data = self.json_data
|
||||
items = []
|
||||
for var in data.get("mom_variables", []):
|
||||
label = var.get("label", "")
|
||||
@@ -85,11 +91,7 @@ class StandardCompletionItems:
|
||||
return items
|
||||
|
||||
def __load_nx_procs(self) -> list[lsp.CompletionItem]:
|
||||
with open(
|
||||
pathlib.Path(__file__).parent.joinpath("completion_list.json"), "r"
|
||||
) as f:
|
||||
data = json.load(f)
|
||||
|
||||
data = self.json_data
|
||||
items = []
|
||||
for proc in data.get("MOM_procs", []):
|
||||
label = proc.get("label", "")
|
||||
|
||||
@@ -13,6 +13,7 @@ import sys
|
||||
import sysconfig
|
||||
import traceback
|
||||
from typing import Any, Optional, Sequence
|
||||
import re
|
||||
|
||||
|
||||
# **********************************************************
|
||||
@@ -54,9 +55,6 @@ LSP_SERVER = server.LanguageServer(
|
||||
name="NX Postprocessor Support", version="0.0.1", max_workers=MAX_WORKERS
|
||||
)
|
||||
|
||||
|
||||
NX_PROC_LIST = []
|
||||
|
||||
# **********************************************************
|
||||
# Tool specific code goes below this.
|
||||
# **********************************************************
|
||||
@@ -106,6 +104,72 @@ def on_completion(params: lsp.CompletionParams) -> list[lsp.CompletionItem]:
|
||||
return lsp.CompletionList(is_incomplete=False, items=items)
|
||||
|
||||
|
||||
@LSP_SERVER.feature(lsp.TEXT_DOCUMENT_HOVER)
|
||||
def hover(params: lsp.HoverParams) -> lsp.Hover:
|
||||
pos = params.position
|
||||
document_uri = params.text_document.uri
|
||||
document = LSP_SERVER.workspace.get_text_document(document_uri)
|
||||
col = params.position.character
|
||||
|
||||
try:
|
||||
line = document.lines[pos.line]
|
||||
except IndexError:
|
||||
return None
|
||||
|
||||
for m in re.finditer(r"\b\w+\b", line):
|
||||
if m.start() <= col <= m.end():
|
||||
token = m.group(0)
|
||||
break
|
||||
else:
|
||||
return None
|
||||
|
||||
command = token
|
||||
data = standard_items.json_data
|
||||
|
||||
all_items = data.get("MOM_procs", []) + data.get("mom_variables", [])
|
||||
|
||||
match = next((item for item in all_items if item["label"] == command), None)
|
||||
if not match:
|
||||
return None
|
||||
|
||||
if not match.get("kind") == "function":
|
||||
return None
|
||||
|
||||
label = match.get("label", "")
|
||||
|
||||
parameters = match.get("parameters", [])
|
||||
param_lines = (
|
||||
"\n".join(f"- `{p['name']}`: {p['desc']}" for p in parameters) or "_None_"
|
||||
)
|
||||
|
||||
example_data = match.get("example", [])
|
||||
example_md = "\n".join(f"{line}" for line in example_data)
|
||||
|
||||
returns_data = match.get("returns", ["None"])
|
||||
returns_md = "\n".join(f"- {line}" for line in returns_data)
|
||||
|
||||
doc_md = f"""\
|
||||
### 📘 {label}
|
||||
|
||||
**Purpose**
|
||||
{match.get("description", "No description available.")}
|
||||
|
||||
**Format**
|
||||
`{match.get("format", label)}`
|
||||
|
||||
**Parameters**
|
||||
{param_lines}
|
||||
|
||||
**Return value**
|
||||
{returns_md}
|
||||
|
||||
**Example**
|
||||
```tcl
|
||||
{example_md}"""
|
||||
|
||||
return lsp.Hover(lsp.MarkupContent(kind=lsp.MarkupKind.Markdown, value=doc_md))
|
||||
|
||||
|
||||
# **********************************************************
|
||||
# Linting features end here
|
||||
# **********************************************************
|
||||
@@ -127,6 +191,8 @@ def formatting(params: lsp.DocumentFormattingParams) -> list[lsp.TextEdit] | Non
|
||||
doc = LSP_SERVER.workspace.get_text_document(params.text_document.uri)
|
||||
text = doc.source
|
||||
|
||||
formatted = text
|
||||
if GLOBAL_SETTINGS.get("formatter", False):
|
||||
formatted = format_tcl(text)
|
||||
|
||||
last_line = len(text.splitlines())
|
||||
@@ -141,6 +207,13 @@ def formatting(params: lsp.DocumentFormattingParams) -> list[lsp.TextEdit] | Non
|
||||
# **********************************************************
|
||||
# Required Language Server Initialization and Exit handlers.
|
||||
# **********************************************************
|
||||
@LSP_SERVER.feature(lsp.WORKSPACE_DID_CHANGE_CONFIGURATION)
|
||||
def did_change_configuration(params: lsp.DidChangeConfigurationParams):
|
||||
settings = params.settings
|
||||
|
||||
log_to_output(str(settings))
|
||||
|
||||
|
||||
@LSP_SERVER.feature(lsp.INITIALIZE)
|
||||
def initialize(params: lsp.InitializeParams) -> lsp.InitializeResult:
|
||||
"""LSP handler for initialize request."""
|
||||
@@ -161,7 +234,7 @@ def initialize(params: lsp.InitializeParams) -> lsp.InitializeResult:
|
||||
)
|
||||
return lsp.InitializeResult(
|
||||
capabilities=lsp.ServerCapabilities(
|
||||
document_formatting_provider=True,
|
||||
document_formatting_provider=GLOBAL_SETTINGS.get("formatter", True),
|
||||
)
|
||||
)
|
||||
|
||||
@@ -185,6 +258,7 @@ def _get_global_defaults():
|
||||
"args": GLOBAL_SETTINGS.get("args", []),
|
||||
"importStrategy": GLOBAL_SETTINGS.get("importStrategy", "useBundled"),
|
||||
"showNotifications": GLOBAL_SETTINGS.get("showNotifications", "off"),
|
||||
"formatter": GLOBAL_SETTINGS.get("formatter", True),
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
// Lark grammar for Tcl scripts with proc definitions and optional args
|
||||
|
||||
%import common.CNAME -> IDENTIFIER
|
||||
%import common.INT -> INT
|
||||
%import common.FLOAT -> FLOAT
|
||||
%import common.ESCAPED_STRING -> STRING_LITERAL
|
||||
%import common.WS_INLINE -> WS_INLINE
|
||||
%import common.NEWLINE -> NEWLINE
|
||||
|
||||
// Ignore only spaces, tabs; treat newlines as separators
|
||||
%ignore WS_INLINE
|
||||
// Tcl comments
|
||||
%ignore COMMENT
|
||||
|
||||
start: script
|
||||
script: statement*
|
||||
|
||||
statement: command (";" | NEWLINE)?
|
||||
|
||||
command: set_command
|
||||
| proc_command
|
||||
| r_break
|
||||
| r_continue
|
||||
|
||||
proc_command: "proc" IDENTIFIER "{" argument_list "}" body_block
|
||||
|
||||
argument_list: [argument (argument)*]
|
||||
|
||||
argument: IDENTIFIER -> required_arg
|
||||
| "{" IDENTIFIER (value)? "}" -> optional_arg
|
||||
|
||||
|
||||
|
||||
value: STRING_LITERAL
|
||||
| FLOAT
|
||||
| INT
|
||||
| IDENTIFIER
|
||||
| list
|
||||
|
||||
list: LBRACE [value (WS_INLINE value)*] RBRACE
|
||||
|
||||
body_block: LBRACE body_content RBRACE -> body
|
||||
body_content: ( /[^{}]+/ | body_block )* // allow nested braces
|
||||
|
||||
set_command: "set" IDENTIFIER index? value
|
||||
// Index: parentheses with comma-separated items
|
||||
index: "(" index_item ("," index_item)* ")"
|
||||
index_item: INT -> index_int
|
||||
| STRING_VAR -> index_string
|
||||
| "$" IDENTIFIER index? -> nested_index
|
||||
|
||||
|
||||
r_break: "break"
|
||||
r_continue: "continue"
|
||||
|
||||
LBRACE: "{"
|
||||
RBRACE: "}"
|
||||
|
||||
STRING_VAR: /(?:[^"\\]|\\.)+/
|
||||
COMMENT: /#[^\r\n]*/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user