@Override public void commitValue() { IntellicutListEntry listEntry = (IntellicutListEntry) intellicutPanel.getIntellicutList().getSelectedValue(); if (listEntry != null) { GemEntity gemEntity = (GemEntity) listEntry.getData(); ModuleTypeInfo currentModuleInfo = valueEditorManager.getPerspective().getWorkingModuleTypeInfo(); TypeExpr valueNodeType = getValueNode().getTypeExpr(); TypeExpr functionType = gemEntity.getTypeExpr(); TypeExpr unifiedType; try { unifiedType = TypeExpr.unify(valueNodeType, functionType, currentModuleInfo); } catch (TypeException e) { throw new IllegalStateException(e.getMessage()); } GemEntityValueNode newValueNode = new GemEntityValueNode(gemEntity, unifiedType); replaceValueNode(newValueNode, true); } super.commitValue(); }
@Override protected IntellicutInfo getIntellicutInfo(IntellicutListEntry data) { if (data.getTypeExpr().getArity() != getValueNode().getTypeExpr().getArity()) { return null; } return getIntellicutInfo( data, getValueNode().getTypeExpr(), valueEditorManager.getTypeCheckInfo(), false, null); }
/** {@inheritDoc} */ @Override protected void commitValue() { IntellicutListEntry listEntry = (IntellicutListEntry) intellicutPanel.getIntellicutList().getSelectedValue(); if (listEntry != null) { // Note: For TypeExpr which contains uninstantiated TypeVars, we must 'duplicate' them // somehow. TypeExpr instanceTypeExpr = ((TypeExpr) listEntry.getData()).copyTypeExpr(); ValueNode replacement = getOwnerValueNode() .transmuteValueNode( valueEditorManager.getValueNodeBuilderHelper(), valueEditorManager.getValueNodeTransformer(), instanceTypeExpr); // Get the TypeVar that we are instantiating. replaceValueNode(replacement, true); notifyValueCommitted(); } }
@Override public String getToolTipTextForEntry(IntellicutListEntry listEntry, JComponent invoker) { Object listEntryData = listEntry.getData(); if (listEntryData instanceof RecordType) { return "<html><body><b>Prelude Record</b></body></html>"; } else if (listEntryData instanceof TypeConsApp) { TypeConsApp typeConsApp = (TypeConsApp) listEntryData; QualifiedName typeConsName = typeConsApp.getName(); TypeConstructor typeCons = valueEditorManager.getPerspective().getTypeConstructor(typeConsName); return ToolTipHelpers.getEntityToolTip( typeCons, getNamingPolicy(), valueEditorManager.getWorkspace(), invoker); } else { throw new IllegalStateException("ParametricValueEditor: Unsupported list entry type"); } }