use of nl.ramsolutions.sw.magik.analysis.typing.ITypeKeeper in project magik-tools by StevenLooman.
the class MethodReturnMatchesDocTypedCheck method extractMethodDocResult.
private ExpressionResult extractMethodDocResult(final AstNode node) {
final PackageNodeHelper packageHelper = new PackageNodeHelper(node);
final String currentPakkage = packageHelper.getCurrentPackage();
final NewDocParser docParser = new NewDocParser(node);
final ITypeKeeper typeKeeper = this.getTypeKeeper();
final TypeParser typeParser = new TypeParser(typeKeeper);
final List<AbstractType> docReturnTypes = docParser.getReturnTypes().stream().map(typeStr -> typeParser.parseTypeString(typeStr, currentPakkage)).collect(Collectors.toList());
return new ExpressionResult(docReturnTypes);
}
use of nl.ramsolutions.sw.magik.analysis.typing.ITypeKeeper in project magik-tools by StevenLooman.
the class NewDocTypeExistsTypeCheck method checkDefinitionParameters.
private void checkDefinitionParameters(final NewDocParser newDocParser, final String pakkage) {
// Test @param types.
final ITypeKeeper typeKeeper = this.getTypeKeeper();
final TypeParser typeParser = new TypeParser(typeKeeper);
newDocParser.getParameterTypeNodes().entrySet().stream().filter(entry -> typeParser.parseTypeString(entry.getValue(), pakkage) == UndefinedType.INSTANCE).forEach(entry -> {
final AstNode typeNode = entry.getKey();
final String typeName = entry.getValue();
final String message = String.format(MESSAGE, typeName);
this.addIssue(typeNode, message);
});
}
use of nl.ramsolutions.sw.magik.analysis.typing.ITypeKeeper in project magik-tools by StevenLooman.
the class NewDocTypeExistsTypeCheck method checkDefinitionReturns.
private void checkDefinitionReturns(final NewDocParser newDocParser, final String pakkage) {
// Test @return types.
final ITypeKeeper typeKeeper = this.getTypeKeeper();
final TypeParser typeParser = new TypeParser(typeKeeper);
newDocParser.getReturnTypeNodes().entrySet().stream().filter(entry -> typeParser.parseTypeString(entry.getValue(), pakkage) == UndefinedType.INSTANCE).forEach(entry -> {
final AstNode typeNode = entry.getKey();
final String typeName = entry.getValue();
final String message = String.format(MESSAGE, typeName);
this.addIssue(typeNode, message);
});
}
use of nl.ramsolutions.sw.magik.analysis.typing.ITypeKeeper in project magik-tools by StevenLooman.
the class MagikTypedCheck method getTypeKeeper.
/**
* Get ITypeKeeper.
* @return ITypeKeeper.
*/
protected ITypeKeeper getTypeKeeper() {
final MagikFile magikFile = this.getMagikFile();
if (!(magikFile instanceof MagikTypedFile)) {
throw new IllegalStateException();
}
final MagikTypedFile magikTypedFile = (MagikTypedFile) magikFile;
final ITypeKeeper typeKeeper = magikTypedFile.getTypeKeeper();
return new ReadOnlyTypeKeeperAdapter(typeKeeper);
}
use of nl.ramsolutions.sw.magik.analysis.typing.ITypeKeeper in project magik-tools by StevenLooman.
the class MagikTypedCheck method getTypeOfMethodDefinition.
/**
* Get type of method definition.
* @param node METHOD_DEFINITION node.
* @return
*/
protected AbstractType getTypeOfMethodDefinition(final AstNode node) {
if (node == null) {
// This can happen in case of a procedure definition calling a method on _self.
return UndefinedType.INSTANCE;
}
final MethodDefinitionNodeHelper methodDefHelper = new MethodDefinitionNodeHelper(node);
final GlobalReference globalRef = methodDefHelper.getTypeGlobalReference();
final ITypeKeeper typeKeeper = this.getTypeKeeper();
return typeKeeper.getType(globalRef);
}
Aggregations