eclipse-xtext / eclipse-xtext/xtext
NPE in ResourceSetGlobalScopeProvider if no ResourceDescription for a Resource
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 831
- Forks
- 330
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 12
Description
I'm working with a ResourceSet that may contain non-Xtext resources.
ResourceSetGlobalScopeProvider.createScopeWithQualifiedNames() cannot handle that (NPE in line 71):
ISelectable compound = new ISelectable() {
@Override
public boolean isEmpty() {
for (ISelectable description: resourceDescriptions) {
// NPE for description
if (!description.isEmpty())
return false;
}
return true;
}
Proposed fix: Add a nonNull filter to the resourceDescriptions iterator:
final Iterable<ISelectable> resourceDescriptions = Iterables.filter(
Iterables.transform(resourceSet.getResources(),
from -> this.resourceDecriptionProvider.getResourceDescription(from)),
Objects::nonNull);
And when we're at it, converting the anonymous ISelectable within createScopeWithQualifiedNames() into a real class would support subclassing a lot.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at ResourceSetGlobalScopeProvider.createScopeWithQualifiedNames(), using a ResourceSet containing a non-Xtext resource to reproduce the null ResourceDescription failure. Ensure resources without descriptions no longer cause an NPE, and consider whether the anonymous ISelectable should become subclassable as proposed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100