Community
Participate
Working Groups
If I read the Javadoc of CompletionProposalCollector.getDeclaringType(CompletionProposal) right, then this method should never fail its assertion but simply return null of the proposal doesn't have a declaring type: * Returns the type signature of the declaring type of a * <code>CompletionProposal</code>, or <code>null</code> for proposals * that do not have a declaring type. The return value is <em>not</em> * <code>null</code> for proposals of the following kinds: This is not true for MODULE_DECLARATION proposals (we have a code path in Code Recommenders' that performs such a call). Also, the comment seems out of datr w.r.t. the list of proposals that apparently have a declaring type (MODULE_REF, PACKAGE_REF? Really?). FWIW, here's a stacktrace I came across while fixing Bug 528901: org.eclipse.core.runtime.AssertionFailedException: assertion failed: at org.eclipse.core.runtime.Assert.isTrue(Assert.java:110) at org.eclipse.core.runtime.Assert.isTrue(Assert.java:96) at org.eclipse.jdt.ui.text.java.CompletionProposalCollector.getDeclaringType(CompletionProposalCollector.java:609) at org.eclipse.jdt.ui.text.java.CompletionProposalCollector.isFiltered(CompletionProposalCollector.java:547) at org.eclipse.jdt.ui.text.java.CompletionProposalCollector.accept(CompletionProposalCollector.java:244) at org.eclipse.recommenders.completion.rcp.processable.ProposalCollectingCompletionRequestor.createJdtProposals(ProposalCollectingCompletionRequestor.java:290) at org.eclipse.recommenders.completion.rcp.processable.ProposalCollectingCompletionRequestor.accept(ProposalCollectingCompletionRequestor.java:264) at org.eclipse.jdt.internal.codeassist.CompletionEngine.findModuleName(CompletionEngine.java:10696) at org.eclipse.jdt.internal.codeassist.CompletionEngine.complete(CompletionEngine.java:2052) at org.eclipse.jdt.internal.core.Openable.codeComplete(Openable.java:131) at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:358) at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:346) at org.eclipse.recommenders.internal.subwords.rcp.SubwordsSessionProcessor.computeProposals(SubwordsSessionProcessor.java:341) at org.eclipse.recommenders.internal.subwords.rcp.SubwordsSessionProcessor.getNewProposals(SubwordsSessionProcessor.java:228) at org.eclipse.recommenders.internal.subwords.rcp.SubwordsSessionProcessor.initializeContext(SubwordsSessionProcessor.java:168) at org.eclipse.recommenders.completion.rcp.processable.IntelligentCompletionProposalComputer.fireInitializeContext(IntelligentCompletionProposalComputer.java:293) at org.eclipse.recommenders.completion.rcp.processable.IntelligentCompletionProposalComputer.computeCompletionProposals(IntelligentCompletionProposalComputer.java:170) at org.eclipse.jdt.internal.ui.text.java.CompletionProposalComputerDescriptor.computeCompletionProposals(CompletionProposalComputerDescriptor.java:333) at org.eclipse.jdt.internal.ui.text.java.CompletionProposalCategory.computeCompletionProposals(CompletionProposalCategory.java:337) at org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor.collectProposals(ContentAssistProcessor.java:331) at org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor.computeCompletionProposals(ContentAssistProcessor.java:288)
Something looks fishy here indeed. Noopur, please take a look for 4.7.3.
(In reply to Andreas Sewe from comment #0) > This is not true for MODULE_DECLARATION proposals MODULE_DECLARATION is not handled and should be added in #getDeclaringType to return null. > Also, the comment seems out > of datr w.r.t. the list of proposals that apparently have a declaring type > (MODULE_REF, PACKAGE_REF? Really?). For PACKAGE_REF, the Javadoc clearly mentions that it returns the package name instead of a type i.e. PACKAGE_REF (returns the package, but no type). The Javadoc should be updated in a similar way for MODULE_REF also. I think these two should cover the requirements of this bug report. Andreas, let me know if I missed something.
(In reply to Noopur Gupta from comment #2) > (In reply to Andreas Sewe from comment #0) > > This is not true for MODULE_DECLARATION proposals > > MODULE_DECLARATION is not handled and should be added in #getDeclaringType > to return null. > > > Also, the comment seems out > > of datr w.r.t. the list of proposals that apparently have a declaring type > > (MODULE_REF, PACKAGE_REF? Really?). > > For PACKAGE_REF, the Javadoc clearly mentions that it returns the package > name instead of a type i.e. PACKAGE_REF (returns the package, but no type). > > The Javadoc should be updated in a similar way for MODULE_REF also. > > I think these two should cover the requirements of this bug report. Andreas, > let me know if I missed something. No, that sounds about right. However, if MODULE_REF returns type package (like PACKAGE_REF, which is indeed in the Javadoc), then shouldn't this be the case for MODULE_DECLARATION as well? That being said, the most important thing for Code Recommenders is that we can CompletionProposalCollector.accept(CompletionProposal) with any proposal kind; we don't do anything module-declaration specific.
(In reply to Andreas Sewe from comment #3) > However, if MODULE_REF returns type package > (like PACKAGE_REF, which is indeed in the Javadoc), then shouldn't this be > the case for MODULE_DECLARATION as well? That's correct. However, I don't see any mention of MODULE_DECLARATION in org.eclipse.jdt.core.CompletionProposal.getDeclarationSignature() or any other proposal API from JDT Core. Hence, I will return null from #getDeclaringType for now and I will open a bug in JDT Core to provide the module declaration name from the proposal.
New Gerrit change created: https://git.eclipse.org/r/114430
(In reply to Noopur Gupta from comment #4) > (In reply to Andreas Sewe from comment #3) > > However, if MODULE_REF returns type package > > (like PACKAGE_REF, which is indeed in the Javadoc), then shouldn't this be > > the case for MODULE_DECLARATION as well? > > That's correct. However, I don't see any mention of MODULE_DECLARATION in > org.eclipse.jdt.core.CompletionProposal.getDeclarationSignature() or any > other proposal API from JDT Core. Hence, I will return null from > #getDeclaringType for now and I will open a bug in JDT Core to provide the > module declaration name from the proposal. Bug 528967 will handle this.
Gerrit change https://git.eclipse.org/r/114430 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=26a1394a929a4df549411aab13df72aae8a41afd
New Gerrit change created: https://git.eclipse.org/r/114662
Gerrit change https://git.eclipse.org/r/114662 was merged to [R4_7_maintenance]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=f8152711dae1b8f2f76144c336df5278ff98b9c6
Merged the fix for 4.7.3 and updated the bundle version: https://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?h=R4_7_maintenance&id=fde01078ddd0d9679c8b6e9b59b3e90d20ecb30e
Verified for M5 in I20180124-2000.
Verified for 4.7.3 in M20180207-1700.