Search in sources :

Example 16 with Doc

use of ast.Ast.Doc in project L42 by ElvisResearchGroup.

the class PlgWrapperGenerator method checkForInside.

private static void checkForInside(ClassB lTop, Path csTop, Path originalPath) throws ClassUnfit, MethodUnfit {
    if (originalPath.isPrimitive()) {
        throw new RefactorErrors.MethodUnfit().msg("Method signature not supported:\n parameters can not be Void/Any/fwd.\n" + "returns can not be Any/fwd\n" + "exceptions can not be Any/Void/Library");
    }
    Path cs = From.fromP(originalPath, csTop);
    assert cs.outerNumber() == 0;
    List<Ast.C> cBar = cs.getCBar();
    ClassB lPointed = lTop.getClassB(cBar);
    Doc d = lPointed.getDoc1();
    if (d._getParameterForPlugin() == null || d._getParameterForPluginPart() == null) {
        throw new RefactorErrors.ClassUnfit().msg("Class " + cBar + " doesnot have @pluginPart annotation");
    }
}
Also used : Path(ast.Ast.Path) Doc(ast.Ast.Doc) ClassUnfit(is.L42.connected.withSafeOperators.pluginWrapper.RefactorErrors.ClassUnfit) MethodUnfit(is.L42.connected.withSafeOperators.pluginWrapper.RefactorErrors.MethodUnfit) ClassB(ast.ExpCore.ClassB)

Example 17 with Doc

use of ast.Ast.Doc in project L42 by ElvisResearchGroup.

the class AddDocumentation method addDocumentationOnMethod.

public static ClassB addDocumentationOnMethod(Program p, ClassB cb, List<Ast.C> cs, MethodSelector sel, Doc doc) {
    Errors42.checkExistsPathMethod(cb, cs, Optional.of(sel));
    if (cs.isEmpty()) {
        cb = auxAddDocOnMethod(p, cb, sel, doc);
    } else {
        Program p1 = p.evilPush(cb);
        if (cs.size() > 1) {
            p1 = p1.navigate(cs.subList(0, cs.size() - 1));
        }
        Program p2 = p1;
        cb = cb.onClassNavigateToPathAndDo(cs, cbi -> auxAddDocOnMethod(p2, cbi, sel, doc));
    }
    return cb;
}
Also used : Resources(platformSpecific.javaTranslation.Resources) Program(programReduction.Program) Ast(ast.Ast) Doc(ast.Ast.Doc) InvalidMwtAsState(ast.Util.InvalidMwtAsState) Configuration(facade.Configuration) Assertions(tools.Assertions) Member(ast.ExpCore.ClassB.Member) MethodWithType(ast.ExpCore.ClassB.MethodWithType) Collectors(java.util.stream.Collectors) MethodSelector(ast.Ast.MethodSelector) Functions(auxiliaryGrammar.Functions) ArrayList(java.util.ArrayList) List(java.util.List) ClassB(ast.ExpCore.ClassB) Optional(java.util.Optional) Mdf(ast.Ast.Mdf) Program(programReduction.Program)

Example 18 with Doc

use of ast.Ast.Doc in project L42 by ElvisResearchGroup.

the class Plugin method MaddDocumentation£xthat£xpath£xselector£xdoc.

@ActionType({ ActionType.NormType.Library, ActionType.NormType.Library, ActionType.NormType.Library, ActionType.NormType.Library, ActionType.NormType.Library })
public Object MaddDocumentation£xthat£xpath£xselector£xdoc(Object _that, Object _path, Object _sel, Object _doc) {
    ClassB that = ensureExtractClassB(_that);
    List<Ast.C> path = PathAux.parseValidCs(ensureExtractStringU(_path));
    MethodSelector sel = MethodSelector.parse(ensureExtractStringU(_sel));
    Doc doc = ensureExtractDoc(_doc);
    return AddDocumentation.addDocumentationOnMethod(Resources.getP(), that, path, sel, doc);
}
Also used : MethodSelector(ast.Ast.MethodSelector) Doc(ast.Ast.Doc) EncodingHelper.ensureExtractDoc(auxiliaryGrammar.EncodingHelper.ensureExtractDoc) ClassB(ast.ExpCore.ClassB) EncodingHelper.ensureExtractClassB(auxiliaryGrammar.EncodingHelper.ensureExtractClassB) ActionType(platformSpecific.fakeInternet.ActionType)

Example 19 with Doc

use of ast.Ast.Doc in project L42 by ElvisResearchGroup.

the class ToAst method visitMxRound.

@Override
public Expression visitMxRound(MxRoundContext ctx) {
    String mx = ctx.MX().getText();
    assert mx.endsWith("(");
    mx = mx.substring(0, mx.length() - 1);
    RoundContext r = ctx.round();
    Doc doc = parseDoc(r.docsOpt());
    assert !mx.startsWith("#");
    assert !mx.startsWith("\\");
    Expression rcv = new Expression.X(position(ctx), mx);
    //Expression rcv= (mx.startsWith("#"))?new Expression.ContextId(mx):new Expression.X(mx);
    return new Expression.FCall(position(r), rcv, doc, parseMParameters(r.ps()));
}
Also used : Expression(ast.Expression) MethodSelectorX(ast.Ast.MethodSelectorX) Doc(ast.Ast.Doc)

Example 20 with Doc

use of ast.Ast.Doc in project L42 by ElvisResearchGroup.

the class ToAst method visitCurlyBlock.

@Override
public Expression visitCurlyBlock(CurlyBlockContext ctx) {
    Doc doc = parseDoc(ctx.docsOpt());
    List<BlockContent> contents = new ArrayList<BlockContent>();
    for (BbContext b : ctx.bb()) {
        List<VarDec> decs = new ArrayList<VarDec>();
        for (DContext d : b.d()) {
            decs.add(parseVDec(d));
        }
        assert b.ks() != null;
        List<Catch> _catch = parseKs(b.ks());
        contents.add(new BlockContent(decs, _catch));
    }
    return new Expression.CurlyBlock(position(ctx), doc, contents);
}
Also used : Catch(ast.Expression.Catch) VarDec(ast.Ast.VarDec) BlockContent(ast.Expression.BlockContent) Doc(ast.Ast.Doc)

Aggregations

Doc (ast.Ast.Doc)27 ArrayList (java.util.ArrayList)11 Ast (ast.Ast)9 ClassB (ast.ExpCore.ClassB)9 Expression (ast.Expression)9 Path (ast.Ast.Path)8 MethodType (ast.Ast.MethodType)7 Type (ast.Ast.Type)7 ExpCore (ast.ExpCore)7 MethodSelector (ast.Ast.MethodSelector)5 List (java.util.List)5 Optional (java.util.Optional)5 VarDec (ast.Ast.VarDec)4 Member (ast.ExpCore.ClassB.Member)4 Catch (ast.Expression.Catch)4 Mdf (ast.Ast.Mdf)3 Position (ast.Ast.Position)3 Block (ast.ExpCore.Block)3 MethodWithType (ast.ExpCore.ClassB.MethodWithType)3 Phase (ast.ExpCore.ClassB.Phase)3