Add the possibility that a class does not have a package.
This commit is contained in:
parent
340bec4fe8
commit
336d60ba06
|
@ -95,7 +95,10 @@ public class ClassFileContainer
|
|||
|
||||
public String getName()
|
||||
{
|
||||
return this.className.substring(this.className.lastIndexOf('/') + 1, this.className.lastIndexOf('.'));
|
||||
if (this.className.contains("/"))
|
||||
return this.className.substring(this.className.lastIndexOf('/') + 1, this.className.lastIndexOf('.'));
|
||||
else
|
||||
return this.className.substring(0, this.className.lastIndexOf('.'));
|
||||
}
|
||||
|
||||
public String getDecompiler()
|
||||
|
|
|
@ -339,7 +339,10 @@ public class MyVoidVisitor extends VoidVisitorAdapter<Object>
|
|||
return;
|
||||
|
||||
String qualifiedName = referenceType.getQualifiedName();
|
||||
String packagePath = qualifiedName.substring(0, qualifiedName.lastIndexOf('.')).replace('.', '/');
|
||||
String packagePath = "";
|
||||
if (qualifiedName.contains("."))
|
||||
packagePath = qualifiedName.substring(0, qualifiedName.lastIndexOf('.')).replace('.', '/');
|
||||
|
||||
this.classFileContainer.putClassReference(classValue.name,
|
||||
new ClassReferenceLocation(getOwner(classFileContainer),
|
||||
packagePath, "", "reference", classValue.line, classValue.columnStart, classValue.columnEnd + 1));
|
||||
|
|
|
@ -127,8 +127,7 @@ class ParserUtil
|
|||
* @param scopeValue The scope value
|
||||
* @param fieldValue The field value
|
||||
*/
|
||||
static void putClassResolvedValues(ClassFileContainer container, Expression visitedExpr,
|
||||
Expression resolveExpr,
|
||||
static void putClassResolvedValues(ClassFileContainer container, Expression visitedExpr, Expression resolveExpr,
|
||||
Value scopeValue, Value fieldValue)
|
||||
{
|
||||
ResolvedType resolvedType = visitedExpr.getSymbolResolver().calculateType(resolveExpr);
|
||||
|
@ -137,10 +136,12 @@ class ParserUtil
|
|||
|
||||
String qualifiedName = resolvedType.asReferenceType().getQualifiedName();
|
||||
String className = qualifiedName.substring(qualifiedName.lastIndexOf('.') + 1);
|
||||
String packageName = qualifiedName.substring(0, qualifiedName.lastIndexOf('.'));
|
||||
container.putClassReference(className, new ClassReferenceLocation(ParserUtil.getOwner(container),
|
||||
packageName.replace('.', '/'), fieldValue.name, "reference", scopeValue.line, scopeValue.columnStart,
|
||||
scopeValue.columnEnd + 1));
|
||||
String packageName = "";
|
||||
if (qualifiedName.contains("."))
|
||||
packageName = qualifiedName.substring(0, qualifiedName.lastIndexOf('.')).replace('.', '/');
|
||||
|
||||
container.putClassReference(className, new ClassReferenceLocation(ParserUtil.getOwner(container), packageName
|
||||
, fieldValue.name, "reference", scopeValue.line, scopeValue.columnStart, scopeValue.columnEnd + 1));
|
||||
container.putField(fieldValue.name, new ClassFieldLocation(scopeValue.name, "reference", fieldValue.line,
|
||||
fieldValue.columnStart, fieldValue.columnEnd + 1));
|
||||
}
|
||||
|
@ -166,10 +167,12 @@ class ParserUtil
|
|||
|
||||
String qualifiedName = referenceType.getQualifiedName();
|
||||
String className = qualifiedName.substring(qualifiedName.lastIndexOf('.') + 1);
|
||||
String packageName = qualifiedName.substring(0, qualifiedName.lastIndexOf('.'));
|
||||
container.putClassReference(className, new ClassReferenceLocation(ParserUtil.getOwner(container),
|
||||
packageName.replace('.', '/'), "", "reference", scopeValue.line, scopeValue.columnStart,
|
||||
scopeValue.columnEnd + 1));
|
||||
String packageName = "";
|
||||
if (qualifiedName.contains("."))
|
||||
packageName = qualifiedName.substring(0, qualifiedName.lastIndexOf('.')).replace('.', '/');
|
||||
|
||||
container.putClassReference(className, new ClassReferenceLocation(ParserUtil.getOwner(container), packageName
|
||||
, "", "reference", scopeValue.line, scopeValue.columnStart, scopeValue.columnEnd + 1));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user