Bug 124679 - [syntax highlighting] Semantic highlighting for compile-time constant variables
Summary: [syntax highlighting] Semantic highlighting for compile-time constant variables
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.2   Edit
Hardware: All All
: P4 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-20 11:57 EST by Markus Keller CLA
Modified: 2014-01-14 10:56 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2006-01-20 11:57:11 EST
In Java, there are two kinds of static final fields. In general, fields are initialized in the static initializer of a class, but there's also a special case of "compile-time constant variables" which are inlined in referencing class files and can cause problems with binary compatibility.

This is a request for a semantic highlighting for such compile-time constants. They can easily be recoginzed from IVariableBindings: their getConstantValue() is != null.



The Java language defines in JLS3 4.12.4
Comment 1 Markus Keller CLA 2006-01-23 04:29:05 EST
> The Java language defines in JLS3 4.12.4
Oops, I just wanted to say that JLS3 4.12.4 defines these "constant variables".
Comment 2 Markus Keller CLA 2014-01-14 10:34:38 EST
There's already a StaticFinalFieldHighlighting with preference key "staticFinalField" which has a wrong name "Constants" in the UI (should be "Static final fields").

The JLS uses the term "constant" for compile-time constant expressions. For a long time, the JLS was confusing and inconsistent about whether non-static fields can also be a "constant variable", but this is settled now: Non-static fields can also be constant variables.

A highlighting for constant variables as requested here has the problem that it conflicts with the existing "Fields", "Static fields", and "Static final fields" highlightings, where "static" is rendered as "italic" by default. It also conflicts with the various local variable highlightings, since those can also be constant variables.

For a new "Constant" highlighting, it would be good if we could just set a color, but not override the "italic" setting of the other field highlightings. But that still doesn't resolve the conflict with constant local variables (which would then look the same as constant non-final fields).

=> Not easy to fix without more infrastructure changes.
Comment 3 Markus Keller CLA 2014-01-14 10:56:18 EST
See also bug 128666 and bug 421564.