package jetbrains.mps.baseLanguage.logging.editor; /*Generated by MPS */ import jetbrains.mps.nodeEditor.menus.substitute.SubstituteMenuBase; import org.jetbrains.annotations.NotNull; import java.util.List; import jetbrains.mps.lang.editor.menus.MenuPart; import jetbrains.mps.openapi.editor.menus.substitute.SubstituteMenuItem; import jetbrains.mps.openapi.editor.menus.substitute.SubstituteMenuContext; import java.util.ArrayList; import jetbrains.mps.lang.editor.menus.substitute.ConstraintsFilteringSubstituteMenuPartDecorator; import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory; import jetbrains.mps.lang.editor.menus.ParameterizedMenuPart; import org.jetbrains.mps.openapi.language.SEnumerationLiteral; import org.jetbrains.annotations.Nullable; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SEnumOperations; import jetbrains.mps.lang.editor.menus.substitute.SingleItemSubstituteMenuPart; import jetbrains.mps.lang.editor.menus.substitute.DefaultSubstituteMenuItem; import org.jetbrains.mps.openapi.model.SNode; import jetbrains.mps.smodel.action.SNodeFactoryOperations; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SPropertyOperations; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SLinkOperations; import jetbrains.mps.smodel.runtime.IconResource; import jetbrains.mps.editor.runtime.selection.SelectionUtil; import jetbrains.mps.openapi.editor.selection.SelectionManager; public class logging_nodeSubstitute_Contribution extends SubstituteMenuBase { public logging_nodeSubstitute_Contribution() { super(true); } @NotNull @Override protected List<MenuPart<SubstituteMenuItem, SubstituteMenuContext>> getParts(final SubstituteMenuContext _context) { List<MenuPart<SubstituteMenuItem, SubstituteMenuContext>> result = new ArrayList<MenuPart<SubstituteMenuItem, SubstituteMenuContext>>(); result.add(new ConstraintsFilteringSubstituteMenuPartDecorator(new logging_nodeSubstitute_Contribution.SMP_Param_85vuih_a(), MetaAdapterFactory.getConcept(0x760a0a8ceabb4521L, 0x8bfd65db761a9ba3L, 0x10fc428b1dfL, "jetbrains.mps.baseLanguage.logging.structure.LogStatement"))); return result; } private class SMP_Param_85vuih_a extends ParameterizedMenuPart<SEnumerationLiteral, SubstituteMenuItem, SubstituteMenuContext> { @NotNull @Override protected List<SubstituteMenuItem> createItems(SEnumerationLiteral parameter, SubstituteMenuContext context) { return new logging_nodeSubstitute_Contribution.SMP_Param_85vuih_a.SMP_Action_85vuih_a0(parameter).createItems(context); } @Nullable @Override protected Iterable<? extends SEnumerationLiteral> getParameters(SubstituteMenuContext _context) { return SEnumOperations.getMembers(0x760a0a8ceabb4521L, 0x8bfd65db761a9ba3L, "jetbrains.mps.baseLanguage.logging", 0x10fc53ae113L, "Severity"); } private class SMP_Action_85vuih_a0 extends SingleItemSubstituteMenuPart { private final SEnumerationLiteral myParameterObject; public SMP_Action_85vuih_a0(SEnumerationLiteral parameterObject) { myParameterObject = parameterObject; } @Nullable @Override protected SubstituteMenuItem createItem(SubstituteMenuContext _context) { return new logging_nodeSubstitute_Contribution.SMP_Param_85vuih_a.SMP_Action_85vuih_a0.Item(_context); } private class Item extends DefaultSubstituteMenuItem { private final SubstituteMenuContext _context; public Item(SubstituteMenuContext context) { super(MetaAdapterFactory.getConcept(0x760a0a8ceabb4521L, 0x8bfd65db761a9ba3L, 0x10fc428b1dfL, "jetbrains.mps.baseLanguage.logging.structure.LogStatement"), context.getParentNode(), context.getCurrentTargetNode(), context.getEditorContext()); _context = context; } @Nullable @Override public SNode createNode(@NotNull String pattern) { SNode logStatement = SNodeFactoryOperations.createNewNode(_context.getModel(), SNodeFactoryOperations.asInstanceConcept(MetaAdapterFactory.getConcept(0x760a0a8ceabb4521L, 0x8bfd65db761a9ba3L, 0x10fc428b1dfL, "jetbrains.mps.baseLanguage.logging.structure.LogStatement")), null); SPropertyOperations.set(logStatement, MetaAdapterFactory.getProperty(0x760a0a8ceabb4521L, 0x8bfd65db761a9ba3L, 0x10fc428b1dfL, 0x10fc541df63L, "severity"), SEnumOperations.getMemberValue(myParameterObject)); SNodeFactoryOperations.setNewChild(logStatement, MetaAdapterFactory.getContainmentLink(0x760a0a8ceabb4521L, 0x8bfd65db761a9ba3L, 0x10fc428b1dfL, 0x10fc42da590L, "logExpression"), SNodeFactoryOperations.asInstanceConcept(MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf93d565d10L, "jetbrains.mps.baseLanguage.structure.StringLiteral"))); SNode catchClause = SNodeOperations.getNodeAncestor(_context.getParentNode(), MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10f39a56e2fL, "jetbrains.mps.baseLanguage.structure.CatchClause"), true, false); if ((catchClause != null) && (SLinkOperations.getTarget(catchClause, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10f39a56e2fL, 0x10f39a6a2f1L, "throwable")) != null)) { SPropertyOperations.set(logStatement, MetaAdapterFactory.getProperty(0x760a0a8ceabb4521L, 0x8bfd65db761a9ba3L, 0x10fc428b1dfL, 0x10fc43f6f0fL, "hasException"), "" + (true)); SNode lvr = SLinkOperations.setNewChild(logStatement, MetaAdapterFactory.getContainmentLink(0x760a0a8ceabb4521L, 0x8bfd65db761a9ba3L, 0x10fc428b1dfL, 0x10fc42f25e9L, "exception"), MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c77f1e98L, "jetbrains.mps.baseLanguage.structure.VariableReference")); SLinkOperations.setTarget(lvr, MetaAdapterFactory.getReferenceLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c77f1e98L, 0xf8cc6bf960L, "variableDeclaration"), SLinkOperations.getTarget(catchClause, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10f39a56e2fL, 0x10f39a6a2f1L, "throwable"))); } return logStatement; } @Nullable @Override public IconResource getIcon(@NotNull String pattern) { return null; } @Nullable @Override public String getMatchingText(@NotNull String pattern) { return SEnumOperations.getMemberValue(myParameterObject); } @Nullable @Override public String getDescriptionText(@NotNull String pattern) { return "prints both to the messages view and the system log (legacy)"; } @Override public void select(@NotNull SNode createdNode, @NotNull String pattern) { SelectionUtil.selectCell(_context.getEditorContext(), createdNode, SelectionManager.LAST_EDITABLE_CELL); } } } } }