packageName = scopeIndex < 0 ? null : text.substring(0, scopeIndex);
}
String path = scopeIndex < 0 ? text : text.substring(scopeIndex + 2);
String[] names = path.isEmpty() ? new String[0] : path.split("\\.");
Declaration base = null;
if (packageName==null) {
if (names.length > 0) {
base = that.getScope().getMemberOrParameter(that.getUnit(),
names[0], null, false);
}
}
else {
Package pack = that.getUnit().getPackage().getModule().getPackage(packageName);
if (pack == null) {
if (DOC_LINK_MODULE.equals(kind)) {
that.addUsageWarning(Warning.doclink,
"module does not exist: '" + packageName + "'");
} else {
that.addUsageWarning(Warning.doclink,
"package does not exist: '" + packageName + "'");
}
}
else {
that.setPkg(pack);
if (DOC_LINK_MODULE.equals(kind)) {
Package rootPack = pack.getModule().getRootPackage();
if (pack.equals(rootPack)) {
that.setModule(pack.getModule());
} else {
that.addUsageWarning(Warning.doclink,
"module does not exist: '" + packageName + "'");
}
}
if (names.length > 0) {
base = pack.getDirectMember(names[0], null, false);
}
}
if (DOC_LINK_MODULE.equals(kind) || DOC_LINK_PACKAGE.equals(kind)) {
return;
}
}
if (base==null) {
that.addUsageWarning(Warning.doclink,
"declaration does not exist: '" +
(names.length > 0 ? names[0] : text) + "'");
}
else {
that.setBase(base);
if (names.length>1) {
that.setQualified(new ArrayList<Declaration>(names.length-1));
}
for (int i=1; i<names.length; i++) {
if (base instanceof Value) {
Value value = (Value) base;
if (!value.isParameter()
&& !value.isTransient()
&& value.getTypeDeclaration() != null
&& value.getTypeDeclaration().isAnonymous()) {
base = value.getTypeDeclaration();
}
}
if (base instanceof TypeDeclaration || base instanceof Functional) {
Declaration qualified = base.getMember(names[i], null, false);
if (qualified==null) {
that.addUsageWarning(Warning.doclink,
"member declaration or parameter does not exist: '" + names[i] + "'");
break;
}