Vscode: PHP namespaced trait breaks syntax highlighting

Created on 12 Jul 2017  Â·  22Comments  Â·  Source: microsoft/vscode

  • VSCode Version: Code 1.14.0 (b8cd5b9556d8b70ea560d35b903422363f6c5c40, 2017-07-10T18:36:31.751Z)
  • OS Version: Windows_NT ia32 10.0.15063

Steps to Reproduce:

  1. Make a PHP class that uses a namespaced trait

Example:

<?php
class Foo {
    use Some\Thing;

    // Comment
    public $name = 'foo';

    public function __construct() {
        $this->doStuff();
    }
}

Reproduces without extensions: Yes

bug php upstream verified

Most helpful comment

Still broken after latest release (1.15.0)

-Update-

OPs issue is resolved.
Will open new issue for 'Multi-line use statements breaking syntax highlighting'

All 22 comments

I'm having same problem.
Using 'use' inside a class breaks syntax highlighting.

Yep, same here. It's worth noting that it only happens on traits that go deeper than the base namespace; single-level traits work normally. What I mean is: use Thing; works normally, but use Some\Thing; breaks syntax highlighting.

Here's a screenshot for those curious about this:

VSC PHP trait broken syntax highlighting

Erm... me too ?

The syntax highlighter breaks after the second use \Yard\Lib\JsConvert. Notice the broken orange text:

image

Somehow, my code in the bottom and the rest is highlighted properly..

I am seeing syntax highlighting being broken when a multiline use statement is in a class (regardless of namespace concerns). Randomly down the file it corrects itself.

Is is the same as this issue, or is a different issue specific to a multiline use statement? Can you post an example?

I am seeing the issue that this issue is pointing out and additionally what I mentioned.
First screenshot is the issue as described by the OP.
screenshot from 2017-07-12 15-58-25
Second screenshot is correct highlighting in regards to not having the use across multiple lines.
screenshot from 2017-07-12 16-04-28
Third is multiline breaking the highlighting.
screenshot from 2017-07-12 16-04-43
Sorry can create a new issue if needed.

This is a better representation of the OP's issue (without the multiline, to not confuse the issues)
screenshot from 2017-07-12 16-20-18

I've found a workaround until this gets fixed:

Add // } on a new line after the use. This fixes the formatting again.

So the original example would be:

<?php
class Foo {
    use Some\Thing;
    // }

    // Comment
    public $name = 'foo';

    public function __construct() {
        $this->doStuff();
    }
}

```php use \Yard\Lib\JsConvert as JsConvert;
use Some\Thing as Thing;

class Foo {
use JsConvert;
use Thing;
// }

// Comment
public $name = 'foo';

public function __construct() {
    $this->doStuff();
}

}```
This above code doesn't break any syntax highlighting.

This was broken in the release so surely they know the fix if they look at this issue? Expected it to be in the first round of bug fixes.

The highlighting of a PHP file is broken for this case:

<?php

namespace Foo;

class Bar
{
    use \Foo\Bar\Baz;

    public function baz()
    {
    }
}

It produces the following highlight:

capture d ecran 2017-08-03 a 16 50 37

  • VSCode Version: 1.14.2
  • OS Version: macOS 10.12.6

Steps to Reproduce:

  1. Use class with fully qualified namespace like use \Foo\Bar\Baz;

Reproduces without extensions: Yes

The issue has been resolved in https://github.com/atom/language-php/pull/249 so I wonder when the PHP grammar will be synced.

Thanks!

PS: duplicate here #31980

Please try it out in today's Insiders build, it's fixed there.

I'll try tomorrow. Thanks!

Le 3 août 2017 5:14 PM, "Rob Lourens" notifications@github.com a écrit :

Please try it out in today's Insiders build, it's fixed there.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/Microsoft/vscode/issues/30448#issuecomment-319999559,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAZlBi5B03lR2IlaohRLH_usBTEaLeMxks5sUePpgaJpZM4OVADr
.

Still broken after latest release (1.15.0)

-Update-

OPs issue is resolved.
Will open new issue for 'Multi-line use statements breaking syntax highlighting'

Works for me, can you post an example that shows the problem?

The problem is fixed in the insider build

capture d ecran 2017-08-11 a 08 59 43

Also in the 1.15.0

capture d ecran 2017-08-11 a 09 01 13

@roblourens will break my issue off into its own issue. The multi-line use statement is still broken.

Still needs work (#8074)

Same issue is happening with me, only this time it happens when I rename a trait method.

highlighting

@pbarnum Are you on stable or insiders? Seems to work fine for me on the insiders build (updated sometime yesterday afternoon).

trait method renamed

Whoops, sorry! I should be running the stable release. I'm running linux mint, and this is taken from the "About" window.

Version 1.17.2
Commit b813d12980308015bcd2b3a2f6efa5c810c33ba5
Date 2017-10-16T13:57:00.652Z
Shell 1.7.7
Renderer 58.0.3029.110
Node 7.9.0
Architecture x64
Was this page helpful?
0 / 5 - 0 ratings

Related issues

lukehoban picture lukehoban  Â·  3Comments

villiv picture villiv  Â·  3Comments

trstringer picture trstringer  Â·  3Comments

philipgiuliani picture philipgiuliani  Â·  3Comments

chrisdias picture chrisdias  Â·  3Comments