package jetbrains.mps.baseLanguage.editor; /*Generated by MPS */ import jetbrains.mps.editor.runtime.descriptor.AbstractEditorBuilder; import org.jetbrains.annotations.NotNull; import org.jetbrains.mps.openapi.model.SNode; import jetbrains.mps.openapi.editor.EditorContext; import jetbrains.mps.openapi.editor.cells.EditorCell; import jetbrains.mps.nodeEditor.cellProviders.CellProviderWithRole; import jetbrains.mps.lang.editor.cellProviders.PropertyCellProvider; import jetbrains.mps.openapi.editor.style.Style; import jetbrains.mps.editor.runtime.style.StyleImpl; import jetbrains.mps.baseLanguage.editor.BaseLanguageStyle_StyleSheet.VariableNameStyleClass; import jetbrains.mps.editor.runtime.style.StyleAttributes; import jetbrains.mps.editor.runtime.style.FocusPolicy; import jetbrains.mps.lang.editor.menus.transformation.NamedTransformationMenuLookup; import jetbrains.mps.smodel.language.LanguageRegistry; import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory; import jetbrains.mps.nodeEditor.cellMenu.CompositeSubstituteInfo; import jetbrains.mps.nodeEditor.cellMenu.SubstituteInfoPartExt; import jetbrains.mps.nodeEditor.cellMenu.SChildSubstituteInfoPartEx; import jetbrains.mps.nodeEditor.EditorManager; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SLinkOperations; import jetbrains.mps.baseLanguage.behavior.Type__BehaviorDescriptor; import jetbrains.mps.lang.editor.generator.internal.AbstractCellMenuPart_PropertyPostfixHints; import java.util.List; import jetbrains.mps.smodel.IOperationContext; import jetbrains.mps.internal.collections.runtime.ListSequence; import java.util.ArrayList; import jetbrains.mps.project.Project; import jetbrains.mps.baseLanguage.behavior.VariableDeclaration__BehaviorDescriptor; import jetbrains.mps.util.NameUtil; /*package*/ class VariableDeclaration_NameCellComponent_ComponentBuilder_a extends AbstractEditorBuilder { @NotNull private SNode myNode; public VariableDeclaration_NameCellComponent_ComponentBuilder_a(@NotNull EditorContext context, @NotNull SNode node) { super(context); myNode = node; } @NotNull @Override public SNode getNode() { return myNode; } /*package*/ EditorCell createCell() { return createProperty_j36akn_a(); } private EditorCell createProperty_j36akn_a() { CellProviderWithRole provider = new PropertyCellProvider(myNode, getEditorContext()); provider.setRole("name"); provider.setNoTargetText("<no name>"); EditorCell editorCell; editorCell = provider.createEditorCell(getEditorContext()); editorCell.setCellId("VDNCC_property_name"); Style style = new StyleImpl(); new VariableNameStyleClass(getEditorContext(), getNode()).apply(style, editorCell); editorCell.getStyle().putAll(style); if (nodeCondition_j36akn_a0()) { editorCell.getStyle().set(StyleAttributes.FOCUS_POLICY, FocusPolicy.FIRST_EDITABLE_CELL); } editorCell.addKeyMap(new IgnoreRightSquareBracketInVariableName()); editorCell.setTransformationMenuLookup(new NamedTransformationMenuLookup(LanguageRegistry.getInstance(getEditorContext().getRepository()), MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c37a7f6eL, "jetbrains.mps.baseLanguage.structure.VariableDeclaration"), "jetbrains.mps.baseLanguage.editor.VariableDeclaration_ApplySideTransforms")); editorCell.setSubstituteInfo(new CompositeSubstituteInfo(getEditorContext(), provider.getCellContext(), new SubstituteInfoPartExt[]{new VariableDeclaration_NameCellComponent_ComponentBuilder_a.VariableDeclaration_name_postfixCellMenu_j36akn_a0a(), new SChildSubstituteInfoPartEx(editorCell)})); SNode attributeConcept = provider.getRoleAttribute(); if (attributeConcept != null) { EditorManager manager = EditorManager.getInstanceFromContext(getEditorContext()); return manager.createNodeRoleAttributeCell(attributeConcept, provider.getRoleAttributeKind(), editorCell); } else return editorCell; } private boolean nodeCondition_j36akn_a0() { boolean condition = SNodeOperations.getConcept(SLinkOperations.getTarget(myNode, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x450368d90ce15bc3L, 0x4ed4d318133c80ceL, "type"))) != MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c37f506dL, "jetbrains.mps.baseLanguage.structure.Type"); if (SNodeOperations.isInstanceOf(SLinkOperations.getTarget(myNode, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x450368d90ce15bc3L, 0x4ed4d318133c80ceL, "type")), MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xf8c37f506dL, "jetbrains.mps.baseLanguage.structure.Type"))) { return condition && !((boolean) Type__BehaviorDescriptor.hasMissingParameters_id32KZwowVoMu.invoke(SLinkOperations.getTarget(myNode, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x450368d90ce15bc3L, 0x4ed4d318133c80ceL, "type")))); } else { return condition; } } public static class VariableDeclaration_name_postfixCellMenu_j36akn_a0a extends AbstractCellMenuPart_PropertyPostfixHints { public VariableDeclaration_name_postfixCellMenu_j36akn_a0a() { } public List<String> getPostfixes(SNode node, IOperationContext operationContext, EditorContext editorContext) { List<String> result = ListSequence.fromList(new ArrayList<String>()); SNode nodeType = SLinkOperations.getTarget(node, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x450368d90ce15bc3L, 0x4ed4d318133c80ceL, "type")); if (nodeType != null) { List<String> names = Type__BehaviorDescriptor.getVariableSuffixes_idhEwIzNo.invoke(nodeType); Project project = operationContext.getProject(); for (String name : names) { String prefix = VariableDeclaration__BehaviorDescriptor.getPrefix_id2Bet8mWh2lw.invoke(node, project); String suffix = VariableDeclaration__BehaviorDescriptor.getSuffix_id2Bet8mWh3pg.invoke(node, project); String mainName = ((prefix == null || prefix.length() == 0) ? name : NameUtil.capitalize(name)); ListSequence.fromList(result).addElement(prefix + mainName + suffix); } } return result; } } }