Community
Participate
Working Groups
It can occur that the variable 'attribute' is null, which leads to a NPE in line int style= textAttribute.getStyle(); This happened to me when I pasted contents into a code template in the templates preference page. Full Stack: Daemon Thread [Thread-1] (Suspended (exception NullPointerException)) AttributedPosition.createStyleRange() line: 44 HighlightingPresenter.applyTextPresentation(TextPresentation) line: 604 XtextSourceViewer(TextViewer).changeTextPresentation(TextPresentation, boolean) line: 4877 HighlightingPresenter.updatePresentation(TextPresentation, AttributedPosition[], AttributedPosition[]) line: 488 HighlightingPresenter$1.run() line: 370 RunnableLock.run() line: 35 UISynchronizer(Synchronizer).runAsyncMessages(boolean) line: 135 Display.runAsyncMessages(boolean) line: 3935 Display.readAndDispatch() line: 3612 EditTemplateDialog(Window).runEventLoop(Shell) line: 825 EditTemplateDialog(Window).open() line: 801 AdvancedTemplatesPreferencePage.editTemplate(Template, boolean, boolean) line: 56 AdvancedTemplatesPreferencePage(TemplatePreferencePage).edit(TemplatePersistenceData) line: 1271 AdvancedTemplatesPreferencePage(TemplatePreferencePage).edit() line: 1266 TemplatePreferencePage.access$1(TemplatePreferencePage) line: 1258 TemplatePreferencePage$16.handleEvent(Event) line: 975 EventTable.sendEvent(Event) line: 84 Display.sendEvent(EventTable, Event) line: 4125 Button(Widget).sendEvent(Event) line: 1457 Button(Widget).sendEvent(int, Event, boolean) line: 1480 Button(Widget).sendEvent(int, Event) line: 1465 Button(Widget).notifyListeners(int, Event) line: 1270 Display.runDeferredEvents() line: 3971 Display.readAndDispatch() line: 3610 WorkbenchPreferenceDialog(Window).runEventLoop(Shell) line: 825 WorkbenchPreferenceDialog(Window).open() line: 801 WorkbenchPreferenceDialog.open() line: 215 ShowPreferencePageHandler.execute(ExecutionEvent) line: 54 HandlerProxy.execute(ExecutionEvent) line: 293 Command.executeWithChecks(ExecutionEvent) line: 476 HandlerService.executeCommand(String, Event) line: 178 CocoaUIEnhancer.runCommand(String) line: 393 CocoaUIEnhancer.actionProc(long, long, long) line: 535 OS.objc_msgSendSuper(objc_super, long, long) line: not available [native method] Display.applicationSendEvent(long, long, long) line: 4986 Display.applicationProc(long, long, long) line: 5135 OS.objc_msgSend(long, long, long) line: not available [native method] NSApplication.sendEvent(NSEvent) line: 128 Display.readAndDispatch() line: 3607 Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 2696 Workbench.runUI() line: 2660 Workbench.access$4(Workbench) line: 2494 Workbench$7.run() line: 674 Realm.runWithDefault(Realm, Runnable) line: 332 Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 667 PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 149 IDEApplication.start(IApplicationContext) line: 123 EclipseAppHandle.run(Object) line: 196 EclipseAppLauncher.runApplication(Object) line: 110 EclipseAppLauncher.start(Object) line: 79 EclipseStarter.run(Object) line: 344 EclipseStarter.run(String[], Runnable) line: 179 NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method] NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39 DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25 Method.invoke(Object, Object...) line: 597 Main.invokeFramework(String[], URL[]) line: 622 Main.basicRun(String[]) line: 577 Main.run(String[]) line: 1410 Main.main(String[]) line: 1386
Not 2.1
FWIW I've come across this problem as well: org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.NullPointerException) at org.eclipse.swt.SWT.error(SWT.java:4282) at org.eclipse.swt.SWT.error(SWT.java:4197) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:138) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494) at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577) at org.eclipse.equinox.launcher.Main.run(Main.java:1410) at org.eclipse.equinox.launcher.Main.main(Main.java:1386) Caused by: java.lang.NullPointerException at org.eclipse.xtext.ui.editor.syntaxcoloring.AttributedPosition.createStyleRange(AttributedPosition.java:48) at org.eclipse.xtext.ui.editor.syntaxcoloring.HighlightingPresenter.applyTextPresentation(HighlightingPresenter.java:604) at org.eclipse.jface.text.TextViewer.changeTextPresentation(TextViewer.java:4877) at org.eclipse.xtext.ui.editor.syntaxcoloring.HighlightingPresenter.updatePresentation(HighlightingPresenter.java:488) at org.eclipse.xtext.ui.editor.syntaxcoloring.HighlightingPresenter$1.run(HighlightingPresenter.java:370) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135) ... 23 more
Karsten, can you provide some more informatione, e.g. which language the code templates belong to and how the code snippet looked like?
I am getting this one in my Spray Runtime workspace. git clone https://code.google.com/a/eclipselabs.org/p/spray/ tag "bug357176" Reproduce: - open Preferences -> Spray -> Templates - select template "Line" The NPE occurs for me when selecting this template
(In reply to comment #4) > I am getting this one in my Spray Runtime workspace. > > git clone https://code.google.com/a/eclipselabs.org/p/spray/ > tag "bug357176" > > Reproduce: > - open Preferences -> Spray -> Templates > - select template "Line" > > The NPE occurs for me when selecting this template Does the problem persist if you disable the layout_id token style, e.g. by replacing it by the default keyword style?
I think you meant in SprayHighlightingConfiguration#configure I have commented out all custom code here. The error still remains.
I was refering to the token colorer.
I have now checked this. The NPE does disappears when the SprayTokenToAttributeIdMapper#calculateId() does not return LAYOUT_ID protected String calculateId(String tokenName, int tokenType) { if (layoutKeywords.contains(tokenName)) { return SprayHighlightingConfiguration.LAYOUT_ID; } return super.calculateId(tokenName, tokenType); } When I comment out the if block the error does not appear.
Pushed a NPE guard to master. Custom highlighting styles don't work at the moment for the template configuration.
Closing all bugs that were set to RESOLVED before Neon.0