Community
Participate
Working Groups
I200403161300 + new code to use AST on reconcile (not yet in HEAD). Difference is that we request the AST. This time I have steps :-) 1. started fresh workspace 2. create Java project 3. create package org.eclipse.swt.custom 4. create empty file StyledText.java 5. paste StyledText.java into a fresh workspace ==> java.lang.NullPointerException at java.lang.Throwable.<init>(Throwable.java) at java.lang.Throwable.<init>(Throwable.java) at java.lang.NullPointerException.<init>(NullPointerException.java:60) at org.eclipse.jdt.core.dom.TypeBinding.getKey(TypeBinding.java) at org.eclipse.jdt.core.dom.MethodBinding.getKey(MethodBinding.java) at org.eclipse.jdt.core.dom.DefaultBindingResolver.resolveMethod(DefaultBindingResolver.java:470) at org.eclipse.jdt.core.dom.MethodDeclaration.resolveBinding(MethodDeclaration.java:869) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java) at org.eclipse.jdt.core.dom.ASTConverter.buildBodyDeclarations(ASTConverter.java:1005) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1132) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java) at org.eclipse.jdt.core.dom.ASTConverter.convertToVariableDeclarationFragment(ASTConverter.java:2710) at org.eclipse.jdt.core.dom.ASTConverter.convertToVariableDeclarationStatement(ASTConverter.java:2737) at org.eclipse.jdt.core.dom.ASTConverter.checkAndAddMultipleLocalDeclaration(ASTConverter.java:384) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1859) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1764) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2008) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1788) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java) at org.eclipse.jdt.core.dom.ASTConverter.buildBodyDeclarations(ASTConverter.java:330) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:268) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:146) at org.eclipse.jdt.core.dom.AST.convertCompilationUnit(AST.java:233) at org.eclipse.jdt.internal.core.CompilationUnit.buildStructure(CompilationUnit.java:147) at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:169) at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:543) at org.eclipse.jdt.internal.core.CompilationUnit.makeConsistent(CompilationUnit.java:931) at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.executeOperation(ReconcileWorkingCopyOperation.java:56) at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:700) at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:739) at org.eclipse.jdt.internal.core.CompilationUnit.reconcile(CompilationUnit.java:1043) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:84) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:109) at org.eclipse.jface.text.reconciler.CompositeReconcilingStrategy.reconcile(CompositeReconcilingStrategy.java:83) at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.reconcile(JavaCompositeReconcilingStrategy.java:97) at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:76) at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:189)
I will investigate.
Do you have lots of compile error? At step 5, do you mean I should paste the code from the swt plugin replacing the empty file StyledText.java?
Yes to both questions.
The problem is that I tried to do exactly this and I could not reproduce. I will continue to investigate.
As stated the code is not yet in HEAD. Did you modify the code to reproduce? It works for us when we use reconcile(false /*getAST*/, ...) but not when we use reconcile(true, /*getAST*/, ...)
of course it should read: ...when we use reconcile(true /*getAST*/, ...)
I tried to create an AST out of this compilation unit resolving the bindings for it and it worked. So far, I was unable to reproduce it.
I will send you a plug-in export of JDT UI this morning where you can see this.
The bug is in the reconcile working copy operation. ReconcileWorkingCopyOperation Line 71, the call to process will clean up the compilation unit. This clean up resets the scopes to null. But afterwards, the DOM/AST is created with binding resolution and this expects the scope to be available. So no scope are available when the getKey() is called on the bindings and this leads to a NPE. The scope must be cleaned after the DOM/AST creation, not before.
Changed ReconcileWorkingCopyOperation as well as CompilationUnit.buildStructure () to cleanup the compilation unit declaration only after building the AST. Added regression tests ASTConverterTest2.test0538f() and test0538g()
Thanks for the quick responcse. This now works and leads us to bug 55362 ;-)