You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Context menu: Unknown symbol (or whitespace) should assume parent context. #777
So I wanted to gave it a try.
I managed to get the ContextMenuHandler to look for a parent if there is no available symbol under the cursor.
It appears to work nicely, if you are on a valid symbol it's used. Otherwise we look the parent and if it's a valid symbol it's used, and again until there is no parent left.
The problem is that when I open the context menu for the class but with the cursor on a blank line and I ask to find the references then we got an error because the handler for the reference finder will receive the offset of the cursor, not the class.
What I would like to do is to provide the "new offset" to the actionSelectionAction method instead of forwarding the one in the arguments.
So that the action will received the right offset.
But I can't manage to find a reliable way to retrieve an Offset from a RelfectionOffset.
All we got is a Position but it doesn't seem reliable to take the start position as offset, neither as the end.
But in a previous version of the generate accessor PR, I was using the reflection to find a property by it's name (in the handler) and then provide the start position as the offset of the property to generate it's accessor.
If I'm not mistaken, then visibility is the start position but if you try to reflection from the offset of the visibility you end up with an unknown symbol.
For this PR it doesn't seem to be a problem, it works for class and methods.
I just wanted to get your opinion on how to pass from a Position to an Offset because it's unclear to me at the time.
hmm, Position offers both startPosition and fullStartPosition. The fullStartPosition includes any leading whitespace and comments. startPosition should always work (that should be the start of the class keyword I think).
Is on the first p of the line, the visibility.
If you put your cursor on a property visibility and class phpactor#Hover() your will have a <unknown> <unknown> as a response.
Which is kind of strange because if you do it on a method visibility, it works.
Activity
camilledejoye commentedon Jun 15, 2019
So I wanted to gave it a try.
I managed to get the
ContextMenuHandlerto look for a parent if there is no available symbol under the cursor.It appears to work nicely, if you are on a valid symbol it's used. Otherwise we look the parent and if it's a valid symbol it's used, and again until there is no parent left.
The problem is that when I open the context menu for the class but with the cursor on a blank line and I ask to find the references then we got an error because the handler for the reference finder will receive the offset of the cursor, not the class.
What I would like to do is to provide the "new offset" to the
actionSelectionActionmethod instead of forwarding the one in the arguments.So that the action will received the right offset.
But I can't manage to find a reliable way to retrieve an
Offsetfrom aRelfectionOffset.All we got is a
Positionbut it doesn't seem reliable to take the start position as offset, neither as the end.Do I miss something about
PositionandOffset?dantleech commentedon Jun 16, 2019
Haven't got access to computer at the moment, but using the class start position should be fine. Why is of unreliable?
camilledejoye commentedon Jun 17, 2019
For know it seems to work.
But in a previous version of the generate accessor PR, I was using the reflection to find a property by it's name (in the handler) and then provide the start position as the offset of the property to generate it's accessor.
If I'm not mistaken, then visibility is the start position but if you try to reflection from the offset of the visibility you end up with an unknown symbol.
For this PR it doesn't seem to be a problem, it works for class and methods.
I just wanted to get your opinion on how to pass from a
Positionto anOffsetbecause it's unclear to me at the time.dantleech commentedon Jun 18, 2019
hmm,
Positionoffers bothstartPositionandfullStartPosition. ThefullStartPositionincludes any leading whitespace and comments.startPositionshould always work (that should be the start of theclasskeyword I think).camilledejoye commentedon Jun 18, 2019
By memory the start of
Is on the first
pof the line, the visibility.If you put your cursor on a property visibility and class
phpactor#Hover()your will have a<unknown> <unknown>as a response.Which is kind of strange because if you do it on a method visibility, it works.
dantleech commentedon Jun 18, 2019
hm, sounds like an unrelated bug maybe? Probably WorseReflection related?
dantleech commentedon Feb 29, 2020
Done!