netbeans icon indicating copy to clipboard operation
netbeans copied to clipboard

PHP: Added CSS embedding to heredoc/nowdoc

Open troizet opened this issue 1 month ago • 4 comments

Added CSS embedding to heredoc/nowdoc. Partially implements feature request #5010.

Before: before

After: after

css_autocomplete css_embedding_background_coloring

Based on discussion #7933, I was able to piece together the puzzle and add CSS embedding to heredoc and nowdoc.

The CssEmbeddingProvider and test code is borrowed from the Javascript2 VUE module. The background highlighting code is borrowed from the HTML Editor module.

I also encountered a formatter execution order issue, which was described by @matthiasblaesing in commit be093c3486ff0b9858aea8b2274ca646f87d48c6. I solved this issue by adding a hack to TaskHandler.java: https://github.com/troizet/netbeans/blob/f9f1f9fe22e4a46f4910a476449725c4a72fbb7f/ide/editor.indent/src/org/netbeans/modules/editor/indent/TaskHandler.java#L170-L186


^Add meaningful description above

Click to collapse/expand PR instructions

By opening a pull request you confirm that, unless explicitly stated otherwise, the changes -

  • are all your own work, and you have the right to contribute them.
  • are contributed solely under the terms and conditions of the Apache License 2.0 (see section 5 of the license for more information).

Please make sure (eg. git log) that all commits have a valid name and email address for you in the Author field.

If you're a first time contributor, see the Contributing guidelines for more information.

If you're a committer, please label the PR before pressing "Create pull request" so that the right test jobs can run.

PR approval and merge checklist:

  1. [ ] Was this PR correctly labeled, did the right tests run? When did they run?
  2. [ ] Is this PR squashed?
  3. [ ] Are author name / email address correct? Are co-authors correctly listed? Do the commit messages need updates?
  4. [ ] Does the PR title and description still fit after the Nth iteration? Is the description sufficient to appear in the release notes?

If this PR targets the delivery branch: don't merge. (full wiki article)

troizet avatar Dec 10 '25 16:12 troizet

@tmysik I've made the corrections.

troizet avatar Dec 12 '25 12:12 troizet

@troizet thanks!

tmysik avatar Dec 12 '25 12:12 tmysik

Updated the pull request. Fixed the slowdown when opening PHP syntax highlighting settings.

troizet avatar Dec 12 '25 15:12 troizet

@troizet in general this looks very nice. I have a concern about scalability of the approach. I tripped over the modification to the lexer structure and the introduction of a special tokenid for CSS. Given that the referenced ticket already asks for HTML, SQL and JSON I see this growing in the future.

Please have a look at this illustration for the idea:

https://github.com/apache/netbeans/commit/8cdb9af84a62c31270488eb1ded1e92e93d21a8e

The use of the property token allows us to transfer the info from the lexer to the analyser without changing the token ids. New mapping would just report a different mimetype. This is currently considered an implementation dependency so the property was marked appropriately and the constant defined outside the exported classes.

What do you think?

matthiasblaesing avatar Dec 14 '25 17:12 matthiasblaesing

What do you think?

Great idea! I'll try to make some changes as soon as possible. Thanks!

troizet avatar Dec 16 '25 11:12 troizet