czyzby / gdx-lml

:octocat: LibGDX utility libraries.
Apache License 2.0
160 stars 25 forks source link

DTD ATTLIST not recognized in IntelliJ because of the comments for each attribute #9

Closed jpsgamboa closed 8 years ago

jpsgamboa commented 8 years ago

In IntelliJ 16 (I haven't tested anywhere else), the dtd file attributes are not recognized (and therefore the content assist won't work) with the current format:

<!ATTLIST visslider
    <!-- CellSizeLmlAttribute -->
    size CDATA #IMPLIED
    <!-- TreeNodeLmlAttribute -->
    node CDATA #IMPLIED>

They get recognized removing the comments between attributes:

<!ATTLIST visslider
    size CDATA #IMPLIED
    node CDATA #IMPLIED>

Or creating an ATTLIST for each attribute:

<!-- CellSizeLmlAttribute -->
<!ATTLIST visslider size CDATA #IMPLIED
<!-- TreeNodeLmlAttribute -->
<!ATTLIST visslider node CDATA #IMPLIED>

This last one would make the file even bigger, but would allow the comments to persist, though I don't know if they're really necessary (for the user) inside the dtd file.

czyzby commented 8 years ago

Huh, I was pretty sure it works and comments are allowed anywhere.

I think comments are necessary - they are the only link between DTD files and Java code. If you want to see the full documentation about a certain attribute or tag, you can CTRL click it in most IDEs, check out the name of the Java class in its comment and then go through LML sources.

I can, however, make it optional to generate comments.

czyzby commented 8 years ago

Use Dtd#saveSchema(LmlParser, Appendable) if you want to generate DTD with comments; use Dtd#saveMinifiedSchema(LmlParser, Appendable) instead.

This fix will be included in 1.6 version. Use 1.6.1.9.2-SNAPSHOT for now.

jpsgamboa commented 8 years ago

If I understood correctly, you altered the 1.6.1.9.2-SNAPSHOT to use this format:

<!-- CellSizeLmlAttribute -->
<!ATTLIST visslider size CDATA #IMPLIED>
<!-- TreeNodeLmlAttribute -->
<!ATTLIST visslider node CDATA #IMPLIED>

Because that's how my DTD got generated now. Intellij froze for a bit after generating the file (perhaps because it's massive - it loads all the attributes and tags instantly, though!), but the result is this thing of beauty:

lmlattlist

No more red spots!

I'd suggest leaving this as an option in 1.6, since we get to keep the comments.

Finally, thanks for how quickly you sorted this. It makes LML much much friendlier to use!

czyzby commented 8 years ago

Yes, I implemented it as you suggested and this is the default generation mode right now. I tested the generated DTD files (both with and without comments) with an external DTD validator and they seem to be correct.

czyzby commented 8 years ago

(By the way - you seem to have only 1 root actor in this template: table. In this case you don't need :noop root. :noop is a utility when you need to create a list of actors that should be added directly to stage with a single template - for example, a Table as background and a Window for actual GUI. Your template could look like this:

<?xml ...?>
<!DOCTYPE table SYSTEM "lml.dtd">

<table fillparent="true" align="top>
    ...
</table>

Not that your approach is wrong or anything, but keep in mind that you don't have to flood every template with :noop, especially since every macro parsing has some [small] overhead.)

jpsgamboa commented 8 years ago

Thanks for the tip! I actually added the file header and the <:noop> root tag to the file template in IntelliJ because I'm lazy, but I suppose most of my templates will end up having a relevant root element anyway so I'll change that!

czyzby commented 8 years ago

BTW, have you tried looking into my other extensions? I really appreciate the input of users other than myself, as I'm clearly biased and focused on the features that _I_ needed, which makes it harder to find bugs or lousy documentation. For example, I never needed DTD (having implemented gdx-lml, I pretty much memorized most of Scene2D API), and now it turns out it had some issues.

It would be great if you had a look at gdx-autumn (dependency injection with component scanning) and gdx-autumn-mvc (model-view-controller semi-framework on top of LibGDX) - you can start with this and this example. I think it makes it much easier to build applications, and the slightly longer initial loading time due to reflection use is a small price to pay.

But, obviously, I'll say things like that, as I'm the author. Oh, well.

jpsgamboa commented 8 years ago

I looked into autumn-mvc but decided against using it in my current project for fear of getting stuck at some point (I'm not too experienced and abstracting too much functionality makes it harder to get over some walls).

But since you seem to be actively maintaining this extensions (and willing to help) I will definitely look into it soon.

Right now I'm working on a desktop application and intend on using LML actively (it's truly awesome, thank you for this), so you can count on my input on it in the near future!

czyzby commented 8 years ago

Fair enough. Well, thanks for you help with LML. If you have any problems (with gdx-lml or any other library) don't hesitate to create issues.