Search in sources :

Example 1 with AliasType

use of nl.ramsolutions.sw.magik.analysis.typing.types.AliasType in project magik-tools by StevenLooman.

the class JsonTypeKeeperReader method handleGlobal.

private void handleGlobal(final JSONObject instruction) {
    final String name = instruction.getString("name");
    final GlobalReference globalRef = GlobalReference.of(name);
    final String typeName = instruction.getString("type_name");
    final ExpressionResult parsedResult = this.typeParser.parseExpressionResultString(typeName, SW_PAKKAGE);
    final AbstractType type = parsedResult.get(0, UndefinedType.INSTANCE);
    final AliasType global = new AliasType(globalRef, type);
    this.typeKeeper.addType(global);
}
Also used : GlobalReference(nl.ramsolutions.sw.magik.analysis.typing.types.GlobalReference) ExpressionResult(nl.ramsolutions.sw.magik.analysis.typing.types.ExpressionResult) AbstractType(nl.ramsolutions.sw.magik.analysis.typing.types.AbstractType) AliasType(nl.ramsolutions.sw.magik.analysis.typing.types.AliasType)

Example 2 with AliasType

use of nl.ramsolutions.sw.magik.analysis.typing.types.AliasType in project magik-tools by StevenLooman.

the class MagikIndexer method handleDefinition.

@SuppressWarnings("java:S1172")
private void handleDefinition(final MagikFile magikFile, final GlobalDefinition globalDefinition) {
    final String pakkage = globalDefinition.getPackage();
    final String identifier = globalDefinition.getName();
    final GlobalReference globalRef = typeParser.getGlobalRefeference(identifier, pakkage);
    if (this.typeKeeper.getType(globalRef) != null) {
        // Don't overwrite any existing types with a AliasType.
        return;
    }
    final String typeAnnotation = TypeAnnotationHandler.typeAnnotationForExpression(globalDefinition.getNode());
    final AbstractType aliasedType = typeAnnotation != null ? this.typeParser.parseTypeString(typeAnnotation, globalDefinition.getPackage()) : UndefinedType.INSTANCE;
    final AbstractType globalType = new AliasType(globalRef, aliasedType);
    this.typeKeeper.addType(globalType);
    final Path path = Paths.get(magikFile.getUri());
    this.indexedTypes.get(path).add(globalType);
}
Also used : Path(java.nio.file.Path) GlobalReference(nl.ramsolutions.sw.magik.analysis.typing.types.GlobalReference) AbstractType(nl.ramsolutions.sw.magik.analysis.typing.types.AbstractType) AliasType(nl.ramsolutions.sw.magik.analysis.typing.types.AliasType)

Aggregations

AbstractType (nl.ramsolutions.sw.magik.analysis.typing.types.AbstractType)2 AliasType (nl.ramsolutions.sw.magik.analysis.typing.types.AliasType)2 GlobalReference (nl.ramsolutions.sw.magik.analysis.typing.types.GlobalReference)2 Path (java.nio.file.Path)1 ExpressionResult (nl.ramsolutions.sw.magik.analysis.typing.types.ExpressionResult)1