undoStudio
The IDE of the undoRT ecosystem
Loading...
Searching...
No Matches
undoAppST.hpp
Go to the documentation of this file.
1
10#pragma once
11
12#include <string>
13#include <vector>
14#include <filesystem>
15#include <memory>
16#include <unordered_map>
17
18// Include TextEditor
19#include <TextEditor.h>
20
21// Include st2cpp headers
22#include "lexer/Lexer.h"
23#include "parser/Parser.h"
24#include "ast/AST.h"
25#include "undoAppSTSemantic.hpp"
26#include "undoAppSTOutput.hpp"
27#include "undoAppSTSnippet.hpp"
28#include "semantic/SemanticAnalyzer.h"
29#include "semantic/LibraryDescriptorBuilder.h"
30#include "library/LibraryRegistry.h"
31#include "semantic/SymbolTable.h"
32
33namespace undoApp {
34namespace ST {
35
38
42enum class POUType {
43 Program,
46};
47
52{
53 std::string name;
54 std::string path;
56 std::vector<FileNode> children;
57 bool expanded = false;
58 bool isDragging = false;
59 int role = 0;
60};
61
66{
67 std::string name;
68 std::string returnType;
69 std::string variablesText;
70 std::string bodyText;
71 std::string visibility;
72 bool isAbstract = false;
73 bool isFinal = false;
74 bool isOverride = false;
75};
76
81{
82 std::unique_ptr<TextEditor> variables;
83 std::unique_ptr<TextEditor> body;
84 float splitterPos = 0.5f;
85};
86
101{
102 std::string path;
104 std::string pouName;
105 std::string functionReturnType;
106 std::string pouVariablesText;
107 std::string pouBodyText;
108 std::vector<MethodData> methods;
109 float splitterPos = 0.5f;
110 std::string activeTab;
111};
112
121{
122 int fullStart = 0;
123 int fullEnd = 0;
124 bool isVariables = false;
125 std::string methodName;
126};
127
134class STApp
135{
136public:
139
142
144 void shutdown();
145
148
149 // ============================================================================
150 // Panel rendering methods
151 // ============================================================================
152
160
168
175
178
181
184
187
188 // ============================================================================
189 // Workspace and file management
190 // ============================================================================
191
193 void loadWorkspace(const std::string& path);
194
197
199 void createNewFile(const std::string& parentPath, const std::string& name);
200
202 void createNewFolder(const std::string& parentPath, const std::string& name);
203
205 void deleteFile(const std::string& path);
206
208 void renameFile(const std::string& oldPath, const std::string& newName);
209
211 void moveFile(const std::string& sourcePath, const std::string& destDir);
212
220 void renameFileTo(const std::string& path);
221
224
232 bool hasUnsavedChanges() const { return m_isDirty; }
233
235 void openFile(const std::string& path);
236
238 void closeFile();
239
242
243 // ============================================================================
244 // Editor and parsing methods
245 // ============================================================================
246
248 std::string generateSTFile();
249
260 std::string generateSTFileWithMap(std::vector<SourceSegment>& outSegments);
261
264
266 const SourceSegment* segmentForLine(int fullLine) const;
267
268 // ============================================================================
269 // Go-to-declaration
270 // ============================================================================
271
273 static bool identifierAt(const TextEditor& editor, int line, int col, std::string& outName);
274
276 const Declaration* findDeclaration(const std::string& name, const std::string& scope) const;
277
279 static int columnOfName(const std::vector<std::string>& srcLines, int line, const std::string& name);
280
282 void revealGeneratedLine(int fullLine, int col, int tokenLength = 0);
283
296
305 void setDocument(const STDocument& doc);
306
308 bool revealMethodTab(const std::string& methodName);
309
312 void requestTabSelection(const std::string& tabName);
313
321
325
328
330 void handleNavigationInput(const char* id, TextEditor& editor);
333
335 void showIdentifierTooltip(TextEditor& editor);
336
337 // ============================================================================
338 // Unsaved-changes handling
339 // ============================================================================
340
343
345 void requestOpenFile(const std::string& path);
346
348 void openMethodOf(const std::string& filePath, const std::string& methodName);
349
352
355
356 // ============================================================================
357 // Workspace declaration index (cross-file navigation)
358 // ============================================================================
359
362 {
363 std::string name;
364 std::string returnType;
365 int line = 0;
366 };
367
370 {
371 std::string file;
372 int line = 0;
373 std::string scope;
375 std::string typeText;
376 std::string kindText;
377 std::string pouName;
378 };
379
382
390
392 void invalidateWorkspaceIndex(const std::string& path);
393
395 std::vector<WorkspaceDeclaration> findWorkspaceDeclarations(const std::string& name) const;
396
398 void indexSTFile(const std::string& path,
399 std::unordered_map<std::string, std::vector<WorkspaceDeclaration>>& outDecls) const;
400
403
406
408 void compile();
409
410 // ============================================================================
411 // Error mapping helpers
412 // ============================================================================
413
415 static int countLines(const std::string& text);
416
418 void addOutput(OutSeverity severity, std::string text);
419
422
423 // ============================================================================
424 // METHOD management (FUNCTION_BLOCK only)
425 // ============================================================================
426
428 void renderSplitEditor(TextEditor& varEditor,
429 TextEditor& bodyEditor,
430 float& splitterPos,
431 const char* varLabel,
432 const char* bodyLabel,
433 const char* varId,
434 const char* bodyId);
435
438
441
443 void addMethod(const std::string& name, const std::string& returnType);
444
446 void deleteMethod(const std::string& name);
447
449 int findMethodIndex(const std::string& name) const;
450
453
454private:
455 // ============================================================================
456 // Generated-source layout
457 // ============================================================================
458
460 TextEditor* editorForSegment(const SourceSegment& segment) const;
461 // ============================================================================
462 // Line mapping for methods
463 // ============================================================================
464 // Superseded by SourceSegment/m_sourceMap, which is filled while the file is
465 // generated and therefore cannot drift from the text the parser saw.
467 {
468 std::string name;
471 };
472
473 // ============================================================================
474 // Member variables
475 // ============================================================================
476
477 bool m_initialized = false;
478 std::string m_workspacePath;
480 std::string m_currentFilePath;
482 std::vector<OutputLine> m_outputLines;
499 char m_outputSearch[256] = {};
502
503 std::unique_ptr<TextEditor> m_variablesEditor;
504 std::unique_ptr<TextEditor> m_bodyEditor;
505
506 std::string m_pouName;
508
509 std::unique_ptr<TranslationUnit> m_ast;
510 std::vector<ParseError> m_errors;
511
512 std::vector<SourceSegment> m_sourceMap;
513
514 std::vector<std::string> m_srcLines;
515
517 std::unique_ptr<st2cpp::semantic::SemanticInfo> m_semantic;
518
521
522 // ============================================================================
523 // Unsaved-changes state
524 // ============================================================================
525
526 bool m_showTooltips = false;
527 bool m_isDirty = false;
529 bool m_showDirtyPrompt = false;
530 std::string m_pendingOpenPath;
531
532 // ============================================================================
533 // Workspace declaration index
534 // ============================================================================
535
536 std::unordered_map<std::string, std::vector<WorkspaceDeclaration>> m_workspaceDecls;
538
540 std::unique_ptr<st2cpp::library::LibraryRegistry> m_projectRegistry;
541
543 mutable std::unordered_map<std::string, std::vector<WorkspaceMethod>> m_workspaceMethods;
544
547
548 // ============================================================================
549 // Pending cross-file navigation
550 // ============================================================================
551
552 std::string m_pendingJumpName;
553 std::vector<WorkspaceDeclaration> m_jumpCandidates;
555 bool m_showJumpPopup = false;
556
557 // ============================================================================
558 // METHOD management
559 // ============================================================================
560
561 std::vector<MethodData> m_methods;
562 std::string m_currentContext;
563 std::string m_pouVariablesText;
564 std::string m_pouBodyText;
565
566 std::string m_activeTab;
567
570 bool m_pendingSelectPOU = false;
571 std::unordered_map<std::string, MethodEditors> m_methodEditors;
572
573 // ============================================================================
574 // Popup states
575 // ============================================================================
576
577 bool m_showNewFilePopup = false;
579 bool m_showRenamePopup = false;
580 bool m_showNewPOUPopup = false;
581 bool m_showAddMethodPopup = false;
583
584 // ============================================================================
585 // Member completion
586 //
587 // Triggered by typing '.' after an identifier that denotes a function block
588 // instance. Typing keeps going to the editor, so the list filters itself as
589 // the prefix grows; only the navigation and confirmation keys are captured.
590 // ============================================================================
591
594 TextEditor* m_completionEditor = nullptr;
595
597 std::vector<MemberAccess> m_completionCandidates;
598
600 std::string m_completionPrefix;
601 std::string m_completionObject;
602
608 {
609 int line = -1;
610 int column = -1;
611 };
615 TextEditor* m_parameterPickerEditor = nullptr;
625
632 ImVec2 m_completionRectMin = ImVec2(0.0f, 0.0f);
633 ImVec2 m_completionRectMax = ImVec2(0.0f, 0.0f);
634 ImVec2 m_completionEditorMin = ImVec2(0.0f, 0.0f);
635 ImVec2 m_completionEditorMax = ImVec2(0.0f, 0.0f);
636 ImVec2 m_completionCursorScreen = ImVec2(0.0f, 0.0f);
637
641
644
645 void updateMemberCompletion(const char* id, TextEditor& editor, bool editorHasKeyboard);
648 void moveMemberCompletion(int delta);
654
656 std::string methodScopeAtLine(int line) const;
657
659 st2cpp::semantic::ScopeId scopeIdForLine(int line) const;
660 // ============================================================================
661 // Signature help
662 //
663 // The parameter list of the call the cursor is inside, with the argument
664 // being written highlighted. Recomputed from the text like the member list,
665 // so it follows the cursor across a multi-line call and closes at the ')'.
666 // ============================================================================
667
668 TextEditor* m_signatureEditor = nullptr;
672
675
680 ImVec2 m_signatureRectMin = ImVec2(0.0f, 0.0f);
681 ImVec2 m_signatureRectMax = ImVec2(0.0f, 0.0f);
682 ImVec2 m_signatureCursorScreen = ImVec2(0.0f, 0.0f);
683 ImVec2 m_signatureEditorMin = ImVec2(0.0f, 0.0f);
684 ImVec2 m_signatureEditorMax = ImVec2(0.0f, 0.0f);
685
689
690 void updateSignatureHelp(const char* id, TextEditor& editor, bool editorHasKeyboard);
696
699 void renderParameterNameHint(const char* id, TextEditor& editor);
700
703
704 // ============================================================================
705 // Statement completion
706 //
707 // Typing the first letters of a statement offers the statements that start
708 // that way, and accepting one writes the whole skeleton with the caret on the
709 // part still to be filled in.
710 //
711 // The state is kept apart from the member completion's. The two can be
712 // answering about the same word and only one of them can be on screen, so
713 // each has to be able to tell that the other is up.
714 // ============================================================================
715
716 TextEditor* m_snippetEditor = nullptr;
717
718 std::vector<StatementSnippet> m_snippetCandidates;
719
721 std::vector<std::vector<int>> m_snippetMatchMask;
722
725 std::string m_snippetPrefix;
726 bool m_snippetInVariables = false;
727
732
735
736 ImVec2 m_snippetRectMin = ImVec2(0.0f, 0.0f);
737 ImVec2 m_snippetRectMax = ImVec2(0.0f, 0.0f);
738 ImVec2 m_snippetCursorScreen = ImVec2(0.0f, 0.0f);
739 ImVec2 m_snippetEditorMin = ImVec2(0.0f, 0.0f);
740 ImVec2 m_snippetEditorMax = ImVec2(0.0f, 0.0f);
741
742 void updateStatementCompletion(const char* id, TextEditor& editor, bool editorHasKeyboard, bool inVariables);
745 void moveStatementCompletion(int delta);
751
753 bool statementCompletionOpen() const { return m_snippetEditor != nullptr && !m_snippetCandidates.empty(); }
754
757
772 static constexpr ImGuiWindowFlags kMemberCompletionWindowFlags =
773 ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings |
774 ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNavFocus |
775 ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse;
776
778 static constexpr ImGuiWindowFlags kSignatureHelpWindowFlags = kMemberCompletionWindowFlags;
779
799
801 bool anyOverlayOpen() const;
802
810 bool buildParameterPicker(TextEditor& editor, const std::vector<std::string>& lines,
811 const TextEditor::Coordinates& cursor);
812
815 std::string m_newPOUName;
816 std::string m_newItemName;
817 std::string m_newItemParent;
818 std::string m_renamePath;
819 float m_splitterPos = 0.5f;
820 bool m_splitterDirty = false;
822
823 // Method creation popup state
824 std::string m_newMethodName;
827 std::string m_methodToDelete;
828
829 // ============================================================================
830 // Delete confirmation state
831 // ============================================================================
832
834
838 char m_workspaceDialogPath[1024] = {};
840
841 // ============================================================================
842 // Drag and drop state
843 // ============================================================================
844
845 std::string m_draggedItemPath;
846 bool m_isDragging = false;
847 std::string m_dropTargetPath;
849};
850
851} // namespace ST
852} // namespace undoApp
Main application class for the Structured Text editor plugin.
Definition undoAppST.hpp:135
void moveMemberCompletionByPage(int pages)
bool m_snippetInVariables
Pane the list was built for.
Definition undoAppST.hpp:726
bool m_showDeleteConfirmation
True if delete confirmation popup is visible.
Definition undoAppST.hpp:833
void updateSignatureHelp(const char *id, TextEditor &editor, bool editorHasKeyboard)
std::unique_ptr< st2cpp::semantic::SemanticInfo > m_semantic
Cached analysis of the current AST, rebuilt by validateAndParse()
Definition undoAppST.hpp:517
void updateDirtyState()
Poll the editors and update the dirty flag.
static bool identifierAt(const TextEditor &editor, int line, int col, std::string &outName)
Extract the identifier surrounding a position in an editor.
bool m_showDropIndicator
Definition undoAppST.hpp:848
std::string m_currentFileContent
Content of the currently open file.
Definition undoAppST.hpp:481
ImVec2 m_completionRectMax
Definition undoAppST.hpp:633
bool m_showDirtyPrompt
True while the confirmation popup is open.
Definition undoAppST.hpp:529
FileNode m_rootNode
Root of the file tree.
Definition undoAppST.hpp:479
bool m_isDragging
Definition undoAppST.hpp:846
const SourceSegment * segmentForLine(int fullLine) const
Map a generated-file line to the editor that owns it.
std::vector< SourceSegment > m_sourceMap
Layout of the last generated file.
Definition undoAppST.hpp:512
const Declaration * findDeclaration(const std::string &name, const std::string &scope) const
Resolve a name to the declaration it should navigate to.
std::unique_ptr< st2cpp::library::LibraryRegistry > m_projectRegistry
Declarations of the sibling files, as the analyzer's external scope.
Definition undoAppST.hpp:540
void updateMemberCompletion(const char *id, TextEditor &editor, bool editorHasKeyboard)
void openWorkspaceDialog()
Open a folder-picker dialog and load the chosen workspace.
ImVec2 m_snippetEditorMin
Definition undoAppST.hpp:739
void beginEditorFrame()
Do the ST editor's per-frame work, before any document is drawn.
std::vector< std::string > m_srcLines
Generated source, 1-based via index+1.
Definition undoAppST.hpp:514
std::vector< WorkspaceDeclaration > m_jumpCandidates
Definition undoAppST.hpp:553
bool m_showWorkspaceDialog
Definition undoAppST.hpp:837
std::string m_currentFilePath
Path of the currently open file.
Definition undoAppST.hpp:480
std::string m_deletePendingPath
Path of the file/folder pending deletion.
Definition undoAppST.hpp:839
void renameFileTo(const std::string &path)
Record that the file this editor holds has moved on disk.
ImVec2 m_completionEditorMin
Definition undoAppST.hpp:634
ImVec2 m_snippetRectMax
Definition undoAppST.hpp:737
size_t m_outputLinesShown
Last line count the Output panel drew, so it can tell new output from old.
Definition undoAppST.hpp:501
std::string m_pendingTabAfterOpen
Tab to select once a pending file switch has completed.
Definition undoAppST.hpp:546
std::unique_ptr< TranslationUnit > m_ast
AST of the current file.
Definition undoAppST.hpp:509
std::vector< WorkspaceDeclaration > findWorkspaceDeclarations(const std::string &name) const
All declarations of a name across the workspace.
CallSignature m_signature
The callee the cursor is inside.
Definition undoAppST.hpp:669
int m_completionSelected
Index into m_completionCandidates.
Definition undoAppST.hpp:599
void moveMemberCompletion(int delta)
std::string m_newMethodName
Definition undoAppST.hpp:824
std::string m_methodToDelete
Definition undoAppST.hpp:827
OutputFilter m_outputFilter
Definition undoAppST.hpp:491
void moveStatementCompletion(int delta)
bool anyOverlayOpen() const
True while any of the three overlays is on screen.
bool statementCompletionOpen() const
True while a statement list is up, which the member list defers to.
Definition undoAppST.hpp:753
std::vector< MemberAccess > m_completionCandidates
Candidates the pattern still matches, best match first.
Definition undoAppST.hpp:597
bool m_completionDismissedValid
Definition undoAppST.hpp:620
void renderDocument()
Draw the Structured Text document, inside the editor panel.
int m_snippetScroll
First candidate row on screen.
Definition undoAppST.hpp:724
void handleNavigationInput(const char *id, TextEditor &editor)
Handle Ctrl+Click and hover on one editor.
int m_completionColEnd
Definition undoAppST.hpp:624
CompletionSpot m_signatureDismissed
Definition undoAppST.hpp:673
POUType m_pouType
Type of the current POU.
Definition undoAppST.hpp:507
void renderDirtyPrompt()
Render the save / discard confirmation.
void renameFile(const std::string &oldPath, const std::string &newName)
Rename the entry at oldPath to newName.
void renderOutputPanel()
Render the Output panel (validation and compilation messages)
void saveCurrentFile()
Save the currently open file.
ImVec2 m_signatureEditorMin
Definition undoAppST.hpp:683
void createNewFile(const std::string &parentPath, const std::string &name)
Create a new ST file under parentPath.
ImVec2 m_signatureCursorScreen
Definition undoAppST.hpp:682
void validateAndParse()
Validate and parse the current ST code (includes semantic analysis)
void renderParameterNameHint(const char *id, TextEditor &editor)
void setDocument(const STDocument &doc)
Show a file taken out by takeDocument()
void refreshSemanticHighlighting()
Re-run the st2cpp analyzer and push resolved symbol colors to the editors.
void acceptStatementCompletion()
void renderStatementCompletion()
std::string m_snippetPrefix
What the candidates were filtered with.
Definition undoAppST.hpp:725
void syncMethodEditorsToData()
Pull the live text out of every currently-open method editor back into m_methods.
DeclarationIndex m_declarations
Declarations of the open file, keyed by normalized name.
Definition undoAppST.hpp:520
std::string m_dropTargetPath
Definition undoAppST.hpp:847
void invalidateWorkspaceIndex(const std::string &path)
Invalidate the workspace index after a file changed.
CallSite m_signatureCall
Where that call is, for its label.
Definition undoAppST.hpp:670
static constexpr ImGuiWindowFlags kSignatureHelpWindowFlags
Same flags for the signature help, which is the same kind of overlay.
Definition undoAppST.hpp:778
void addOutput(OutSeverity severity, std::string text)
Append a tagged line to the Output panel.
void renderWorkspacePanel()
Render the workspace/file-tree panel.
std::string m_currentContext
Current context: "POU" or "METHOD:name".
Definition undoAppST.hpp:562
void openFile(const std::string &path)
Open a file for editing (with method extraction)
void indexSTFile(const std::string &path, std::unordered_map< std::string, std::vector< WorkspaceDeclaration > > &outDecls) const
Index the declarations of one .st file.
std::vector< MethodData > m_methods
List of methods.
Definition undoAppST.hpp:561
std::string generateSTFileWithMap(std::vector< SourceSegment > &outSegments)
Generate the ST file and record where each editor section landed.
bool m_splitterDirty
It has been dragged and not yet written out.
Definition undoAppST.hpp:820
TextEditor * m_signatureEditor
Definition undoAppST.hpp:668
std::unordered_map< std::string, MethodEditors > m_methodEditors
Lazily-created editors, keyed by method name.
Definition undoAppST.hpp:571
std::unique_ptr< TextEditor > m_bodyEditor
Editor for the Body section.
Definition undoAppST.hpp:504
int m_ignoreChangeFrames
Frames to skip after a programmatic load.
Definition undoAppST.hpp:528
bool m_showNewFolderPopup
Definition undoAppST.hpp:578
int m_completionColStart
Definition undoAppST.hpp:623
void moveStatementCompletionByPage(int pages)
bool consumeAddMethodDialogRequest()
Take the pending "Add Method" request, if there is one.
bool m_showJumpPopup
True when a name is declared more than once.
Definition undoAppST.hpp:555
CompletionSpot m_completionDismissed
Definition undoAppST.hpp:619
void requestAddMethodDialog()
Ask the ST document to show the "Add Method" dialog.
bool m_completionIsParameterList
Definition undoAppST.hpp:618
bool m_showTooltips
Hover tooltips are opt-in: they interrupt reading.
Definition undoAppST.hpp:526
void createNewFolder(const std::string &parentPath, const std::string &name)
Create a new folder under parentPath.
std::string m_pouVariablesText
Variables text for the main POU.
Definition undoAppST.hpp:563
void renderFileTree(FileNode &node)
Render one file-tree node and its children recursively.
static constexpr ImGuiWindowFlags kMemberCompletionWindowFlags
Definition undoAppST.hpp:772
int m_completionPageSize
Rows the last frame had room for, so navigation knows a page.
Definition undoAppST.hpp:643
static STApp & getInstance()
Get the singleton instance of STApp.
void clearMemberCompletion()
ImVec2 m_completionEditorMax
Definition undoAppST.hpp:635
bool m_showNewPOUPopup
Definition undoAppST.hpp:580
void renderJumpPopup()
Let the user pick a target when a name has several declarations.
void addMethod(const std::string &name, const std::string &returnType)
Add a new, empty method and switch to its tab.
void showIdentifierTooltip(TextEditor &editor)
Show the resolved declaration of the identifier under the mouse.
void runTranspiler()
Run st2cpp over the open project and report what it says.
std::string m_pouName
Name of the current POU.
Definition undoAppST.hpp:506
std::string m_draggedItemPath
Definition undoAppST.hpp:845
std::string m_workspacePath
Current workspace path.
Definition undoAppST.hpp:478
ImVec2 m_signatureEditorMax
Definition undoAppST.hpp:684
void revealGeneratedLine(int fullLine, int col, int tokenLength=0)
Move the editor to a generated-file line, switching METHOD tabs.
STDocument takeDocument()
Take the open file out whole, to be put back later.
void dismissSignatureHelp()
void moveFile(const std::string &sourcePath, const std::string &destDir)
Move sourcePath into destDir.
void deleteFile(const std::string &path)
Delete the file or folder at path.
std::string methodScopeAtLine(int line) const
The METHOD whose body a line sits in, empty for POU-level code.
void ensureWorkspaceIndex()
Build (or reuse) the index of declarations across the workspace.
void requestOpenFile(const std::string &path)
Open a file, asking first when there are unsaved changes.
ImVec2 m_completionRectMin
Definition undoAppST.hpp:632
void loadWorkspace(const std::string &path)
Load a workspace directory into the file tree.
void dismissMemberCompletion()
std::string generateSTFile()
Generate the full ST file content from the editor sections and methods.
int m_snippetSelected
Index into m_snippetCandidates.
Definition undoAppST.hpp:723
std::unordered_map< std::string, std::vector< WorkspaceDeclaration > > m_workspaceDecls
Definition undoAppST.hpp:536
void clearStatementCompletion()
ImVec2 m_snippetEditorMax
Definition undoAppST.hpp:740
std::string m_pendingOpenPath
File queued to open once the user decides.
Definition undoAppST.hpp:530
ImVec2 m_completionCursorScreen
Definition undoAppST.hpp:636
int m_snippetColEnd
Definition undoAppST.hpp:731
std::string m_pendingTabSelection
One-shot request to select a tab, honoured via ImGuiTabItemFlags_SetSelected.
Definition undoAppST.hpp:569
bool m_showRenamePopup
Definition undoAppST.hpp:579
int m_snippetColStart
Definition undoAppST.hpp:730
void invalidateSemanticTokens()
Drop the semantic spans the editors are painting.
void renderMemberCompletion()
void deleteMethod(const std::string &name)
Delete a method by name.
ImGuiKey handleMemberCompletionKeys()
TextEditor * m_snippetEditor
Editor the list belongs to.
Definition undoAppST.hpp:716
std::string m_renamePath
Definition undoAppST.hpp:818
bool m_signatureDismissedValid
Definition undoAppST.hpp:674
std::string m_jumpCandidateName
Definition undoAppST.hpp:554
bool m_showGeneratedDump
Definition undoAppST.hpp:485
float m_splitterPos
Where the Variables and Body sections are divided.
Definition undoAppST.hpp:819
bool handleKeyboardShortcuts()
Handle keyboard shortcuts.
void renderSplitEditor(TextEditor &varEditor, TextEditor &bodyEditor, float &splitterPos, const char *varLabel, const char *bodyLabel, const char *varId, const char *bodyId)
Render one Variables/Body split editor (shared by the POU tab and every method tab)
TextEditor * m_completionEditor
Definition undoAppST.hpp:594
static int countLines(const std::string &text)
Count the number of lines in a text string.
int findMethodIndex(const std::string &name) const
Find the index of a method by name, or -1 if not found.
std::string m_pouBodyText
Body text for the main POU.
Definition undoAppST.hpp:564
bool m_snippetDismissedValid
Definition undoAppST.hpp:734
void acceptMemberCompletion()
void updateStatementCompletion(const char *id, TextEditor &editor, bool editorHasKeyboard, bool inVariables)
bool m_signatureArgumentEmpty
Definition undoAppST.hpp:688
void requestTabSelection(const std::string &tabName)
Ask the tab bar to show a tab on the next frame.
std::vector< ParseError > m_errors
Parsing errors.
Definition undoAppST.hpp:510
std::string m_functionReturnType
Definition undoAppST.hpp:821
TextEditor * m_parameterPickerEditor
Definition undoAppST.hpp:615
bool revealMethodTab(const std::string &methodName)
Switch to a METHOD tab, materializing it if needed.
int m_completionScroll
Definition undoAppST.hpp:640
std::unique_ptr< TextEditor > m_variablesEditor
Editor for the Variables section.
Definition undoAppST.hpp:503
void shutdown()
Shutdown the ST undoApp and release resources.
bool hasUnsavedChanges() const
Whether the file has edits that are not on disk.
Definition undoAppST.hpp:232
ImVec2 m_snippetRectMin
Definition undoAppST.hpp:736
bool buildParameterPicker(TextEditor &editor, const std::vector< std::string > &lines, const TextEditor::Coordinates &cursor)
Fill the completion list with the parameters of the call at the caret.
std::string m_newMethodReturnType
Definition undoAppST.hpp:825
void setupEditors()
Setup and configure the TextEditor widgets.
void registerPanels()
Register UI panels with ImGuiManager.
std::vector< StatementSnippet > m_snippetCandidates
Matching skeletons, best first.
Definition undoAppST.hpp:718
bool m_showNewFilePopup
Definition undoAppST.hpp:577
void setErrorMarkers()
Set error markers on the appropriate editors based on m_errors.
std::string m_newItemParent
Definition undoAppST.hpp:817
void ensureProjectRegistry()
Build (or reuse) the library registry describing the sibling files.
void renderOutlinePanel()
Render the Outline panel (AST structure tree with methods)
ImVec2 m_snippetCursorScreen
Definition undoAppST.hpp:738
st2cpp::semantic::ScopeId scopeIdForLine(int line) const
The scope an identifier on a line resolves from, 0 when nothing is.
void closeFile()
Close the currently open ST file and clear the editor state.
ImGuiKey handleStatementCompletionKeys()
int m_signatureArgument
Index of the argument the cursor is in.
Definition undoAppST.hpp:671
bool m_showAddMethodPopup
True if add method popup is visible.
Definition undoAppST.hpp:581
MethodEditors & getOrCreateMethodEditors(MethodData &method)
Get (creating on first use) the editor pair for a method tab.
int m_completionLine
Line and column span the completion would replace, in editor coordinates.
Definition undoAppST.hpp:622
bool revealDeclaration(const Declaration &decl)
Reveal a declaration, handling METHOD headers and parameters.
std::vector< std::vector< int > > m_snippetMatchMask
One row per candidate, a byte per label character, 1 where the pattern matched.
Definition undoAppST.hpp:721
std::string m_newItemName
Definition undoAppST.hpp:816
void resetMethodState()
Reset all method-related state (called whenever the open file changes/closes)
void endEditorFrame()
Draw the ST editor's overlays, after the document.
std::string m_newMethodVisibility
Definition undoAppST.hpp:826
void openMethodOf(const std::string &filePath, const std::string &methodName)
Open a file and land on one of its METHOD tabs.
char m_outputSearch[256]
Definition undoAppST.hpp:499
TextEditor * editorForSegment(const SourceSegment &segment) const
Resolve the TextEditor that backs a segment, or nullptr if closed.
char m_workspaceDialogPath[1024]
Definition undoAppST.hpp:838
std::vector< OutputLine > m_outputLines
Definition undoAppST.hpp:482
bool m_workspaceIndexValid
Definition undoAppST.hpp:537
bool m_initialized
Initialization flag.
Definition undoAppST.hpp:477
void renderSignatureHelp()
void dismissStatementCompletion()
CompletionSpot m_snippetDismissed
Definition undoAppST.hpp:733
std::string m_completionObject
Instance name the '.' was typed after.
Definition undoAppST.hpp:601
bool m_isDirty
Editor text differs from the file on disk.
Definition undoAppST.hpp:527
bool m_showDeleteMethodConfirmation
True if delete method confirmation is visible.
Definition undoAppST.hpp:813
void claimOverlayNavigationKeys()
Claim the navigation keys for whichever overlay is open.
std::string m_completionPrefix
Prefix the candidates were filtered with.
Definition undoAppST.hpp:600
int m_snippetLine
Line and column span the list would replace, in editor coordinates.
Definition undoAppST.hpp:729
bool m_pendingSelectPOU
Request to select the POU tab.
Definition undoAppST.hpp:570
std::string m_pendingJumpName
Identifier to reveal after a file switch.
Definition undoAppST.hpp:552
bool m_addMethodDialogPending
Asked for from another panel; the document opens the popup.
Definition undoAppST.hpp:582
POUType m_newPOUType
Definition undoAppST.hpp:814
bool initialize()
Initialize the ST undoApp.
ImVec2 m_signatureRectMax
Definition undoAppST.hpp:681
std::unordered_map< std::string, std::vector< WorkspaceMethod > > m_workspaceMethods
METHODS of each indexed .st file, so the tree can show them.
Definition undoAppST.hpp:543
static int columnOfName(const std::vector< std::string > &srcLines, int line, const std::string &name)
Column of a name inside a generated line, or -1 when absent.
ImVec2 m_signatureRectMin
Definition undoAppST.hpp:680
void applyPendingJump()
Resolve a name queued by a cross-file Ctrl+Click and reveal it.
std::string m_newPOUName
Definition undoAppST.hpp:815
std::string m_activeTab
"" = POU tab (Variables/Body), otherwise the open method's name
Definition undoAppST.hpp:566
void compile()
Compile the current ST code.
ImGuiKey handleSignatureHelpKeys()
SymCategory
Category of a resolved symbol, as far as highlighting cares.
Definition undoAppSTSemantic.hpp:35
@ Unresolved
Not in the symbol table: leave the text as the lexer saw it.
OutSeverity
Severity of a line in the Output panel.
Definition undoAppSTOutput.hpp:57
std::unordered_map< std::string, std::vector< Declaration > > DeclarationIndex
Declarations of a translation unit, keyed by normalized name.
Definition undoAppSTSemantic.hpp:129
::ParseError ParseError
Definition undoAppST.hpp:37
POUType
Enumeration of POU (Program Organization Unit) types.
Definition undoAppST.hpp:42
::TranslationUnit TranslationUnit
Definition undoAppST.hpp:36
Definition undoAppCpp.hpp:26
The parameter list of a callable.
Definition undoAppSTSemantic.hpp:365
The call the cursor sits inside, if any.
Definition undoAppSTSemantic.hpp:324
One declaration that a usage can be navigated back to.
Definition undoAppSTSemantic.hpp:111
Node structure for the file tree representation.
Definition undoAppST.hpp:52
std::vector< FileNode > children
Child nodes (files and subdirectories)
Definition undoAppST.hpp:56
bool isDragging
True if this node is being dragged.
Definition undoAppST.hpp:58
bool isDirectory
True if this node represents a directory.
Definition undoAppST.hpp:55
bool expanded
True if the tree node is expanded in the UI.
Definition undoAppST.hpp:57
std::string name
File or directory name.
Definition undoAppST.hpp:53
int role
Semantic role within an undoProject (0=Generic)
Definition undoAppST.hpp:59
std::string path
Full filesystem path.
Definition undoAppST.hpp:54
Data structure for a method inside a FUNCTION_BLOCK.
Definition undoAppST.hpp:66
bool isFinal
True if final method.
Definition undoAppST.hpp:73
std::string name
Method name.
Definition undoAppST.hpp:67
std::string returnType
Return type (empty for void)
Definition undoAppST.hpp:68
std::string visibility
PUBLIC, PROTECTED, PRIVATE (default: PUBLIC)
Definition undoAppST.hpp:71
std::string bodyText
Method body (statements)
Definition undoAppST.hpp:70
bool isAbstract
True if abstract method.
Definition undoAppST.hpp:72
bool isOverride
True if override method.
Definition undoAppST.hpp:74
std::string variablesText
All VAR sections (VAR_INPUT, VAR_OUTPUT, VAR_TEMP, VAR)
Definition undoAppST.hpp:69
Editor pair for a single METHOD tab (created lazily on first open)
Definition undoAppST.hpp:81
float splitterPos
Definition undoAppST.hpp:84
std::unique_ptr< TextEditor > variables
Definition undoAppST.hpp:82
std::unique_ptr< TextEditor > body
Definition undoAppST.hpp:83
Which severities the Output panel shows.
Definition undoAppSTOutput.hpp:85
Definition undoAppST.hpp:608
int line
Definition undoAppST.hpp:609
int column
Definition undoAppST.hpp:610
Definition undoAppST.hpp:467
int endLine
Definition undoAppST.hpp:470
int startLine
Definition undoAppST.hpp:469
std::string name
Definition undoAppST.hpp:468
A declaration found somewhere in the workspace.
Definition undoAppST.hpp:370
std::string file
Absolute path of the declaring file.
Definition undoAppST.hpp:371
std::string scope
Empty for POU level, else the METHOD name.
Definition undoAppST.hpp:373
std::string pouName
Definition undoAppST.hpp:377
int line
1-based line in that file
Definition undoAppST.hpp:372
SymCategory category
Definition undoAppST.hpp:374
std::string kindText
Definition undoAppST.hpp:376
std::string typeText
Definition undoAppST.hpp:375
A METHOD of a file in the workspace, for the file tree.
Definition undoAppST.hpp:362
std::string name
Definition undoAppST.hpp:363
int line
Definition undoAppST.hpp:365
std::string returnType
Definition undoAppST.hpp:364
One open ST file, held whole so it can be put back.
Definition undoAppST.hpp:101
std::string pouName
Name of the POU.
Definition undoAppST.hpp:104
std::string path
Absolute path, where a later save goes.
Definition undoAppST.hpp:102
std::vector< MethodData > methods
Its methods, with their texts.
Definition undoAppST.hpp:108
std::string pouBodyText
The POU's body.
Definition undoAppST.hpp:107
std::string activeTab
Which method tab was showing, empty for the POU.
Definition undoAppST.hpp:110
std::string functionReturnType
Return type of a FUNCTION.
Definition undoAppST.hpp:105
POUType pouType
PROGRAM, FUNCTION_BLOCK or FUNCTION.
Definition undoAppST.hpp:103
std::string pouVariablesText
The POU's VAR sections.
Definition undoAppST.hpp:106
float splitterPos
Where the two panes were divided.
Definition undoAppST.hpp:109
One editor-backed block of the generated ST file.
Definition undoAppST.hpp:121
int fullStart
First line of the block in the generated file.
Definition undoAppST.hpp:122
int fullEnd
Last line of the block (inclusive)
Definition undoAppST.hpp:123
std::string methodName
Empty for the POU itself, else the owning METHOD.
Definition undoAppST.hpp:125
bool isVariables
True for a VAR* block, false for a body block.
Definition undoAppST.hpp:124
Deciding which lines of the ST Output panel are shown.
Resolved-symbol extraction for ST syntax highlighting.
Statement skeletons offered by the editor's suggestion list.