-
Notifications
You must be signed in to change notification settings - Fork 91
fix(graphical): dotted refs as constants + resolve globals/struct-members in LSP scope #950
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ import { RefreshIcon } from '../../../../assets/icons/interface/Refresh' | |
| import { useOpenPLCStore } from '../../../../store' | ||
| import { checkVariableName } from '../../../../store/slices/project/validation/variables' | ||
| import { cn } from '../../../../utils/cn' | ||
| import { isLegalIdentifier } from '../../../../utils/keywords' | ||
| import { toast } from '../../../_features/[app]/toast/use-toast' | ||
| import { useBoundEditorModel, useBoundPou } from '../../../_features/[workspace]/editor/graphical/active-context' | ||
| import { HighlightedTextArea } from '../../highlighted-textarea' | ||
|
|
@@ -504,6 +505,13 @@ const Block = <T extends object>(block: BlockProps<T>) => { | |
| if (matchingVariable) { | ||
| variableToLink = matchingVariable | ||
| } else if (createIfNotFound) { | ||
| // An entry that can't be a new variable NAME — a member/array reference, | ||
| // a typed literal (`T#500ms`), a reserved word — is bound to the block | ||
| // verbatim as a constant/reference instead of erroring. | ||
| if (!isLegalIdentifier(variableNameToSubmit)[0]) { | ||
| updateNodeVariable({ name: variableNameToSubmit }) | ||
| return | ||
| } | ||
|
Comment on lines
+508
to
+514
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Apply non-identifier handling to every block-commit path. The new branch is unreachable for the ordinary textarea commit because both handlers pass
📍 Affects 2 files
🤖 Prompt for AI Agents |
||
| const pouData = pous.find((p) => p.name === pouName) | ||
| pushToHistory(pouName, { | ||
| variables: pouData?.interface?.variables ?? [], | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ import { | |
| } from '../../../../../services/graphical-scope' | ||
| import { useOpenPLCStore } from '../../../../../store' | ||
| import { cn } from '../../../../../utils/cn' | ||
| import { getLiteralType } from '../../../../../utils/keywords' | ||
| import { getLiteralType, isLegalIdentifier } from '../../../../../utils/keywords' | ||
| import { toast } from '../../../../_features/[app]/toast/use-toast' | ||
| import { useBoundPou } from '../../../../_features/[workspace]/editor/graphical/active-context' | ||
| import { GraphicalEditorAutocomplete } from '../../autocomplete' | ||
|
|
@@ -187,6 +187,21 @@ const VariablesBlockAutoComplete = forwardRef<HTMLDivElement, VariablesBlockAuto | |
| }) | ||
| if (!rung || !node) return | ||
|
|
||
| // If the entry can't be a new variable NAME — a member/array reference | ||
| // (`some_struct.field`, `arr[3]`), a typed literal (`T#500ms`), a reserved | ||
| // word, etc. — don't try to create a variable. Bind it to the node | ||
| // verbatim as a constant/reference; strucpp validates the expression. New | ||
| // local-variable creation is only for plain, legal identifiers. | ||
| if (!isLegalIdentifier(variableName)[0]) { | ||
| updateNode({ | ||
| editorName: pouName, | ||
| rungId: rung.id, | ||
| nodeId: node.id, | ||
| node: { ...node, data: { ...node.data, variable: { name: variableName } } }, | ||
| }) | ||
| return | ||
|
Comment on lines
+190
to
+202
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win Use This branch updates only the variable node, while 🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| const variableType = newVariableTypeForExpected(expectedType) | ||
|
|
||
| const res = createVariable({ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Use an explicit unresolved-expression binding type in both autocomplete paths.
Both paths persist only a name where the shared
PLCVariablecontract requires additional fields.src/frontend/components/_atoms/graphical-editor/fbd/autocomplete/index.tsx#L138-L140: replace theas PLCVariablecast with a supported expression-binding representation.src/frontend/components/_atoms/graphical-editor/ladder/autocomplete/index.tsx#L195-L202: use the same representation and ensure connected-variable consumers handle it.📍 Affects 2 files
src/frontend/components/_atoms/graphical-editor/fbd/autocomplete/index.tsx#L138-L140(this comment)src/frontend/components/_atoms/graphical-editor/ladder/autocomplete/index.tsx#L195-L202🤖 Prompt for AI Agents