atom/language-java

Enum not correctly hightlighted when mixed with constructor and code overrides

Closed this issue · 1 comments

Description

Originally created in redhat-developer/vscode-java#974 by @orblazer :

Hello,
The color of first item when the enum overwrite is wrong

Environment
  • Operating System: Windows 10
  • JDK version: jdk1.8.0_212
  • Visual Studio Code version: 1.35.1
  • Java extension version: 0.46.0
Steps To Reproduce
  1. Create an enum with function
  2. Override that function in enum items

[attach a sample project reproducing the error]
attach logs

Current Result

wrong

Expected Result

right

Additional Informations

The path for color is different :

Path of current result :
wrong-dt

Path of expected result :
right-dt

I think the path for the current result is right bug its just parsing is broken.

The problem is infact caused by the overly restricted rules specified in syntax file

Currently, the enum syntax will try to match three patterns:

  • pure enum's constant field
  • constant field with constructor
  • constant field with code overrides

But when constructor and code overrides are applied on a field at the same time, the pattern matching fails, just as follows:

image

Worth noting that a new line also breaks current syntax:
image