1) Open one of the classfiles from the akka-actor jar.
2) Manually attach the akka-actor sources
Editor is colored using the Java syntax highlighting (for instance, `trait` keywords aren't colored). No semantic highlighting is performed.
The reason why the editor is colored using the Java syntax highlighting is that if a Java ClassFile is created when there are no source attachments. Check ScalaClassFileProvider.create implementation.
I believe the fix would be to always return an instance of `ScalaClassFile` even if the source file cannot be found.
Once that's done, to fix semantic highlighting we should simply have a listener that notifies us if source attachment have been installed on the current classfile, and if so trigger a semantic highlighting refresh on the editor.
In scala-ide:67c6cfeefaae2fe66cbd6f3be206e6c56ce40e0b `ScalaClassFileEditor` should always hold a `ScalaClassFile`
There doesn't seem to be a good reason for not creating a `ScalaClassFile` when
source attachments cannot be located.
Doing so has two nice consequences:
1) When sources are manually attached to a Scala JAR, and a classfile is opened
in an editor, the source is now correctly syntactically highlighted. This
basically fix half of ticket Re #1001926 (the other half is triggering
semantic highlighting).
2) `ScalaClassFileEditor` instances are now ensured to be always created with
an underlying `ScalaClassFile`. This is an important fact, as
`ScalaClassFileEditor` assumes it (in fact, the `ClassCastException`
reported in ticket Re #1001925 was happening because this implicit contract
was broken, i.e., it was possible that a `ScalaClassFileEditor` could be
created with a (Java) `ClassFile` when no source attachment was found.
By the way, the `ClassCastException` issue mentioned in point 2) could be
reproduced by copying a **Scala** classfile in the root of a project, and then
trying to opening (by double-clicking on it from the Package Explorer view)
would result in an error prompted to the user.
Fixes #1001925
Name | Size |
---|