eclipse-sirius / sirius-desktop

Sirius Desktop: desktop-based graphical modelers for dedicated DSLs
https://eclipse.dev/sirius/
Eclipse Public License 2.0
14 stars 11 forks source link

Provide a NotAResourceStrategyImpl #301

Open ewillink opened 6 months ago

ewillink commented 6 months ago

OCL provides an AS counterpart to Xtext/CS resources analoguously to Java's class files and java files. If the AS file is saved, bad things, such as no transaction, happen when Sirius processes both CS and AS. Simple solution: register a ResourceStrategy to inhibit Sirius's semantic resource recognition of OCL AS files.

Unfortunately Sirius does not provide a parameterisable extension point; it is necessary for application code such as OCL to provide a derived Sirius class even though OCL has no Sirius dependencies.

If the following was supported:

<extension point="org.eclipse.sirius.resourceStrategy">
      <resourceStrategy class="org.eclipse.sirius.ecore.extender.NotAResourceStrategyImpl" excludedExtensions="oclas,qvtcas,qvrtas"/>
   </extension>

OCL and QVTd could configure Sirius without adding a dependency.

And in the spirit of eating one's own dog food, Sirius could replace isVsmModel and isRepFIle by

<extension point="org.eclipse.sirius.resourceStrategy">
    <resourceStrategy class="org.eclipse.sirius.ecore.extender.NotAResourceStrategyImpl" excludedExtensions="aird,odesign"/>
</extension>
pcdavid commented 6 months ago

Not saying the proposed approach is not the right one, but reformulating to be sure I understand correctly, what you need/want is a way to tell Sirius to ignore some resources as potential semantic resources (even though they are loadable EMF models), and do so with configuration only to avoid any hard dependency. Is that correct?

ewillink commented 6 months ago

Yes. Many extension points, such as e.g org.eclipse.emf.ecore.uri_mapping allow functionality to be defined purely by parameters. Others such as org.eclipse.core.contenttype.contentTypes may need a functional class that may often be general purpose. org.eclipse.sirius.resourceStrategy has a very general purpose strategy but users are forced to define a custom implementation. This imposes undesirable dependencies at build time and further inconvenience at install time.

As a workaround for 2024-03, OCL and QVTd have to add Sirius dependencies to support e.g. https://git.eclipse.org/r/plugins/gitiles/mmt/org.eclipse.qvtd/+/refs/heads/master/plugins/org.eclipse.qvtd.xtext.qvtbase.ui/src/org/eclipse/qvtd/xtext/qvtbase/ui/QVTdNotAResourceStrategyImpl.java

(Of course one might question why an exception is needed at all. Why can't I draw a diagram that depicts the .aird content? For .aird the answer might be inadequate implementation. For .oclas the answer may be over-aggressive loading. I'm not a fan of proactive indexes. If there was a per-model diagram file just like the original Ecore tools we would not need the .aird index and its many problems.)