Search in sources :

Example 1 with Import_statementContext

use of org.finos.legend.pure.m3.serialization.grammar.m3parser.antlr.M3Parser.Import_statementContext in project legend-pure by finos.

the class AntlrContextToM3CoreInstance method imports.

private ImportGroup imports(ImportsContext ctx) {
    MutableList<Import> imports = Lists.mutable.empty();
    int importGroupStartLine = -1;
    int importGroupStartColumn = -1;
    int importGroupEndLine = -1;
    int importGroupEndColumn = -1;
    for (Import_statementContext isCtx : ctx.import_statement()) {
        Import _import = ImportInstance.createPersistent(this.repository, this.sourceInformation.getPureSourceInformation(isCtx.getStart(), isCtx.packagePath().getStart(), isCtx.STAR().getSymbol()), this.packageToString(isCtx.packagePath()));
        imports.add(_import);
        SourceInformation sourceInfo = _import.getSourceInformation();
        if (importGroupStartLine == -1) {
            importGroupStartLine = sourceInfo.getStartLine();
            importGroupStartColumn = sourceInfo.getStartColumn();
            importGroupEndLine = sourceInfo.getEndLine();
            importGroupEndColumn = sourceInfo.getEndColumn();
        }
        if (importGroupStartLine > sourceInfo.getStartLine()) {
            importGroupStartLine = sourceInfo.getStartLine();
            importGroupStartColumn = sourceInfo.getStartColumn();
        }
        if (importGroupEndLine < sourceInfo.getEndLine()) {
            importGroupEndLine = sourceInfo.getEndLine();
            importGroupEndColumn = sourceInfo.getEndColumn();
        }
    }
    if (importGroupStartLine == -1) {
        importGroupStartLine = 1 + this.sourceInformation.getOffsetLine();
        importGroupStartColumn = 0;
        importGroupEndLine = 1 + this.sourceInformation.getOffsetLine();
        importGroupEndColumn = 0;
    }
    return buildImportGroupFromImport(this.sourceInformation.getSourceName(), this.count, imports, new SourceInformation(this.sourceInformation.getSourceName(), importGroupStartLine, importGroupStartColumn, importGroupEndLine, importGroupEndColumn));
}
Also used : Import_statementContext(org.finos.legend.pure.m3.serialization.grammar.m3parser.antlr.M3Parser.Import_statementContext) Import(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.Import) Constraint(org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.constraint.Constraint) AntlrSourceInformation(org.finos.legend.pure.m4.serialization.grammar.antlr.AntlrSourceInformation) SourceInformation(org.finos.legend.pure.m4.coreinstance.SourceInformation)

Aggregations

Import (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel._import.Import)1 Constraint (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.constraint.Constraint)1 Import_statementContext (org.finos.legend.pure.m3.serialization.grammar.m3parser.antlr.M3Parser.Import_statementContext)1 SourceInformation (org.finos.legend.pure.m4.coreinstance.SourceInformation)1 AntlrSourceInformation (org.finos.legend.pure.m4.serialization.grammar.antlr.AntlrSourceInformation)1