Incomplete completion menu in extended base language editors

Hi,

I want to provide a custom Expression editor, but as soon as I add additional elements code completion is not as expected. My editor looks as follows:

But then code completion looks as follows (i.e., code completion works only for the current type and node substitution is not available anymore).

As soon as I select all elements of the current expression's editor I get the menu. However, typing and code completion is not possible/available. The situation gets even worse as soon as the editor gets more complex.

So am I missing something? Is it possible to solve the issue or is it a bug?

Cheers,

Ben

 

5 comments

Hi,

substitutions, by default, work when you select the whole editor. If you want substitutions to be triggered on a single cell ("next applicable editor" in your case), you need to indicate that in its "menu" property (Inspector) as follows:

menu parts:
    replace node (custom node concept)
    replace with : Expression

Vaclav

 

0

Thanks a lot for the quick response! Precise and helpful as always! :)

0

Hm, if I add the menu parts to the next applicable editor as you said substitutions still not work.

However, adding the menu parts to the constant in the editor gives me in the code a completion menu on pressing ctrl+alt (with the cursor at the constant). Any ideas?

0

Okay, found a workaround. The problem is that for "next applicable editor" the generator doesn't provide substitute information (editorCell.setSubstituteInfo()).

Thus, I created a custom cell provider to workaround the issue:


public class CustomNextApplicableEditor extends AbstractCellProvider {

private EditorContext myContext;
private node<> myNode;

private static concept<> myConcept;
private ConceptEditor myConceptEditor;


public CustomNextApplicableEditor(EditorContext context, node<> node, ConceptEditor conceptEditor, concept<> concept) {
myContext = context;
myNode = node;
myConceptEditor = conceptEditor;
myConcept = concept;
}

public EditorCell createEditorCell(EditorContext context) {
EditorCell nextApplicableEditor = context.getCellFactory().createEditorCell(myNode, false, myConceptEditor.getClass());
// workaround: remove the cell id as it will be set by the custom cell.
// otherwise, we would end in an assertion error due to conflicting cell ids.
try {
Field myCellId = EditorCell_Basic.class.getDeclaredField("myCellId");
myCellId.setAccessible(true);
myCellId.set(nextApplicableEditor, null);
} catch (NoSuchFieldException e) {
error "No field myCellId in " + nextApplicableEditor.getClass(), e;
} catch (IllegalAccessException e) {
error "IllegalAccessException " + nextApplicableEditor.getClass(), e;
}
nextApplicableEditor.setBig(true);
nextApplicableEditor.setSubstituteInfo(new CompositeSubstituteInfo(myContext, new BasicCellContext(myNode), new SubstituteInfoPartExt[]{new ReplaceWith_Expression_cellMenu()}));
return nextApplicableEditor;
}


public static class ReplaceWith_Expression_cellMenu extends AbstractCellMenuPart_ReplaceNode_CustomNodeConcept {

public ReplaceWith_Expression_cellMenu() {
<no statements>
}
protected String getReplacementConceptName() {
return myConcept.toString();
}
}
}
0


Benjamin, thank you for your feedback.

 

I've created the issue:

https://youtrack.jetbrains.com/issue/MPS-24114

 

It will be fixed in the next release

0

Please sign in to leave a comment.