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 loggingMsg_nodeSubstitute_Contribution extends SubstituteMenuBase {
public loggingMsg_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 loggingMsg_nodeSubstitute_Contribution.SMP_Param_ax7x23_a(), MetaAdapterFactory.getConcept(0x760a0a8ceabb4521L, 0x8bfd65db761a9ba3L, 0x57e2cf14f6d5a71dL, "jetbrains.mps.baseLanguage.logging.structure.MsgStatement")));
return result;
}
private class SMP_Param_ax7x23_a extends ParameterizedMenuPart<SEnumerationLiteral, SubstituteMenuItem, SubstituteMenuContext> {
@NotNull
@Override
protected List<SubstituteMenuItem> createItems(SEnumerationLiteral parameter, SubstituteMenuContext context) {
return new loggingMsg_nodeSubstitute_Contribution.SMP_Param_ax7x23_a.SMP_Action_ax7x23_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_ax7x23_a0 extends SingleItemSubstituteMenuPart {
private final SEnumerationLiteral myParameterObject;
public SMP_Action_ax7x23_a0(SEnumerationLiteral parameterObject) {
myParameterObject = parameterObject;
}
@Nullable
@Override
protected SubstituteMenuItem createItem(SubstituteMenuContext _context) {
return new loggingMsg_nodeSubstitute_Contribution.SMP_Param_ax7x23_a.SMP_Action_ax7x23_a0.Item(_context);
}
private class Item extends DefaultSubstituteMenuItem {
private final SubstituteMenuContext _context;
public Item(SubstituteMenuContext context) {
super(MetaAdapterFactory.getConcept(0x760a0a8ceabb4521L, 0x8bfd65db761a9ba3L, 0x57e2cf14f6d5a71dL, "jetbrains.mps.baseLanguage.logging.structure.MsgStatement"), 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, 0x57e2cf14f6d5a71dL, "jetbrains.mps.baseLanguage.logging.structure.MsgStatement")), null);
SPropertyOperations.set(logStatement, MetaAdapterFactory.getProperty(0x760a0a8ceabb4521L, 0x8bfd65db761a9ba3L, 0x57e2cf14f6d5a71dL, 0x57e2cf14f6d5d81fL, "severity"), SEnumOperations.getMemberValue(myParameterObject));
SNodeFactoryOperations.setNewChild(logStatement, MetaAdapterFactory.getContainmentLink(0x760a0a8ceabb4521L, 0x8bfd65db761a9ba3L, 0x57e2cf14f6d5a71dL, 0x4f67298c4630c25eL, "message"), 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)) {
SNode lvr = SLinkOperations.setNewChild(logStatement, MetaAdapterFactory.getContainmentLink(0x760a0a8ceabb4521L, 0x8bfd65db761a9ba3L, 0x57e2cf14f6d5a71dL, 0x4f67298c4630c25fL, "throwable"), 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 "message " + SEnumOperations.getMemberValue(myParameterObject);
}
@Nullable
@Override
public String getDescriptionText(@NotNull String pattern) {
return "prints to the messages view";
}
@Override
public void select(@NotNull SNode createdNode, @NotNull String pattern) {
SelectionUtil.selectCell(_context.getEditorContext(), createdNode, SelectionManager.LAST_EDITABLE_CELL);
}
}
}
}
}