Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggesting configuration parameters in section "Nette" #18

Open
brabijan opened this issue May 2, 2013 · 20 comments
Open

Suggesting configuration parameters in section "Nette" #18

brabijan opened this issue May 2, 2013 · 20 comments

Comments

@brabijan
Copy link

brabijan commented May 2, 2013

It would be nice, if plugin can suggest me configuration parameters in Nette section (session, database, latte, etc...)

@juzna
Copy link
Collaborator

juzna commented May 2, 2013

It is already there, perhaps new keywords shall be added as well? Or I guess we shall add these into a separate nette plugin, because this is not raw neon

@juzna
Copy link
Collaborator

juzna commented May 3, 2013

Similar to #9

I guess we shall have some external definition of available keywords, in several contexts. Is there something like Neon Schema? (http://json-schema.org/examples.html, http://en.wikipedia.org/wiki/XML_Schema_(W3C))

@juzna
Copy link
Collaborator

juzna commented May 3, 2013

@hosiplan, you've got many configurator extensions which would be nice to have autocompletion as well. Any ideas how to list available keywords for each extension?

@fprochazka
Copy link
Collaborator

I would postpone this. Soon there will be validator for compiler parameters in @nette and than it would be much easier to get standardtized structure to validate over and autocomplete. cc @dg

@hrach
Copy link
Collaborator

hrach commented May 3, 2013

@hosiplan 👍

@juzna
Copy link
Collaborator

juzna commented May 3, 2013

Actually I don't want to postpone this, because I love autocompletion (im too laz to typ ful words)

@dg have you got something already? Can we discuss it to check whether it would be easy to add IDE support for it?

@fprochazka
Copy link
Collaborator

@juzna you may add autocompletion for nette section (it wouldn't change that much), but general support would be harder and should wait for the validators.

@dg
Copy link
Contributor

dg commented May 3, 2013

There is a difference between DI service schema and config.neon schema. Because there are 4 steps of processing:

  • convert NEON to intermediate format (because we have support for different formats)
  • merge multiple files
  • expand parameters (in 2.1, so it is impossible to have validation scheme in 2.0)
  • validating (in 2.1)

So I have plan to add some validation scheme, but it will be validator for partially processed file, not for source neon file.

@fprochazka
Copy link
Collaborator

@dg the point here is to have autocompletion based on the defined validation schema, not validation itself (well, maybe) :)

@dg
Copy link
Contributor

dg commented May 3, 2013

I understand, I'm just saying that there will be no validation schema for neon in Nette.

@hrach
Copy link
Collaborator

hrach commented May 3, 2013

Imo we should split neon & neon config support. Neon config should have another extension. Neon support should be clear with php class autocompletion etc. Neon config should have some validation, autocompletion, section hinting, etc.

@juzna
Copy link
Collaborator

juzna commented May 3, 2013

Yep we may split the plugin eventually, but not now. It's not about having hundreds of plugins, but about getting some work done ;)

I'll try to prepare some kind of very simple neon schema which will be used for autocompletion and validation in IDE.

@hrach
Copy link
Collaborator

hrach commented May 3, 2013

well, I wasn't talking about splitting the plugin, but splitting the available features for autocompletion. The first step is the detection, what do you want to validate/autocomplete.
possibilites:

  • by extension - sth like *.neon and *.neonc
  • by heuristic, comment, annotation?

@dg
Copy link
Contributor

dg commented May 3, 2013

By config*.neon ?

@hrach
Copy link
Collaborator

hrach commented May 3, 2013

@dg: yes, this was meant as heuristic, also sth like config/*.neon :)

@dg
Copy link
Contributor

dg commented May 3, 2013

(BTW, we need to version Neon syntax, because it is developed)

@juzna
Copy link
Collaborator

juzna commented May 4, 2013

What about this kind of annotations?

/** Edit: DEPRECATED: do not read this anymore!!! Proceed to the other example. */
class NetteExtension extends Nette\Config\CompilerExtension
{
    /** @configDefaults("nette") */
    public $defaults = array(
        'session' => array(
            'debugger' => FALSE,
            'iAmUsingBadHost' => NULL,
            'autoStart' => 'smart',  // true|false|smart
            'expiration' => NULL,
        ),
    );

    /** @configDefaults("nette.database.*") */
    public $databaseDefaults = array(
        'dsn' => NULL,
        'user' => NULL,
        'password' => NULL,
        'options' => NULL,
        'debugger' => TRUE,
        'explain' => TRUE,
        'reflection' => 'Nette\Database\Reflection\DiscoveredReflection',
    );

Or an unobstrusive way, similar to Factory Methods which are built in PhpStorm:

<?php
// .phpstorm.meta.php
namespace NEON_META {                                                 // we want to avoid the pollution
  $CONFIG_KEYS = [
    'dibi' => [ 'host' => '', 'dbname' => '', 'user' => '', 'password' => '' ],  // unobstrusive static definition

    'nette' => \Nette\Config\Extensions\NetteExtension::$defaults,    // no problem the property is actually not static
  ];

@juzna
Copy link
Collaborator

juzna commented May 4, 2013

I've got proof of concept of the unobtrusive way ready (8875871) and it's pretty pleasant to use. I think it's better than annotations (the first way).

@fprochazka
Copy link
Collaborator

Great, now the application can generate it using some kind of extension :)

@juzna
Copy link
Collaborator

juzna commented May 8, 2013

I created a sample metadata file from which I believe it would be possible to provide very good autocompletion. Please

  • have a look at it
  • try to add more metadata for your compiler extensions, so that we can see whether it's understandable
  • provide any comments

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants