use of com.goide.runconfig.testing.GoTestFunctionType in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoTestSignaturesInspection method checkFile.
@Override
protected void checkFile(@NotNull GoFile file, @NotNull ProblemsHolder problemsHolder) {
if (!GoTestFinder.isTestFile(file))
return;
for (GoFunctionDeclaration function : file.getFunctions()) {
GoTestFunctionType type = GoTestFunctionType.fromName(function.getName());
if (type == null)
continue;
GoSignature signature = function.getSignature();
if (signature == null)
continue;
List<GoParameterDeclaration> params = signature.getParameters().getParameterDeclarationList();
if (type == GoTestFunctionType.EXAMPLE) {
if (!params.isEmpty() || signature.getResult() != null) {
problemsHolder.registerProblem(function.getIdentifier(), "Wrong example signature", new GoTestSignaturesQuickFix(type));
}
} else {
GoParameterDeclaration param = ContainerUtil.getFirstItem(params);
GoImportSpec testingImportSpec = file.getImportedPackagesMap().get(GoConstants.TESTING_PATH);
String testingAlias = GoPsiImplUtil.getImportQualifierToUseInFile(testingImportSpec, GoConstants.TESTING_PATH);
if (GoConstants.TESTING_PATH.equals(file.getImportPath(false))) {
testingAlias = "";
}
if (signature.getResult() != null || testingAlias == null || params.size() != 1 || param == null || !param.getType().textMatches(type.getQualifiedParamType(testingAlias))) {
problemsHolder.registerProblem(function.getIdentifier(), "Wrong test signature", new GoTestSignaturesQuickFix(type));
}
}
}
}
Aggregations