Class KotlinPropertyReader
This is what the property panel needs, and it needs nothing else: the panel gets a property's default from the live component by reflection, and only asks the source what the developer explicitly set. So "not set here" is a normal answer, not a failure — the panel then shows the default.
Kotlin can express the same set five ways, and a real view mixes them:
name.helperText = "Write your name" // property assignment
name.setHelperText("Write your name") // call form, legal but rare
isPadding = true // implicit this, on the view itself
setPadding(true) // implicit this, call form
button.isEnabled = false // is-prefixed boolean
All five are read. Which one Copilot would write is a separate
decision and deliberately not made here.
The public surface takes and returns only strings and numbers, so no PSI type escapes this package.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intPass as the occurrence when the caller cannot say which same-type component on the line it means. -
Constructor Summary
ConstructorsConstructorDescriptionKotlinPropertyReader(KotlinSource source) Creates a reader for a component whose position among same-type creations on its line is not known.KotlinPropertyReader(KotlinSource source, int occurrence, int componentsOnLine) Creates a reader for a known occurrence. -
Method Summary
Modifier and TypeMethodDescriptionfindPropertyValue(int createLine, Class<?> componentType, String propertyName) The source text of the value assigned to a property, if the source sets it.
-
Field Details
-
UNKNOWN_OCCURRENCE
public static final int UNKNOWN_OCCURRENCEPass as the occurrence when the caller cannot say which same-type component on the line it means. Re-exposed here because the finder is package private, so this is the only way a caller outside the package can name it.- See Also:
-
-
Constructor Details
-
KotlinPropertyReader
Creates a reader for a component whose position among same-type creations on its line is not known.Safe by default: where the line creates only one component of the type — which is nearly always — this reads exactly as before, and where it creates several the reader declines to answer rather than attribute one component's value to another. Prefer
KotlinPropertyReader(KotlinSource, int, int)whenever the caller can work the position out.- Parameters:
source- the parsed file the component lives in
-
KotlinPropertyReader
Creates a reader for a known occurrence.Both numbers are required together, because an index is only meaningful against the set it indexes into. If the running application accounts for fewer components on that line than the source creates, the index cannot be trusted — see
occurrenceIsTrustworthy(int).- Parameters:
source- the parsed file the component lives inoccurrence- 0-based index of this component among same-type components created on its line, ordered as the source iscomponentsOnLine- how many same-type components the running application accounts for at that location, which the index was derived from
-
-
Method Details
-
findPropertyValue
public Optional<Object> findPropertyValue(int createLine, Class<?> componentType, String propertyName) The source text of the value assigned to a property, if the source sets it.- Parameters:
createLine- 1-based line the component is created on, fromComponentTrackercomponentType- the component's class, from the live instance — its simple name locates the create call, and its constructors are what a constructor argument is matched againstpropertyName- the JavaBean property name, such ashelperText- Returns:
- the value as written in the source —
"\"Write your name\""for a string,"true"for a boolean — or empty when the source does not set it
-