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()
|
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()
|
public String getDecompiler()
|
||||||
|
|
|
@ -339,7 +339,10 @@ public class MyVoidVisitor extends VoidVisitorAdapter<Object>
|
||||||
return;
|
return;
|
||||||
|
|
||||||
String qualifiedName = referenceType.getQualifiedName();
|
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,
|
this.classFileContainer.putClassReference(classValue.name,
|
||||||
new ClassReferenceLocation(getOwner(classFileContainer),
|
new ClassReferenceLocation(getOwner(classFileContainer),
|
||||||
packagePath, "", "reference", classValue.line, classValue.columnStart, classValue.columnEnd + 1));
|
packagePath, "", "reference", classValue.line, classValue.columnStart, classValue.columnEnd + 1));
|
||||||
|
|
|
@ -127,8 +127,7 @@ class ParserUtil
|
||||||
* @param scopeValue The scope value
|
* @param scopeValue The scope value
|
||||||
* @param fieldValue The field value
|
* @param fieldValue The field value
|
||||||
*/
|
*/
|
||||||
static void putClassResolvedValues(ClassFileContainer container, Expression visitedExpr,
|
static void putClassResolvedValues(ClassFileContainer container, Expression visitedExpr, Expression resolveExpr,
|
||||||
Expression resolveExpr,
|
|
||||||
Value scopeValue, Value fieldValue)
|
Value scopeValue, Value fieldValue)
|
||||||
{
|
{
|
||||||
ResolvedType resolvedType = visitedExpr.getSymbolResolver().calculateType(resolveExpr);
|
ResolvedType resolvedType = visitedExpr.getSymbolResolver().calculateType(resolveExpr);
|
||||||
|
@ -137,10 +136,12 @@ class ParserUtil
|
||||||
|
|
||||||
String qualifiedName = resolvedType.asReferenceType().getQualifiedName();
|
String qualifiedName = resolvedType.asReferenceType().getQualifiedName();
|
||||||
String className = qualifiedName.substring(qualifiedName.lastIndexOf('.') + 1);
|
String className = qualifiedName.substring(qualifiedName.lastIndexOf('.') + 1);
|
||||||
String packageName = qualifiedName.substring(0, qualifiedName.lastIndexOf('.'));
|
String packageName = "";
|
||||||
container.putClassReference(className, new ClassReferenceLocation(ParserUtil.getOwner(container),
|
if (qualifiedName.contains("."))
|
||||||
packageName.replace('.', '/'), fieldValue.name, "reference", scopeValue.line, scopeValue.columnStart,
|
packageName = qualifiedName.substring(0, qualifiedName.lastIndexOf('.')).replace('.', '/');
|
||||||
scopeValue.columnEnd + 1));
|
|
||||||
|
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,
|
container.putField(fieldValue.name, new ClassFieldLocation(scopeValue.name, "reference", fieldValue.line,
|
||||||
fieldValue.columnStart, fieldValue.columnEnd + 1));
|
fieldValue.columnStart, fieldValue.columnEnd + 1));
|
||||||
}
|
}
|
||||||
|
@ -166,10 +167,12 @@ class ParserUtil
|
||||||
|
|
||||||
String qualifiedName = referenceType.getQualifiedName();
|
String qualifiedName = referenceType.getQualifiedName();
|
||||||
String className = qualifiedName.substring(qualifiedName.lastIndexOf('.') + 1);
|
String className = qualifiedName.substring(qualifiedName.lastIndexOf('.') + 1);
|
||||||
String packageName = qualifiedName.substring(0, qualifiedName.lastIndexOf('.'));
|
String packageName = "";
|
||||||
container.putClassReference(className, new ClassReferenceLocation(ParserUtil.getOwner(container),
|
if (qualifiedName.contains("."))
|
||||||
packageName.replace('.', '/'), "", "reference", scopeValue.line, scopeValue.columnStart,
|
packageName = qualifiedName.substring(0, qualifiedName.lastIndexOf('.')).replace('.', '/');
|
||||||
scopeValue.columnEnd + 1));
|
|
||||||
|
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