Skip to content

Conversation

@haidubogdan
Copy link
Contributor

This pull request proposes support for .env files.
Maybe it has too much features for the daily usage for these kind of files, but I think it's something to be discussed.
As the feedback progresses I can add more unit tests.

Implementations :

  • mime provider for .env files
  • coloring support
image
  • coloring options for keyword like values (null, true, false ...)
  • interpolated env key features like completion and declaration finder
  • partial ticket fix Add comment/uncomment options on .properties, .cnf, .env files #6677 covering env files
  • hints for duplicate key assignment
  • important file node inclusion for .env file for web and php projects
image

^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)

@mbien mbien added the Editor label Dec 12, 2025
@apache apache locked and limited conversation to collaborators Dec 12, 2025
@apache apache unlocked this conversation Dec 12, 2025
Copy link
Contributor

@matthiasblaesing matthiasblaesing left a comment

Choose a reason for hiding this comment

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

In general good idea. The grammar seems to be incomplete. I entered DB_TEST=demo then inserted a newline and inputted D. Then I got on CLI:

     [exec] line 2:1 missing ASSIGN_OPERATOR at '<EOF>'

This looks like debug output.

Entering TEST (notice the trailing space) yields:

    [exec] line 1:4 missing ASSIGN_OPERATOR at '<EOF>'
     [exec] SEVERE: Lexer org.netbeans.modules.languages.env.lexer.EnvLexer@7856b550
     [exec]   returned null token but lexerInput.readLength()=1
     [exec]   lexer-state: -1
     [exec]   tokenStartOffset=4, readOffset=5, lookaheadOffset=6
     [exec]   Chars: " " - these characters need to be tokenized.
     [exec] Fix the lexer to not return null token in this state.
     [exec] java.lang.IllegalStateException: Lexer org.netbeans.modules.languages.env.lexer.EnvLexer@7856b550
     [exec]   returned null token but lexerInput.readLength()=1
     [exec]   lexer-state: -1
     [exec]   tokenStartOffset=4, readOffset=5, lookaheadOffset=6
     [exec]   Chars: " " - these characters need to be tokenized.
     [exec] Fix the lexer to not return null token in this state.
     [exec] 	at org.netbeans.lib.lexer.LexerInputOperation.checkLexerInputFinished(LexerInputOperation.java:435)
     [exec] 	at org.netbeans.lib.lexer.LexerInputOperation.nextToken(LexerInputOperation.java:193)
     [exec] 	at org.netbeans.lib.lexer.BatchTokenList.tokenOrEmbeddingImpl(BatchTokenList.java:171)
     [exec] 	at org.netbeans.lib.lexer.BatchTokenList.tokenOrEmbedding(BatchTokenList.java:166)
     [exec] 	at org.netbeans.lib.lexer.LexerUtilsConstants.tokenIndexLazyTokenCreation(LexerUtilsConstants.java:307)
     [exec] 	at org.netbeans.lib.lexer.BatchTokenList.tokenIndex(BatchTokenList.java:161)
     [exec] 	at org.netbeans.api.lexer.TokenSequence.move(TokenSequence.java:650)
     [exec] 	at org.netbeans.modules.languages.env.EnvOccurencesFinder.computeOccurrences(EnvOccurencesFinder.java:99)
     [exec] 	at org.netbeans.modules.languages.env.EnvOccurencesFinder.run(EnvOccurencesFinder.java:60)
     [exec] 	at org.netbeans.modules.languages.env.EnvOccurencesFinder.run(EnvOccurencesFinder.java:35)
     [exec] [catch] at org.netbeans.modules.csl.editor.semantic.MarkOccurrencesHighlighter.processImpl(MarkOccurrencesHighlighter.java:157)
     [exec] 	at org.netbeans.modules.csl.editor.semantic.MarkOccurrencesHighlighter.run(MarkOccurrencesHighlighter.java:114)
     [exec] 	at org.netbeans.modules.csl.editor.semantic.MarkOccurrencesHighlighter.run(MarkOccurrencesHighlighter.java:59)
     [exec] 	at org.netbeans.modules.parsing.impl.TaskProcessor.callParserResultTask(TaskProcessor.java:561)
     [exec] 	at org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.run(TaskProcessor.java:786)
     [exec] 	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:288)
     [exec] 	at org.netbeans.modules.parsing.impl.TaskProcessor$RequestPerformer.execute(TaskProcessor.java:702)
     [exec] 	at org.netbeans.modules.parsing.impl.TaskProcessor$CompilationJob.run(TaskProcessor.java:663)
     [exec] 	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
     [exec] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
     [exec] 	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1403)
     [exec] 	at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
     [exec] 	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:287)
     [exec] 	at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2018)
     [exec] line 1:5 missing ASSIGN_OPERATOR at '<EOF>'

The hint integration shows an untranslated label (first linne in tree):

grafik

<friend>org.netbeans.modules.javascript2.nodejs</friend>
<friend>org.netbeans.modules.javascript2.requirejs</friend>
<friend>org.netbeans.modules.languages.apacheconf</friend>
<friend>org.netbeans.modules.languages.env</friend>
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is to include the .env file in the Important Files folder for web projects.
I was thinking if it would be better to have a stand alone implementation, but so far I see that most configuration files use this dependency from web.common.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@matthiasblaesing
Regarding the console output, I see that on antlr language parser there is a removal of the console error listener.
I will apply the same logic.

parser.removeErrorListener(ConsoleErrorListener.INSTANCE);

I will, also, try to display a better message for the syntax error.

- mime provider for .env files
- coloring support
- interpolated env key features like completion and declaration finder
- partial ticket fix apache#6677 covering env files
- include .env file in ImportantFiles node for web and php projects
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add comment/uncomment options on .properties, .cnf, .env files

4 participants