EditorSyntax icon indicating copy to clipboard operation
EditorSyntax copied to clipboard

Chained methods and properties on expressions

Open vors opened this issue 6 years ago • 2 comments

Moving from https://github.com/SublimeText/PowerShell/issues/68 And https://github.com/SublimeText/PowerShell/issues/77

Environment

  • Editor and Version (VS Code, Atom, Sublime): Sublime
  • Your primary theme: Default

Issue Description

There is inconsistency in the chained methods:

$users.Split(",").Trim()

Split and Trim get 2 different regions.

Same applies for

$foo.bar

vs

($foo).bar

Screenshots

image

Expected Behavior

  • Trim() and Split() should be the same region type
  • .bar in first and second case should be the same region type

Code Samples

$users.Split(",").Trim()

$foo.bar
($foo).bar

vors avatar May 26 '18 21:05 vors

even disregarding the chaining, scoping $variable.anything as an entity.name.function.invocation is very wrong - invocations should never get an entity scope, as they show up in the symbol list. The . should be punctuation.accessor.dot and the identifier afterwards in this case is not a function, just a property, so variable.other.member would suffice. If it were a function, variable.function would be appropriate.

keith-hall avatar May 31 '18 18:05 keith-hall

@keith-hall you'll find a lot of scoping issues and one of the overarching projects is going to be to review them all. As best as possible I am following https://www.sublimetext.com/docs/3/scope_naming.html; However, I am not a developer so I don't always know what a particular thing in the syntax is fundamentally called and referencing other languages that may also be scoped incorrectly doesn't always help. I have a decent idea but there are gaps.

So far I've fixed some of them, I've left some of them the way they were for the time being, and in at least one instance I set one incorrectly on purpose to meet user expectation across 99% of themes until the actual patterns could be redefined.

One of the issues with the PS syntax file as it stands is that a number of things are defined in pieces with no connections even when directly related. That means you cannot assign a proper parent or meta scope for fallback when themes don't cover one of the more granular scopes. One of my goals is to fix a lot of those issues (variables and function calls are top of the list right now) but some scopes are incorrect for the time being for that reason.

This discussion from 2016 is still open: https://github.com/PowerShell/EditorSyntax/issues/8 but it may be worth starting it from scratch at this point.

omniomi avatar May 31 '18 19:05 omniomi