This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 244054 - twig autocomplete not working
Summary: twig autocomplete not working
Status: RESOLVED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Twig (show other bugs)
Version: 8.0
Hardware: All All
: P2 normal with 1 vote (vote)
Assignee: junichi11
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-24 19:54 UTC by dootzky
Modified: 2017-11-06 11:58 UTC (History)
6 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
GIF for the delimiters (153.17 KB, image/gif)
2016-12-11 04:03 UTC, junichi11
Details
GIF for quotes and brackets (241.74 KB, image/gif)
2016-12-11 04:16 UTC, junichi11
Details
proposed patch (111.32 KB, patch)
2016-12-15 05:53 UTC, junichi11
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description dootzky 2014-04-24 19:54:39 UTC
I have the default plugin for Twig in my PHP Netbeans 8.0

Product Version: NetBeans IDE 8.0 (Build 201403101706)

Twig plugin:
Version: 1.19.1 Source: NetBeans IDE 8.0 (Build 201403101706)

It's enabled and everything.
The color syntax work as expected, but there is no autocomplete? 

So for example, in my file which is named "index.html.twig", I try to type something like this 

{{ 

and it's not auto-closing those brackets.

I try to do a foreach, like so:

{% 

and it's not closing anything. 

Even when I have a {% for %}, it's not ending it with {% endfor %}
i.e.
{% for user in users %}

Is this the expected behavior? 

You know how when you type
<div>

it generates the closing div tag automatically, right? 
so it just adds
</div>

Perfect.

Does that exist for Twig plugin? Or do we really have to type it all out, every time? 

Just curious. 
I mentioned this on the forum, and a nice person told me to report an issue if I feel this should be there, so - hope it helps.

http://forums.netbeans.org/viewtopic.php?p=156987#156987

Thanks guys! :)
Comment 1 Ondrej Brejla 2014-04-25 07:08:57 UTC
Autoclosing doesn't work (it wasn't implemented). It's an enhancement for next release.
Comment 2 dootzky 2014-04-25 11:43:37 UTC
Ah, alright. 

Thanks. :)
I'll close the "bug" report then.

Have a great Friday! :)
Comment 3 gekannt 2015-02-16 00:31:55 UTC
More than half of year is passed. Any progress? This feature is very necessary. I even think of starting to use Sublime 2 only for editing of twig templates.
Comment 4 hegedusarpad 2016-04-27 10:24:40 UTC
I am also interested to see this implemented.
Comment 5 Tomas Mysik 2016-06-06 08:26:16 UTC
Taking over.
Comment 6 Supervan 2016-11-17 08:47:25 UTC
Hi Tomas,

Any feedback regarding the auto closing of the brackets when using Twig in netbeans 8.2

The concept is similar to whats already being implemented in PHP with the auto-closing brackets. 

Please fix this.

Thanks

Sarel
Comment 7 Tomas Mysik 2016-11-21 07:50:26 UTC
Perhaps Junichi could have time to look at it, please?

Thanks.
Comment 8 junichi11 2016-11-21 11:14:59 UTC
(In reply to Tomas Mysik from comment #7)
> Perhaps Junichi could have time to look at it, please?

I'll try looking at it later. (I'm looking at another issue now.)

Thanks.
Comment 9 Supervan 2016-11-28 05:40:58 UTC
Good day,

Thanks for responding, your time and effort appreciated.

Please contact me directly if i need to explain or test.

Thanks
Sarel
Comment 10 junichi11 2016-12-07 09:46:53 UTC
I'll support the following delimiters:

- {{ ({{  }})
- {% ({%  %})

{# is not supported. Because it would be annoying if you want to comment-out the specific part manually(Although you can use the toggle comment feature.).

> Even when I have a {% for %}, it's not ending it with {% endfor %}

In this case, I think that you can use the code template feature.

Thanks.
Comment 11 junichi11 2016-12-11 04:03:09 UTC
Created attachment 163201 [details]
GIF for the delimiters

This is available in HTML part. 
So it doesn't work fine JS and CSS parts now. This means that it doesn't work in the value of some attributes for HTML tag. e.g. id="", style="", onload="". OTOH, <a href="{{"> works fine.

Are the delimiters used in JS and CSS parts?
Perhaps, the JS case can be fixed. But the CSS case has a problem. 

Thanks.
Comment 12 junichi11 2016-12-11 04:16:30 UTC
Created attachment 163202 [details]
GIF for quotes and brackets

I'm also adding quotes and brackets completion now.

I'm going to add the option for these features to Editor > Code Completion > Twig File.

Thanks.
Comment 13 junichi11 2016-12-15 05:53:37 UTC
Created attachment 163245 [details]
proposed patch

Tomas, To add Options for code completion, I want to add php.twig module to options.editor module as a friend. Do we have to ask a specific person that? or Can I do that?

If I can do that, I'm going to push my changes tomorrow (or later).

Thanks!
Comment 14 Tomas Mysik 2016-12-15 06:46:26 UTC
(In reply to junichi11 from comment #13)
> Tomas, To add Options for code completion, I want to add php.twig module to
> options.editor module as a friend. Do we have to ask a specific person that?
> or Can I do that?

Adding TomasZ to CC - Tome, could you please confirm whether it is OK or not? If not, what we need to do exactly? Thanks!

> If I can do that, I'm going to push my changes tomorrow (or later).

Let's wait for TomasZ. Anyway, as always, thanks for the patch, Junichi!
Comment 15 Tomas Zezula 2016-12-15 08:19:58 UTC
Tome, feel free to do it.
Comment 16 Tomas Mysik 2016-12-15 08:35:59 UTC
Thanks, Tome!

Junichi, one minor issue - the Twig dependency on options.editor should be 1.60 (there is 1.59 in the patch). Otherwise, please apply the patch.

Thanks!
Comment 17 junichi11 2016-12-15 09:46:01 UTC
Thank you guys!

(In reply to Tomas Mysik from comment #16)
> Junichi, one minor issue - the Twig dependency on options.editor should be
> 1.60 (there is 1.59 in the patch). Otherwise, please apply the patch.

Thanks for catching it! I'll fix it, then push changes tomorrow.
Comment 18 Tomas Mysik 2016-12-15 09:58:13 UTC
(In reply to junichi11 from comment #17)
> push changes tomorrow.

Perfect, thanks a lot!
Comment 19 junichi11 2016-12-16 02:01:05 UTC
Fixed.

http://hg.netbeans.org/web-main/rev/1a6fec7f795b

There are a few differences between this commit and the attached patch.
- options.editor dependency: 1.59 -> 1.60
- Remove the same method in TwigTypedTextInterceptor: Use TypingHooksUtils.sameAsExistingChar() instead
- Change a class name: CharRemoverFactory -> RemoverFactory

Thanks!
Comment 20 Tomas Mysik 2016-12-16 06:42:07 UTC
Thanks a lot, Junichi! I noticed that PHP build now has one FindBugs warning [1] (which is related to your commit) and some formatting test failures [2] (I am not sure whether they can be related).

Thanks.
[1] http://deadlock.netbeans.org/job/PHP-build/2865/findbugsResult/?
[2] http://deadlock.netbeans.org/job/PHP-build/2865/#showFailuresLink
Comment 21 Quality Engineering 2016-12-17 02:57:25 UTC
Integrated into 'main-silver', will be available in build *201612170001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/1a6fec7f795b
User: Junichi Yamamoto <junichi11@netbeans.org>
Log: #244054 - twig autocomplete not working
Comment 22 Supervan 2016-12-23 13:58:32 UTC
Hi,

Thanks for the fix.

How can I install this fix.
Im using NetBeans IDE 8.2 (Build 201609300101)

Thanks
Comment 23 junichi11 2016-12-23 16:35:28 UTC
(In reply to Supervan from comment #22)
> How can I install this fix.
> Im using NetBeans IDE 8.2 (Build 201609300101)

You cannot use it in NetBeans 8.2. Please use the development version [1].
If you find some problems, please submit them as new issues. (Please don't add them here as comments.) 

Thanks.

[1] http://bits.netbeans.org/download/trunk/nightly/latest/
Comment 24 Radioaktywnyja 2017-02-09 20:55:01 UTC
Hi

Do you know when this patch will be included to official version?
Comment 25 junichi11 2017-02-09 21:59:06 UTC
(In reply to Radioaktywnyja from comment #24)
> Hi
> 
> Do you know when this patch will be included to official version?

It's the next version (probably NB9.0).

Thanks.
Comment 26 Supervan 2017-11-06 06:44:14 UTC
Hi,

Im Using NetBeans IDE Dev (Build 201710190002)

I noticed the Twig Autocomplete not working, maybe its not added to this build.

Thanks
Comment 27 junichi11 2017-11-06 11:14:22 UTC
(In reply to Supervan from comment #26)
> Hi,
> 
> Im Using NetBeans IDE Dev (Build 201710190002)
> 
> I noticed the Twig Autocomplete not working, maybe its not added to this
> build.
> 
> Thanks

Please don't reopen it. If you have a problem, just submit it as a new issue.

BTW, It works fine in my environment:
Product Version: NetBeans IDE Dev (Build 201711060002)
Java: 1.8.0_151; Java HotSpot(TM) 64-Bit Server VM 25.151-b12
Runtime: Java(TM) SE Runtime Environment 1.8.0_151-b12
System: Linux version 4.4.0-98-generic running on amd64; UTF-8;

Just try checking Tools > Options > Editor > Code Completion > Language: Twig File.
Comment 28 Supervan 2017-11-06 11:58:10 UTC
Thanks it working on this build.

Product Version: NetBeans IDE Dev (Build 201711060002)
Java: 1.8.0_101; Java HotSpot(TM) 64-Bit Server VM 25.101-b13
Runtime: Java(TM) SE Runtime Environment 1.8.0_101-b13
System: Windows 10 version 10.0 running on amd64; Cp1252; en_ZA (nb)
User directory: C:\Users\Sarelvdm\AppData\Roaming\NetBeans\dev
Cache directory: C:\Users\Sarelvdm\AppData\Local\NetBeans\Cache\dev

the Build 201710190002 didn't had the Language: Twig File installed under  
Tools > Options > Editor > Code Completion > Language