nette-intellij / intellij-neon

Neon language support for PhpStorm / IntelliJ IDEA
http://plugins.intellij.net/plugin/index?pr=webide&pluginId=7060
MIT License
96 stars 43 forks source link

Suggesting configuration parameters in section "Nette" #18

Open brabijan opened 11 years ago

brabijan commented 11 years ago

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

juzna commented 11 years ago

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 commented 11 years ago

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 commented 11 years ago

@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 commented 11 years ago

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 commented 11 years ago

@HosipLan :+1:

juzna commented 11 years ago

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 commented 11 years ago

@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 commented 11 years ago

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

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

fprochazka commented 11 years ago

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

dg commented 11 years ago

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

hrach commented 11 years ago

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 commented 11 years ago

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 commented 11 years ago

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:

dg commented 11 years ago

By config*.neon ?

hrach commented 11 years ago

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

dg commented 11 years ago

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

juzna commented 11 years ago

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 commented 11 years ago

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

fprochazka commented 11 years ago

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

juzna commented 11 years ago

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

Thanks!