-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Import all does not work for long packages #724
Comments
public PackageBinding createPackage(char[][] compoundName) {
PackageBinding packageBinding = getPackage0(compoundName[0]);
if (packageBinding == null || packageBinding == TheNotFoundPackage) {
packageBinding = new PackageBinding(compoundName[0], this, this.module);
this.knownPackages.put(compoundName[0], packageBinding);
if (this.module != null) {
packageBinding = this.module.addPackage(packageBinding, true);
this.knownPackages.put(compoundName[0], packageBinding); // update in case of split package
}
}
for (int i = 1, length = compoundName.length; i < length; i++) {
// check to see if it collides with a known type...
// this case can only happen if the package does not exist as a directory in the file system
// otherwise when the source type was defined, the correct error would have been reported
// unless its an unresolved type which is referenced from an inconsistent class file
// NOTE: empty packages are not packages according to changes in JLS v2, 7.4.3
// so not all types cause collision errors when they're created even though the package did exist
ReferenceBinding type = packageBinding.getType0(compoundName[i]);
if (type != null && type != TheNotFoundType && !(type instanceof UnresolvedReferenceBinding))
return null; |
This all changed for Groovy-Eclipse when this was added to for (ImportNode importNode : module.getStarImports()) {
if (importNode.getEnd() > 0) {
String importName = importNode.getPackageName();
importName = importName.substring(0, importName.length()-1);
ClassNode type = ClassHelper.makeWithoutCaching(importName);
if (resolve(type, false, false, true)) {
importNode.setType(type);
type.setStart(importNode.getStart() + 7);
type.setEnd(type.getStart() + importName.length());
}
}
} |
This prevents LookupEnvironment.createPackage from returning null because a package was tried as a type and a missing binding was stored
Ready to test |
Tested on 3.1.0.xx-201809201450-e47 |
I have an issue with the code that is compiled properly, but as soon as I open a particular file it is complains that it can not resolve a type and mark is as compile error:
But it is only marked inside editor, not in problems or in tree and only when file is opened.
It is easy to reproduce:
and just create 4 empty classes:
When you open the Test class you will noticed that the first two classes references is fine, while the second two is complaining about:
I am on 3.1.0.xx-201809172153-e47
The text was updated successfully, but these errors were encountered: