Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 218725 - [projection] exception in System.err from folding
Summary: [projection] exception in System.err from folding
Status: RESOLVED DUPLICATE of bug 182935
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows Vista
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-02-12 19:15 EST by Mik Kersten CLA
Modified: 2008-02-14 04:38 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mik Kersten CLA 2008-02-12 19:15:23 EST
I just saw the following exception dumped to System.err while working.  Note that I am using Mylyn, which means that most of the elements in my editors are folded.  I also saw some weird compression where methods were stacked on top of each other without the expected newline.  Steffen mentioned that he has seen text disappear with M5 so CC'ing him as well.  If we see any more clues about what could be causing this we'll post.

Exception in thread "Thread-282" java.lang.NullPointerException
	at org.eclipse.jface.text.AbstractLineTracker.flushRewriteSession(AbstractLineTracker.java:293)
	at org.eclipse.jface.text.AbstractLineTracker.checkRewriteSession(AbstractLineTracker.java:315)
	at org.eclipse.jface.text.AbstractLineTracker.getLineNumberOfOffset(AbstractLineTracker.java:160)
	at org.eclipse.jface.text.AbstractDocument.getLineOfOffset(AbstractDocument.java:842)
	at org.eclipse.jdt.ui.text.folding.DefaultJavaFoldingStructureProvider$JavaElementPosition.computeProjectionRegions(DefaultJavaFoldingStructureProvider.java:592)
	at org.eclipse.jface.text.source.projection.ProjectionViewer.computeCollapsedRegions(ProjectionViewer.java:1126)
	at org.eclipse.jface.text.source.projection.ProjectionSummary.createSummaries(ProjectionSummary.java:228)
	at org.eclipse.jface.text.source.projection.ProjectionSummary.internalUpdateSummaries(ProjectionSummary.java:167)
	at org.eclipse.jface.text.source.projection.ProjectionSummary.access$3(ProjectionSummary.java:148)
	at org.eclipse.jface.text.source.projection.ProjectionSummary$Summarizer.run(ProjectionSummary.java:70)
Comment 1 Dani Megert CLA 2008-02-13 03:45:23 EST
Mik, does Mylyn register its own folding provider(s)?
Comment 2 Mik Kersten CLA 2008-02-13 16:52:58 EST
What Mylyn does is to grab the provider from the editor:

	Object adapter = editor.getAdapter(IJavaFoldingStructureProvider.class);
	if (adapter instanceof IJavaFoldingStructureProviderExtension) {
			updater = (IJavaFoldingStructureProviderExtension) adapter;
	}

And then when needed it uses that to force an update of the folding.  So no, it does not use it's own provider but drives the existing provider.  It does this for the given element when that element is selected, and for the entire editor when the action is toggled or a context is activated.  Here's the code for the latter.

	List<IJavaElement> toExpand = new ArrayList<IJavaElement>();
	List<IJavaElement> toCollapse = new ArrayList<IJavaElement>();

	IJavaElement element = JavaUI.getEditorInputJavaElement(editor.getEditorInput());
	if (element instanceof ICompilationUnit) {
		ICompilationUnit compilationUnit = (ICompilationUnit) element;
		List<IJavaElement> allChildren = getAllChildren(compilationUnit);
		for (IJavaElement child : allChildren) {
			IInteractionElement interactionElement = ContextCorePlugin.getContextManager().getElement(
					bridge.getHandleIdentifier(child));
			if (interactionElement != null && interactionElement.getInterest().isInteresting()) {
				toExpand.add(child);
			} else {
				toCollapse.add(child);
			}
		}
	}
	if (updater != null) {
		updater.collapseMembers();
		updater.expandElements(toExpand.toArray(new IJavaElement[toExpand.size()]));
	}
Comment 3 Dani Megert CLA 2008-02-14 04:38:42 EST
Though not intended to be used like that from the outside the code looks OK. Probably a dup of bug 182935.

*** This bug has been marked as a duplicate of bug 182935 ***