Git Product home page Git Product logo

netbeans-php-blade-plugin's Introduction

Netbeans Php blade editor

Netbeans Php blade editor using Antlr Lexer and Parser.

Note

This is an extract of a new netbeans modules suite : https://github.com/haidubogdan/nb-18-php-blade-plugin still in development.

Installation

Requirements

Installing from package

The plugin is not uploaded on netbeans site as it is still in experimental version.

Check for relase versions at : https://github.com/haidubogdan/netbeans-php-blade-plugin/tags

  1. In Netbeans open Tools -> Plugins, select Downloaded tab.
  2. Click "Add plugins" and select the file from the nbm folder.
  3. Select the checkbox next to the "Blade for Netbeans" plugin and click Install.
  4. Restart the IDE when demanded and enjoy your new plugin.

Installing from source

  1. Clone the git repository.
  2. Start a new Netbeans project, choose NetBeans module as project type.
  3. Setup your project.
  4. Right-click on project name and choose Create NBM.
  5. Install the NBM file as described in "Installing from package".

For more information refer yourself to: http://platform.netbeans.org/tutorials/nbm-google.html

Usage

Features

  • Blade syntax coloring

syntax coloring

  • Declaration finder for
    • php elements
    • included paths
    • yield ids (section)
    • stack elements
  • Php code completion inside expressions, and echo tags

completion

  • Brace matcher and folding

folding

  • Find template usage (only in the blade files context)

template usage

Custom directives

Project -> Properties -> Laravel Blade -> Custom Directives

Just add the php file where you added the custom directive implementation as in https://laravel.com/docs/10.x/blade#extending-blade.

VIews folder

If you use blade templates outside of the generic laravel framework or have custom templates folders you can configure them for a project.

This will help the yielid and view path completion

Reformat and indentation

Experimental formatting and indenting


Known issues

Warning

.

  • The duplicate file process can create a "blade_1.php" file because by default the extension of a file is the last ".*" element. So for "blade.php" the extension found is ".php"
  • HTML join embedding breaks indentation especially in <script> and <style> context

brace matcher

  • Emoji character can break brace matching.

completion

  • slowness or process is stuck

Why Netbeans 18+ requirement ?

The plugin is implemented using ANTLR lexer and parser. I migrated from Jflex and jcup tools due to scalability reason. Antlr plugin was introduced with Netbeans 18.

Still missing

Some features are not implemented in this plugin version :

  • variable completion from controller
  • components completion and declaration finder
  • error diagnostics for inline php code

netbeans-php-blade-plugin's People

Contributors

erikn69 avatar haidubogdan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

netbeans-php-blade-plugin's Issues

Open files on `@extends`, `@include` not working

Hi, thanks for the amazing work, i'm using Netbeans 12.5

When I use @include and then [CTRL] + CLICK nothing happens, even with right click and Navigate > Go to declaration
It's that a bug or need some configuration for getting work, file path(string value) shows underline like link, but no file opens

`unknown directive` on custom blade directives

  • #8
    In my previous issue you added the functionality to autocomplete the blade directives(custom/3rd party), in version 2, it still works but it marks them as unknown directive, but if they are added for autocompletion they should be known, or am i missing something?
    This leaves too many messages in all my documents, it's harder to focus on the messages that really matter.

`@include` path suggestions problem

When you are typing, starts path sugestions
image
Then try to type the point for subdirectory, good so far on path suggestions, sometimes syntax highlight breaks
image
Also after type first character, suggestions stops too
image
image

blade file duplication has wrong increment placement

It is a known issue.
It's being fixed in t_v2_3 branch.
The issue is just for tracking.

issue

In a folder when you try to copy a blade file 'my_file.blade.php' you will get 'my_file.blade_1.php' because the extension is considered the last string after the "." symbol.

@json function is not working

@JSON function is not working

this is my code

<script>
    @if( !defined('ADDRESS_PARAMS_SET') )
        var ADDRESS_PARAMS = {};
        ADDRESS_PARAMS.COUNTRIES        = @json( $defaults->countries );
    @endif
</script>

this is my error message

image

Weird behaivor on highlighting

Sometimes this happens

image
image

When open a blade file happens, also when you use autocomplete with tags like @if
It breaks the highlight of opening/ending tags, those html are outer of any blade directive
Sometimes when you close and reopen the file, it starts working again
other times it starts working again after change something(like adding an space)

image

Also when i use autocomplete, it automatically reformat indentation of other blade tags on the same file

Declaration finder gets stuck when changing Projects

  1. I have two projects.
  2. I wait for all the indexing to finish.
  3. I try a declaration on one element like a class or function.
    This will work quite fast.
  4. On the next project we have a delay when we want to use declaration finder for a new element.

TAB not working after html close tag

In a bade file. After a new line inserted at the end of a close tag. The tab button stops working.

@section('jj')
    <div>
        <div></div>
    </div>
    [cursor tab stops]
@endsection

too many tokens for antlr lexer inside foreach

@foreach(My_Class::getData() as $id => $data)
    <option value="{{$id}}">{{$data['label']}}</option>
@endforeach
L1: 137 (DIRECTIVE) | 133 |  (PHP_EXPRESSION)M |  (PHP_EXPRESSION)y |  (PHP_EXPRESSION)_ |  (PHP_EXPRESSION)C |  (PHP_EXPRESSION)l | 135 |  (PHP_EXPRESSION)s |  (PHP_EXPRESSION): |  (PHP_EXPRESSION): |  (PHP_EXPRESSION)g |  (PHP_EXPRESSION)e |  (PHP_EXPRESSION)t |  (PHP_EXPRESSION)D |  (PHP_EXPRESSION)a |  (PHP_EXPRESSION)t |  (PHP_EXPRESSION)a | 133 | 134 | 135 |  (PHP_VARIABLE)$id | 136 |  (PHP_VARIABLE)$data | 134 | 
L2: 2113 |  (HTML)value | 117 | 109 |  (PHP_VARIABLE)$id | 121 |  (HTML)> | 109 |  (PHP_VARIABLE)$data |  (PHP_IDENTIFIER) | 121 |  (HTML)</option> | 
L3: 338 (DIRECTIVE) | -1

This can decrease parsing performance

[BUG] On blade comments

I'm trying to write {{-- --}}, but it only writes {{-
So i try to copy/paste {{-- and then netbeans freezes, it needs a restart

Netbeans Version: 16
Plugin Version: php-blade-14102022.nbm

Code highlighting | Namespace import

First of all, this plugins is amazing!

Thanks for all the work guys. This plugin really helps with developing in laravel.
I tested it in Netbeans 17 and it works great.

besides that is works great here are a few options that can be fixed in the next verisons.

Namespace use statements

When importing classes using the use the editor does not bind the classes you import. (No typehinting etc)
Also the editor does not register the imported class as being used.

image

shorthand if statement

When using the ? : the highlighting does't work anymore.
image

Livewire location

Good morning,

This is not an issue but i noticed in the new release you added the livewire location withing the Http folder.
In new laravel installations that includes the new livewire major version starting from 10.* > the livewire folder is located directly in the App folder.
App/Livewire instead of App/Http/Livewire

image

This may cuase some issues down the path.

`Unclosed @if` when `@endif` exists

Try this, but separately, imagine that they are inside some loop

@if(true) @continue @endif

@if(true) @break @endif

@if(true) 
    @break @endif

@if(true) 
    @continue @endif

Blade Sintax Error Unexpected String, `@extends`,`@yield` needs extra support

Suppose you have this

<?php
$string='string';
function getString(){
   return 'string';
}
?>

Now try this

@extends(getString())
or
@extends($string)

@yield(getString())
or
@yield($string)

That works on laravel but this plugin give me
Blade Sintax Error
Unexpected: String
After: )

Maybe trying other things also, for example

@include(($condition?'test1':'test2').'.blade_file')

If you have html/js with an @ it fails too, try this and look at the error

<script>
// @ (
</script>
<script>
// @ ''(
</script>

[BUG] Blade autocomplete break **CTRL + Z** when custom blade directives

Custom blade directives are added on Project Properties -> Blade Directives

Steps to Reproduce:

Just write anything, and use Blade Autocomplete for any custom blade directive,
after text autocomplete try CTRL + Z for undo everything,
it doesn't works anymore, you can't undo the directive and the first writing

With the Laravel oficial blade directives CTRL + Z works

NOTE: I'm trying with
spatie/laravel-permission/src/PermissionServiceProvider.php#L103-L110,
spatie/laravel-blade-javascript/src/BladeJavaScriptServiceProvider.php#L21-L25
spatie/laravel-honeypot/src/HoneypotServiceProvider.php#L45-L47

Blade Sintax Error on CSS

Example:

<style>
@-webkit-keyframes swal2-toast-show{
    0% { transform : translateY(-.625em) }
    100%{ transform : translateY(0) }
}
</style>

I get
Blade Sintax Error Unexpected ) after variable 'translateY'
image

Plugin Breaks how JS works

Suppose you have

<script>
var myVar={key:[]};
myVar.key.length;
</script>

With this plugin when you double click on length, all the line gets selected
image
Without this plugin when you double click on length, only length gets selected
image

@if formatting is not working

@if formatting is not working

actual formatting

        @if ($params->allow_google_in_country)
        <div class="form-group row">
            aaa
        </div>
        @endIf

expected formatting

        @if ($params->allow_google_in_country)
            <div class="form-group row">
                aaa
            </div>
        @endIf

at netbeans 12.6, code formating has some errors

erre1. Format of html was running away, bringing more and more spacing.
ex1:

not format yet : <div class="logout"><a href={{url("/logout")}}> logout </a></div>
format once:  <div class="logout"><a href={{url("/logout")}}      > logout </a></div>
format twice:  <div class="logout"><a href={{url("/logout")}}              > logout </a></div>

....
ex2:

not format yet : <li><?= $content->date_create ?>></li>
format once:  <li><?= $content->date_create ?>     ></li>
format twice: <li><?= $content->date_create ?>              ></li>

error2. netbeans display syntax error
ex1: @section({{ $content }})

Blade Sintax Error Unexpected: End of File Expected: T_BLADE_COMMENT, T_BLADE_STOP

From #12, I have that problem too, i don't know how to avoid it

<script>
// @ (
</script>
<script>
// @ ''(
</script>
@section('content')
  <td style="mso-number-format:&#39;@&#39;;"></td>
@endsection
@section('content')
  <span data-formatcode="@"></td>
@endsection

Blade Sintax Error Unexpected: End of File Expected: T_BLADE_COMMENT, T_BLADE_STOP

when after @ there is a especial character or a space it is not a blade directive

No highlight open tags `@canany`/`@endcanany` when selecting end tags

@can/@canany are laravel core but shows unknown directive, Fix on v2.0.5
also no highlight tags, if you select open/close canany, the counterpart is not highlighted, it is difficult to find where the block starts/ends
On can/@canany not works highlight on selecting end tag

image

@canany([''])

@endcanany

@can('')

@endcan

Missing highlighting in blade core/custom attributes

https://laravel.com/docs/9.x/blade#additional-attributes

image

<span @class([
    'p-4',
    'font-bold' => $isActive,
    'text-gray-500' => ! $isActive,
    'bg-red' => $hasError,
])></span>
<span @style([
    'background-color: red',
    'font-weight: bold' => $isActive,
])></span>
<input type="checkbox" @checked(old('active', $user->active)) />
<option value="{{ $version }}" @selected(old('version') == $version)>test</option>
<button type="submit" @disabled($errors->isNotEmpty())>Submit</button>
<input type="email" @readonly($user->isNotAdmin()) />
<input type="text" @required($user->isAdmin()) />
<input type="text" @echoIf('data-test="test"',$user->isAdmin()) />

Plugin not working for NetBeans 12.6

I wanted to install your plugin in NetBeans 12.6 and I got this error:
image

And as you can see, the scrollbar is long, but I think those errors are the same. So this plugin is not working for NetBeans 12.6. I see that you already had problems to support each new version which is very simple. Build your plugin with the most minimal/oldest version where your plugin should work up on. So if you want to support 12.0, 12.1, 12.2....12.6, 13, you just need to build it for 12.0 and it will work to the latest, if you don't use a specific API which will change etc. But this will work afaik.

Blade Sintax Error, Unexpected End of File, Expected T_BLADE_STOP

Blade Sintax Error
Unexpected End of File
Expected T_BLADE_STOP

You get that exception if you do

@section('modals')
   <!--contents-->
@append

@append is also a close tag for @section but it is not supported,
i think also @show,@stop are closing tags for @section too
for @section @parent directive is missing

There is a lot mising basic blade directives like
@method,
@can,@endcan,
@canany,@endcanany,
@while,
@error,
@hasSection,
@sectionMissing,
@checked,
@includeWhen,
@includeUnless,
@includeFirst,
@each,
@once,
@pushOnce
and more

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.