Skip to content

Conversation

@troizet
Copy link
Collaborator

@troizet troizet commented Dec 10, 2025

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 be093c3. 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 troizet added PHP [ci] enable extra PHP tests (php/php.editor) Editor labels Dec 10, 2025
@apache apache locked and limited conversation to collaborators Dec 10, 2025
@apache apache unlocked this conversation Dec 10, 2025
Copy link
Member

@tmysik tmysik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am afraid that I am not able to fully verify the editor-related implementations but overall, the change looks good to me, thank you.

@troizet troizet force-pushed the css_heredoc_nowdoc_embedding branch 3 times, most recently from d8a066a to 568b554 Compare December 12, 2025 12:01
@troizet
Copy link
Collaborator Author

troizet commented Dec 12, 2025

@tmysik I've made the corrections.

@tmysik
Copy link
Member

tmysik commented Dec 12, 2025

@troizet thanks!

@troizet troizet force-pushed the css_heredoc_nowdoc_embedding branch from 568b554 to df565ff Compare December 12, 2025 15:08
@troizet
Copy link
Collaborator Author

troizet commented Dec 12, 2025

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

@matthiasblaesing
Copy link
Contributor

@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:

8cdb9af

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?

@troizet
Copy link
Collaborator Author

troizet commented Dec 16, 2025

What do you think?

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

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

Labels

Editor PHP [ci] enable extra PHP tests (php/php.editor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants