From: Hannu Niemistö Date: Wed, 15 Nov 2017 07:11:32 +0000 (+0200) Subject: (refs #7619) Better parenthese in derived show X-Git-Tag: v1.31.0~36^2 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F24%2F1224%2F1;p=simantics%2Fplatform.git (refs #7619) Better parenthese in derived show Change-Id: Ia0ce420d8958395f787f08926a14e7bfd6fc2bcd --- diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/deriving/ShowDeriver.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/deriving/ShowDeriver.java index afd2a4f89..40c3605e7 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/deriving/ShowDeriver.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/deriving/ShowDeriver.java @@ -81,33 +81,55 @@ class ShowDeriver implements InstanceDeriver { for(int i=0;iemptyList()));*/ + } catch (NotPatternException e) { + errorLog.log(e.getExpression().location, "Not a pattern."); + } } - - try { - DValueAst valueAst = new DValueAst(lhs, value); - valueAst.setLocationDeep(der.location); - valueDefs.add(valueAst); - /*valueDefs.addAnnotation("<+", new DAnnotationAst(new EVar("@private"), - Collections.emptyList()));*/ - } catch (NotPatternException e) { - errorLog.log(e.getExpression().location, "Not a pattern."); + + // precedence + { + Expression lhs = new EApply( + new EVar("precedence"), + new EApply(new EVar(constructor.name.name), Expressions.vars(par)) + ); + Expression value; + value = new ELiteral(new IntegerConstant(l == 0 ? 0 : 20)); + + try { + DValueAst valueAst = new DValueAst(lhs, value); + valueAst.setLocationDeep(der.location); + valueDefs.add(valueAst); + } catch (NotPatternException e) { + errorLog.log(e.getExpression().location, "Not a pattern."); + } } } instancesAst.add(new ProcessedDInstanceAst(instanceAst, valueDefs));