NullPointerException JSEditor [message #146773] |
Wed, 09 November 2005 23:28  |
Eclipse User |
|
|
|
Originally posted by: amitz.nimblefish.com
I am getting this error when I try to open a JSEditor from within my
plugin using the following code, what am i missing here?
Am I doing something wrong?
java.lang.NullPointerException
at
org.eclipse.wst.javascript.ui.internal.editor.JSEditor$Stora geInputDocumentProvider.createAnnotationModel(JSEditor.java: 157)
at
org.eclipse.ui.editors.text.StorageDocumentProvider.createEl ementInfo(StorageDocumentProvider.java:264)
at
org.eclipse.wst.javascript.ui.internal.editor.JSEditor$Stora geInputDocumentProvider.createElementInfo(JSEditor.java:170)
at
org.eclipse.ui.texteditor.AbstractDocumentProvider.connect(A bstractDocumentProvider.java:398)
at
org.eclipse.ui.texteditor.AbstractTextEditor.doSetInput(Abst ractTextEditor.java:3008)
at
org.eclipse.ui.texteditor.StatusTextEditor.doSetInput(Status TextEditor.java:173)
at
org.eclipse.ui.texteditor.AbstractDecoratedTextEditor.doSetI nput(AbstractDecoratedTextEditor.java:1303)
at org.eclipse.ui.editors.text.TextEditor.doSetInput(TextEditor .java:262)
at
org.eclipse.wst.javascript.ui.internal.editor.JSEditor.doSet Input(JSEditor.java:501)
at
org.eclipse.ui.texteditor.AbstractTextEditor$16.run(Abstract TextEditor.java:2360)
at
org.eclipse.jface.operation.ModalContext.runInCurrentThread( ModalContext.java:346)
at org.eclipse.jface.operation.ModalContext.run(ModalContext.ja va:291)
at
org.eclipse.jface.window.ApplicationWindow$1.run(Application Window.java:624)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:69)
....
the error point to this line in JSEditor.java
id = storageInput.getStorage().getFullPath().toString();
VariableEditorInput input = new VariableEditorInput(filename, extension);
page.openEditor(input, "com.nimblefish.tools.n4console.jseditor");
public final class VariableEditorInput implements IStorageEditorInput,
IPersistableElement {
private IStorage fStorage;;
private File fFile;
private String fName;
private String value = "";
public VariableEditorInput(String name, String value) {
fName = name;
this.value = value;
createStorage();
}
public VariableEditorInput(String name) {
fName = name;
createStorage();
}
public VariableEditorInput(File file) {
fFile = file;
createStorage();
}
private void createStorage() {
fStorage = new IStorage() {
public InputStream getContents() throws CoreException {
try {
return fFile != null ? new FileInputStream(fFile) :
getClearStream();
} catch (IOException e) {
return getClearStream();
}
}
private InputStream getClearStream() {
return new ByteArrayInputStream(value.getBytes());
}
public IPath getFullPath() {
return null;
}
public String getName() {
return VariableEditorInput.this.getName();
}
public boolean isReadOnly() {
return false;
}
public Object getAdapter(Class adapter) {
return null;
}
};
}
public boolean exists() {
return fFile != null ? fFile.exists() : false;
}
public ImageDescriptor getImageDescriptor() {
return null;
}
public String getName() {
return fFile != null ? fFile.getName() : fName;
}
public IPersistableElement getPersistable() {
return fFile != null ? this : null;
}
public String getToolTipText() {
return fFile != null ? fFile.getAbsolutePath() : getName();
}
public Object getAdapter(Class adapter) {
return null;
}
/**
* Returns the underlying IStorage object.
*
* @return an IStorage object.
* @exception CoreException if this method fails
*/
public IStorage getStorage() throws CoreException {
return fStorage;
}
public File getFile() {
return fFile;
}
public String getFactoryId() {
return
" com.nimblefish.tools.n4console.editors.VariableEditorInputFa ctory ";
}
public void saveState(IMemento memento) {
if (fFile == null) {
return;
}
memento.putString("path", fFile.getAbsolutePath());
}
}
I have the following extensions defined in my plgin.xml:
<extension point="org.eclipse.ui.editors">
<editor
class="org.eclipse.wst.javascript.ui.internal.editor.JSEditor "
contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor "
default="false"
extensions="js"
icon="icons/copy_edit.gif"
id="com.nimblefish.tools.n4console.jseditor"
name="JSEditor"/>
</extension>
<extension
point="org.eclipse.ui.elementFactories">
<factory
class=" com.nimblefish.tools.n4console.editors.VariableEditorInputFa ctory "
id=" com.nimblefish.tools.n4console.editors.VariableEditorInputFa ctory "/>
</extension>
|
|
|
Re: NullPointerException JSEditor [message #146778 is a reply to message #146773] |
Thu, 10 November 2005 00:42  |
Eclipse User |
|
|
|
Amit wrote:
> I am getting this error when I try to open a JSEditor from within my
> plugin using the following code, what am i missing here?
>
> Am I doing something wrong?
>
> java.lang.NullPointerException
> at
> org.eclipse.wst.javascript.ui.internal.editor.JSEditor$Stora geInputDocumentProvider.createAnnotationModel(JSEditor.java: 157)
No, the version you're using has a bug where it expects any
IStorageEditorInputs to return a non-null full path, which is more
than required by the IStorageEditorInput interface. It shouldn't be
a problem in M9, or you can simply implement
VariableEditorInput.getFullPath() to return a value as a workaround.
--
- Nitin
|
|
|
Powered by
FUDForum. Page generated in 0.03301 seconds