Plugin development dependency to TextGenOutcomeResource


I'm creating a new intellij plugin and i'm trying to get the generated code for a model.

But i'm getting "NoClassDefFoundError: jetbrains/mps/lang/core/plugin/TextGenOutcomeResource" and my plugin has the following dependencies:

  • <depends>jetbrains.mps.core</depends>
  • <depends></depends>
  • <depends></depends>

Can you help me solving this problem?




Hi Raul

The dependency on jetbrains.mps.core is enough in terms of plugin dependencies. However, the class you're trying to use belongs to a language, namely jetbrains.mps.lang.core. To be able to use it, you should reference it from a class that also lives in a language (or a plugin solution, i.e. a module for which mps creates a classloader) and that language or solution must have a dependency on jetbrains.mps.lang.core.

It has to with classloaders. The code that you just write as part of your plugin is loaded by the plugin class loader. Languages and plugin solutions are loaded by their own classloaders. The latter will see classes from the former, but not vice versa.

Could you describe, what exactly you want to do?



Hi Daniil,

Thanks for the reply.

I'm trying to get the generated text of a root node, for that i'm trying to do the same of preview generated text functionality used in MPS. But i'm doing this using an intellij plugin.

The code i'm using is:

public class PreviewGeneratedText extends AnAction {

public void actionPerformed(AnActionEvent event) {
GenerationSettingsProvider.getInstance().setGenerationSettings(new DefaultModifiableGenerationSettings());
final MPSProject mpsProject = event.getData(MPSCommonDataKeys.MPS_PROJECT);
final Project ideaProject = event.getData(CommonDataKeys.PROJECT);
final DefaultMakeMessageHandler msgHandler = new DefaultMakeMessageHandler(mpsProject);
MakeSession session = new MakeSession(mpsProject, msgHandler, true);
final SNodeReference contextNode = (event.getData(MPSCommonDataKeys.NODE) == null ? null : event.getData(MPSCommonDataKeys.NODE).getReference());
final WorkbenchMakeService buildMakeService = new WorkbenchMakeService(ApplicationManager.getApplication().getComponent(jetbrains.mps.ide.platform.watching.ReloadManagerComponent.class));
//if (IMakeService.INSTANCE.get().openNewSession(session)) {
if (buildMakeService.openNewSession(session)) {
IScript scr = new ScriptBuilder().withFacetNames(new IFacet.Name("jetbrains.mps.lang.core.Generate"), new IFacet.Name("jetbrains.mps.lang.core.TextGen"), new IFacet.Name("jetbrains.mps.make.facets.Make")).withFinalTarget(new ITarget.Name("jetbrains.mps.lang.core.TextGen.textGenToMemory")).toScript();
ModelAccess modelAccess = mpsProject.getRepository().getModelAccess();
modelAccess.executeCommand(new Runnable() {
public void run() {
SModule module = mpsProject.getRepository().getModule(PersistenceFacade.getInstance().createModuleId("~CompileMPSTestProject"));
SModelId modelId = PersistenceFacade.getInstance().createModelId("r:1e65c28d-c1bf-4079-8da8-bf2174d10d1b");
EditableSModel model = (EditableSModel) module.getModel(modelId);
final SModelReference model2generateRef = model.getReference();
//final Future<IResult> future = IMakeService.INSTANCE.get().make(session, new ModelsToResources(Sequence.<SModel>singleton(model)).resources(false), scr);
final Future<IResult> future = buildMakeService.make(session, new ModelsToResources(Sequence.<SModel>singleton(model)).resources(false), scr);
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
public void run() {
try {
final IResult result = future.get();
final List<TextPreviewFile> previewFiles = new ModelAccessHelper(mpsProject.getModelAccess()).runReadAction(new Computable<List<TextPreviewFile>>() {
public List<TextPreviewFile> compute() {
ArrayList<TextPreviewFile> rv = new ArrayList<TextPreviewFile>();
for (TextGenOutcomeResource tgr : Sequence.fromIterable(result.output()).ofType(TextGenOutcomeResource.class)) {
// XXX don't see too much value in modelName, shall drop?
String modelName = NameUtil.compactNamespace(tgr.getModel().getModelName());
final SRepository repo = mpsProject.getRepository();
SNode cn = (contextNode == null ? null : contextNode.resolve(repo));
List<SNode> ancestors = (cn == null ? new ArrayList<SNode>() : SNodeOperations.getNodeAncestors(cn, null, true));
for (TextUnit tu : tgr.getTextGenResult().getUnits()) {
if (cn != null) {
SNode originalStart = TracingUtil.getInputNode(tu.getStartNode(), repo);
if (originalStart != null && !(ListSequence.fromList(ancestors).contains(originalStart))) {
rv.add(new TextPreviewFile(tu, modelName));
return rv;

ApplicationManager.getApplication().invokeLater(new Runnable() {
public void run() {
if (previewFiles.isEmpty()) {
StringBuilder message = new StringBuilder();
message.append("Model processed:");
if (contextNode != null) {
message.append("Context node:");
if (result.isSucessful()) {
message.append("Text generation completed successfully\n");
} else {
message.append("Text generation completed with errors\n");
if (contextNode != null) {
message.append("None of generated text units reference context node");
} else {
message.append("There were no text units generated.");
previewFiles.add(new TextPreviewFile("TextGen", message.toString(), model2generateRef.getModelName()));
FileEditorManager fem = FileEditorManager.getInstance(ideaProject);
for (TextPreviewFile f : ListSequence.fromList(previewFiles)) {
fem.openTextEditor(new OpenFileDescriptor(ideaProject, f), true);
// to update tree to reveal transient models. is it still necessary?
// ProjectPane.getInstance(mpsProject).rebuild();
} catch (Exception e) {
msgHandler.handle(new Message(MessageKind.ERROR, "TextPreviewModel", e.toString()).setException(e));


private SModel modelToGenerate(final AnActionEvent event) {
SModel md = null;
if (event.getData(MPSCommonDataKeys.CONTEXT_MODEL) != null) {
md = event.getData(MPSCommonDataKeys.CONTEXT_MODEL);
} else if (event.getData(MPSCommonDataKeys.MODELS) != null && event.getData(MPSCommonDataKeys.MODELS).size() > 0) {
md = event.getData(MPSCommonDataKeys.MODELS).get(0);
return md;

I hope this helps.






Please sign in to leave a comment.