cypher256 / eclipse-encoding-plugin

Show file encoding and line ending for the active editor in the eclipse status bar. Encoding can be changed by right click. Line ending support showing CRLF, CR, LF and Mixed.
https://marketplace.eclipse.org/content/autodetect-encoding
Eclipse Public License 1.0
47 stars 8 forks source link

IllegalStateException thrown when JavaScript resource is opened #9

Closed sstyana closed 6 years ago

sstyana commented 6 years ago

Environment: Pleiades All in One Java, Oxygen (Windows 64bit)

Steps:

  1. Switch to JavaEE perspective
  2. Make new JavaScript project
  3. Open any item under "JavaScript resource" - "ECMAScript built-in library"
  4. IllegalStateException thrown
java.lang.IllegalStateException: java.lang.NoSuchMethodException: org.eclipse.wst.jsdt.internal.core.LibraryFragmentRoot.getRawClasspathEntry()
    at mergedoc.encoding.JarResource.setPackageFragmentRoot(JarResource.java:53)
    at mergedoc.encoding.document.ClassFileJarDocument.updateStatus(ClassFileJarDocument.java:51)
    at mergedoc.encoding.document.ActiveDocument.init(ActiveDocument.java:66)
    at mergedoc.encoding.document.ClassFileJarDocument.init(ClassFileJarDocument.java:35)
    at mergedoc.encoding.document.ActiveDocument.<init>(ActiveDocument.java:52)
    at mergedoc.encoding.document.ClassFileJarDocument.<init>(ClassFileJarDocument.java:24)
    at mergedoc.encoding.ActiveDocumentAgent.getDocument(ActiveDocumentAgent.java:128)

ActiveDocumentAgent.getDocument() seems confused with org.eclipse.jdt.internal.ui.javaeditor.InternalClassFileEditorInput (Java editor) and org.eclipse.wst.jsdt.internal.ui.javaeditor.InternalClassFileEditorInput (JavaScript editor).

Possible fix (I've not tried):

at ActiveDocumentAgent.getDocument(), change } else if (editorInput.getClass().getSimpleName().equals("InternalClassFileEditorInput")) { to } else if (editorInput.getClass().getName().equals("org.eclipse.jdt.internal.ui.javaeditor.InternalClassFileEditorInput")) {

event.txt

cypher256 commented 6 years ago

Fix open error item in "ECMAScript built-in library". 1.8.5 - 2018.01.19 Thanks for the detailed report.

sstyana commented 6 years ago

I tried 1.8.5, and confirmed the issue was solved. Thanks for quick response.