21#include "semantic/SymbolTable.h"
25#include <unordered_map>
79 const st2cpp::semantic::SymbolTable& symTab,
80 const std::vector<std::string>& srcLines);
94 const std::string& ownerName,
138 const st2cpp::semantic::SymbolTable& symTab);
215 bool matches(
const std::string& prefix)
const;
248 st2cpp::semantic::SymbolId fbId);
263 st2cpp::semantic::ScopeId scopeId,
264 const std::string& name);
310 st2cpp::semantic::ScopeId scopeId,
311 bool includeOwnMethods =
true);
388 st2cpp::semantic::ScopeId scopeId,
std::vector< Suggestion > MemberList
Definition undoAppSTSemantic.hpp:224
DeclarationIndex collectDeclarations(const TranslationUnit &tu, const st2cpp::semantic::SymbolTable &symTab)
Index every declaration a navigation could target.
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.
@ Field
PROGRAM / FUNCTION_BLOCK instance, STRUCT member.
@ Type
Built-in or user-defined type, INTERFACE.
@ Constant
VAR CONSTANT, or any symbol flagged constant.
MemberList collectScopeNames(const st2cpp::semantic::SymbolTable &symTab, st2cpp::semantic::ScopeId scopeId, bool includeOwnMethods=true)
The names visible from a scope, for completing a plain identifier.
MemberList collectBlockMembers(const st2cpp::semantic::SymbolTable &symTab, st2cpp::semantic::SymbolId fbId)
Everything reachable through '.' on a value of a function block type.
std::unordered_map< std::string, std::vector< Declaration > > DeclarationIndex
Declarations of a translation unit, keyed by normalized name.
Definition undoAppSTSemantic.hpp:129
std::string describeType(const TypeRef &type)
Render a type reference the way it is written in source.
st2cpp::semantic::ScopeId findMemberScopeFor(const st2cpp::semantic::SymbolTable &symTab, const std::string &ownerName, bool method)
The scope holding the variables of a POU or the locals of a METHOD.
void rankMembers(MemberList &members, const std::string &pattern)
Keep the members a pattern matches and order them best first.
MemberAccessPoint memberAccessPointAt(const std::string &line, int cursorCol)
Decide whether the cursor sits in a member access.
SemanticTokenSet collectSemanticTokens(const TranslationUnit &tu, const st2cpp::semantic::SymbolTable &symTab, const std::vector< std::string > &srcLines)
Classify every identifier the analyzer could resolve.
std::string formatSignature(const CallSignature &signature, int activeArgument)
Render a signature as one line, the way the tests and the label use it.
st2cpp::semantic::SymbolId findInstanceBlock(const st2cpp::semantic::SymbolTable &symTab, st2cpp::semantic::ScopeId scopeId, const std::string &name)
The function block an instance name refers to, if any.
NameMatch matchName(const std::string &name, const std::string &pattern)
Match a typed pattern against a candidate name, fuzzily.
std::vector< SignatureSegment > signatureSegments(const CallSignature &signature, int activeArgument)
Break a signature into the runs the popup draws.
CallSite callSiteAt(const std::vector< std::string > &lines, int line, int col)
Find the call whose argument list the cursor is inside.
std::string describeMember(const Suggestion &member)
Render a member the way it is offered in the completion list.
::TranslationUnit TranslationUnit
Definition undoAppST.hpp:36
bool resolveCallSignature(const st2cpp::semantic::SymbolTable &symTab, st2cpp::semantic::ScopeId scopeId, const CallSite &call, CallSignature &out)
Resolve the parameters of the call at a call site.
Definition undoAppCpp.hpp:26
The parameter list of a callable.
Definition undoAppSTSemantic.hpp:365
std::string returnType
Return type, empty for a call with no result.
Definition undoAppSTSemantic.hpp:368
std::string owner
Block the method belongs to, empty for a plain call.
Definition undoAppSTSemantic.hpp:367
std::string name
Member or function name, without the object.
Definition undoAppSTSemantic.hpp:366
bool inherited
Definition undoAppSTSemantic.hpp:369
std::string declaredIn
Definition undoAppSTSemantic.hpp:370
std::vector< SignatureParam > params
Definition undoAppSTSemantic.hpp:371
The call the cursor sits inside, if any.
Definition undoAppSTSemantic.hpp:324
std::string label
"motore.Reset" or "MAX", as it appears in the source
Definition undoAppSTSemantic.hpp:328
std::string calleeName
Member or function being called.
Definition undoAppSTSemantic.hpp:327
bool active
The cursor is between a callee's parentheses.
Definition undoAppSTSemantic.hpp:325
int argumentIndex
Which argument the cursor is in, 0-based.
Definition undoAppSTSemantic.hpp:329
int argumentLine
Line the current argument's text starts on.
Definition undoAppSTSemantic.hpp:332
int parenColumn
Column of the opening parenthesis.
Definition undoAppSTSemantic.hpp:331
std::string objectName
Instance before the '.', empty for a plain call.
Definition undoAppSTSemantic.hpp:326
int parenLine
Line of the opening parenthesis.
Definition undoAppSTSemantic.hpp:330
int argumentColumn
Its first column, just past '(' or the last ','.
Definition undoAppSTSemantic.hpp:333
One declaration that a usage can be navigated back to.
Definition undoAppSTSemantic.hpp:111
std::string kindText
"VAR", "METHOD", "FUNCTION_BLOCK", ... for display
Definition undoAppSTSemantic.hpp:119
std::string typeText
Declared or return type, when known.
Definition undoAppSTSemantic.hpp:118
int ownerLine
For a METHOD parameter: the line of its METHOD.
Definition undoAppSTSemantic.hpp:115
int col
Column of the first character of the name.
Definition undoAppSTSemantic.hpp:113
SymCategory category
Definition undoAppSTSemantic.hpp:117
int line
Line of the declared name.
Definition undoAppSTSemantic.hpp:112
std::string name
Identifier as spelled in the source.
Definition undoAppSTSemantic.hpp:114
std::string scope
Empty for POU level, else the owning METHOD name.
Definition undoAppSTSemantic.hpp:116
What a line looks like at the cursor, for member completion.
Definition undoAppSTSemantic.hpp:270
std::string prefix
Part of the member name already typed.
Definition undoAppSTSemantic.hpp:273
int dotColumn
0-based column of the '.', -1 when inactive
Definition undoAppSTSemantic.hpp:274
bool active
A '.' was typed and the cursor follows it.
Definition undoAppSTSemantic.hpp:271
std::string objectName
Identifier before the '.'.
Definition undoAppSTSemantic.hpp:272
How a typed pattern lines up with a candidate name.
Definition undoAppSTSemantic.hpp:154
std::vector< int > positions
Matched indices into the name, ascending.
Definition undoAppSTSemantic.hpp:157
bool matched
Pattern occurs in order inside the name.
Definition undoAppSTSemantic.hpp:155
int score
Higher is better; only meaningful if matched.
Definition undoAppSTSemantic.hpp:156
One classified identifier occurrence.
Definition undoAppSTSemantic.hpp:50
int col
0-based column of the first character
Definition undoAppSTSemantic.hpp:52
int line
1-based line in the generated file
Definition undoAppSTSemantic.hpp:51
int length
Number of characters.
Definition undoAppSTSemantic.hpp:53
SymCategory category
Definition undoAppSTSemantic.hpp:54
Result of a classification pass.
Definition undoAppSTSemantic.hpp:61
std::vector< SemanticToken > tokens
Definition undoAppSTSemantic.hpp:62
One parameter of a call, as the signature popup shows it.
Definition undoAppSTSemantic.hpp:354
bool hasDefault
Declared with an initial value, so it may be omitted.
Definition undoAppSTSemantic.hpp:358
std::string name
As declared, empty when the declaration is unnamed.
Definition undoAppSTSemantic.hpp:355
std::string direction
"IN", "OUT" or "IN_OUT"; empty when not a parameter
Definition undoAppSTSemantic.hpp:357
std::string type
Declared type.
Definition undoAppSTSemantic.hpp:356
One run of text in a rendered signature.
Definition undoAppSTSemantic.hpp:396
std::string text
Definition undoAppSTSemantic.hpp:397
bool isParameter
A parameter, which is what gets highlighted.
Definition undoAppSTSemantic.hpp:398
One entry of a completion list.
Definition undoAppSTSemantic.hpp:186
Kind kind
Definition undoAppSTSemantic.hpp:202
std::string declaredIn
Base block name, set when inherited.
Definition undoAppSTSemantic.hpp:208
bool isOverride
Definition undoAppSTSemantic.hpp:206
std::string name
Identifier as spelled in the source.
Definition undoAppSTSemantic.hpp:200
std::vector< std::string > parameterNames
Method parameter names, for signature help.
Definition undoAppSTSemantic.hpp:210
std::vector< std::string > parameterTypes
Method parameter types, for display.
Definition undoAppSTSemantic.hpp:209
bool isAbstract
Definition undoAppSTSemantic.hpp:205
std::string typeText
Declared type, or the return type of a method.
Definition undoAppSTSemantic.hpp:201
bool inherited
Declared by a base block, not by this one.
Definition undoAppSTSemantic.hpp:207
bool isConstant
Definition undoAppSTSemantic.hpp:203
Kind
What kind of thing this is, which is also what its colour means.
Definition undoAppSTSemantic.hpp:189
@ Enumerator
An enumerator of an enum.
@ State
VAR / VAR_TEMP / VAR RETAIN.
@ Parameter
VAR_INPUT / VAR_OUTPUT / VAR_IN_OUT.
@ Block
A FUNCTION_BLOCK instance, or the block's type name.
std::string note
Short remark after the name, such as "given".
Definition undoAppSTSemantic.hpp:212
bool matches(const std::string &prefix) const
True when the pattern occurs in this name, fuzzily and case-insensitively.
std::vector< std::string > parameterDirs
"IN", "OUT" or "IN_OUT", empty when unknown
Definition undoAppSTSemantic.hpp:211
std::vector< int > matchPositions
Indices of name that the last matches call matched, for highlighting.
Definition undoAppSTSemantic.hpp:218
bool isRetain
Definition undoAppSTSemantic.hpp:204