smuuf / vscode-latte-lang

☕ Nette Latte extension for VS Code.
MIT License
5 stars 0 forks source link

Question about implementation requirements #5

Open gebeer opened 8 months ago

gebeer commented 8 months ago

Thank you for the great extension.

I can't get it to work when using Latte outside the Nette Framework.

Is the definition of a FooTemplateParameters class following the example at https://latte.nette.org/en/type-system required for type hinting to work?

I guess yes. Just wanted to make sure.

smuuf commented 8 months ago

Hi, I've not (yet) tested it outside Nette, but AFAIK the extension shouldn't really be dependent on it in any way.

Type hinting via specifying {templateType ...} is now pretty well supported, but also shouldn't be a requirement.

As long as you specify some (existing) types for some variables in a .latte file via tag {var MyNamespace\MyClass $object = ...} or via tag {varType MyNamespace\MyClass $object}, the extension should be able pick that up.

If it doesn't work for you, is there maybe anything useful visible in the Help > Toggle Developer Tools JS console in vscode? :thinking:

smuuf commented 8 months ago

Here viewing Latte file in https://github.com/ApiGen/ApiGen codebase, as an example of working vscode-latte-lang extension outside of Nette framework app:

obrazek

BernhardBaumrock commented 8 months ago

Thx @smuuf it's strange. It does not work for me:

image

Any ideas what we could be missing?

smuuf commented 8 months ago

obrazek

... 🤔

As I asked the original issue author - is there maybe some error visible in vscode's JS console (in Developer Tools)? Also what dev environment do you have? Pure Windows? Windows/WSL? Linux?

gebeer commented 8 months ago

obrazek

... 🤔

As I asked the original issue author - is there maybe some error visible in vscode's JS console (in Developer Tools)? Also what dev environment do you have? Pure Windows? Windows/WSL? Linux?

Thank you for looking into this. The described behaviour happens on both, Windows 11 and Linux. In VSCode, VSCodium and Cursor Editors (both forks of VSCode) No relevant errors/warnings in devtools. Here some screens from Cursor Editor running on Linux.

class-definition

type-unknown

devtools

BernhardBaumrock commented 8 months ago

Thx @smuuf what console are you talking about? One of these? Sorry I'm using VSCode every day but only as a user, I have never touched anything beyond settings ;)

image

The screenshot is from cursor, here's the same with vscode:

image

I'm on Mac as you can see :)

Thx for your help @smuuf !

smuuf commented 8 months ago

@gebeer Are you sure you have the correct fully qualified class name in the template? In your screenshot I see RockPageBuilder\Model3D vs RockPageBuilderBlock\Model3D.

BernhardBaumrock commented 8 months ago

@smuuf I think you are right here, but I tried the same with the repo you linked to. And these kind of typos only happen because the IDE does not suggest the correct type as it would in PHP:

image

Not sure if your extension should also add autocomplete for vartypes?

gebeer commented 8 months ago

@gebeer Are you sure you have the correct fully qualified class name in the template? In your screenshot I see RockPageBuilder\Model3D vs RockPageBuilderBlock\Model3D.

Doesn't make a difference: vartype

daun commented 2 days ago

Just installed the extension, amazing work, thanks a lot for this! Just wanted to add a note that type hints seem to be working correctly in the latest version, but best to check in with @gebeer if he's still seeing the issue.

Screenshot 2024-10-25 at 15 16 01
BernhardBaumrock commented 2 days ago
image

@daun it's still not working for me and has never been :( Any ideas?

daun commented 2 days ago

@BernhardBaumrock Just guessing: Might be an issue with intelephense, if that's used to gather type information? I remember having issues with it not properly starting. But if you're seeing the typehints in regular PHP files, that might not be it. Also, could be a compatibility issue with another extension — disabling all extensions except this one might give some clues.