Coder Social home page Coder Social logo

devboost / emftext Goto Github PK

View Code? Open in Web Editor NEW
13.0 13.0 12.0 303.05 MB

EMFText is an Eclipse plug-in that allows you to define text syntax for languages described by an Ecore metamodel. EMFText enables developers to define textual Domain Specific Languages quickly and without the need to learn new technologies and concepts.

Home Page: http://www.emftext.org

Java 90.35% TeX 0.46% CSS 0.06% HTML 4.13% GAP 4.59% Smalltalk 0.02% C# 0.27% Assembly 0.02% Makefile 0.11%

emftext's People

Contributors

chseidl avatar cwende avatar jjohannes avatar jreimone avatar mirkoseifert avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

emftext's Issues

Outline-View, "Link with Editor": Click in Editor often does not select the right Element in the Outline View

When I toggle the "Link with Editor" button in the outline view and select something in the editor, often the selection in the outline view does not correspond to the selection in the editor. This problem seems to occur, when I select an element in the editor where the corresponding element in the outline view lays inside a branch that is not yet expanded. When I expand the whole tree in the outline view before selecting something in the editor, the selction in the ouline view is always correct.

Use ANTLR 4.0

Hello, ANTLR 4.0 has been released January 22, 2013.
Maybe newer versions of EMFText will use this new version of ANTLR?

EMF Validation - traversal strategy (ITraversalStrategy) is not set

I am using EMF Validation to add some constraint checking and found out that in the code generated by EMFText SDK there is no traversal stragety set on the EMF validator object. As a consequence of this, my validator doesn't get called for the model element I would like to validate. I added the following line of code in BasicEclipseProxy.java:
validator.setTraversalStrategy(new ITraversalStrategy.Recursive());
With this the validation worked fine.

I would want to keep BasicEclipseProxy.java getting generated by the SDK in the future. Would it be possible to let the SDK generate another class that allows for setting the traversal strategy yourself?

How to determine Resource of current model in a TokenResolver?

I have a metamodel where one of its EClasses has an attribute of type 'EJavaClass'. This type comes from Ecore itself and is mapped to java.lang.Class. Thus, I have defined a token like this:

DEFINE CLASSNAME IDENTIFIER + $('.'$ + IDENTIFIER + $)*$;

And the rule for the EClass is:

PreProcessor ::= !0 "prepare with" class[CLASSNAME];

Therefore a CLASSNAMETokenResolver is generated in which I want to resolve the String to the according class in the classpath of the project in which the textual model is contained. Thus, I need to know at least the resource in which the model is contained for determining the project and to get the classloader for it. But, unfortunately, the resolve method of a token resolver only has this signature:

public void resolve(String lexem, EStructuralFeature feature, IGueryTokenResolveResult result)

But, if you search for all uses of resolve(..), one can see that the needed information is present. In the scope of the invocation of resolve(..) the actual model element is known and could be passed to the resolve(..) method.

Is there a chance that TokenResolvers could get such a method or do you see any other possibility?

best regards,
Jan

Immediately 'vanishing' popup might mislead users to assume failure

There is a UI glitch when saving an EMFText resource as XMI.

reproduce:

  • generate language tooling for language foo with EMFText
  • edit file.foo using said tooling
  • use "Save as" to save as .xmi (e.g. foo.xmi)

What happens:

  • foo language is serialized as xmi
  • foo editor tries to show the xmi, realizes that this makes no sense, opens a popup with head "No EMFText Resource" and text "The file 'foo.xmi' of type 'xmi' can not be handled by the foo Editor."

Generally that's what we expect so far, but the popup is actually only visible to the user for a fraction of second - after the popup is drawn, Eclipse main window immediately withdraws the editor pane opened for the .xmi file and by that the main window gets focus attention, causing the popup to get behind the main window and leaves the main window in blocked mode (popup is modal). A user that has missed the popup at all might assume the IDE to have frozen.

Desktop setup: two screens on Ubuntu Unity.

Selection direction Text --> Outline doesn't work correctly in cs editor

If you select text in the cs editor the selection in the outline most often is not correct or is not shown at all. The screenshot shows the selection of a whitespace modifier of the rule RoleReference. But the selection in the outline is a whitespace modifier of the rule RefactoringSpecification instead of the lower emphasized element.
cs_editor

Printer closes its stream and Printer2 does not

Both printers create a PrintWriter in their print(EObject element) methods. While the Printer2 only flushes the writer, Printer even closes it. This results in some strange behaviour in one of my test cases where some EObject's should be printed to console. Thus, I tried out the following:

  1. RolemappingPrinter2 printer = new RolemappingPrinter2(System.out, null);
  2. RolemappingPrinter printer = new RolemappingPrinter(System.out, null);

In the first case (where the writer isn't closed) each call to print(EObject element) causes the expected result. In the second case (whre the writer is closed), only the first call print(EObject element) works. After that nothing is printed to the console anymore. Nor, normal calls to System.out.println("something").

So what I'm asking is, is this an EMFText/Printer problem or is this my fault because of passing System.out as printer which is not intended?

Parsing of similar keywords including white spaces can cause errors

I created a DSL including two kinds of statements to express test code waiting for some events. One rule starts with the keyword "WAIT" followed by an attribute for an amount of time (an integer), the other rules starts with the keyword "WAIT FOR" followed by an identifier for a certain event (a String).

The grammer of this rules parses successfully. However, once I try to use the rule starting with "WAIT", the parser fails and tells me it is expecting an "F" instead of an integer.

Here's the thing: If I change my rule from using the keyword "WAIT FOR" to "WAIT" #1 "FOR" everything works fine. However, I can now not use code completion to enter "WAIT FOR" at once.

This makes me wander. Isn't this some kind of syntacial sugar that could be easily integrated. Letting the parser behave as in the second case but the code completion as handling "WAIT FOR" as one keyword? Morover, the syntax editor does not display an error for the "WAIT FOR" case, although the generated parser is not working.

Support trigger for code completion

In the JDT java editor the code completion is triggered automatically if one presses '.' (after a short timeout). I could imagine to support declaration of such triggers. E.g. an annotation directly next to a token could be possible. What do you think?

Releasing EMFText

We use EMFText in several locations within our transformation chain. A automated build environment to build our product is currently being implemented. Would it be possible to create formal releases of EMFText once in a while? This will help us to significantly to keep our toolsmith environments and build environments in sync with each other. This is more cumbersome when 'only' nightly builds of EMFText are available.

Thanks!

Code completion proposals for non-containment reference: the target element is not part of the proposal object

In the proposal post processor it would be helpful to have a reference to the target object for non-containment references. In CodeCompletionHelper.java inside handleNCReference() the target object is available like this:
"Object target = elementMapping.getTargetElement();"
Here the reference to that target object could easily be added to the CompletionProposal object.

In the ProposalPostProcessor.java my intention is to get access to the model element tree for the resource where the target object is part of. With this information I would like to set the proposal's display string.

Fix progress monitor handling in TaskItemBuilder

Currently the generated TaskItemBuilder sets the task name on the progress monitor which causes the progress view to show "Searching for task items" while all builders for one DSL are running. This is misleading as the other builder should have individual task names.

Memory leak caused by ItemProviderAdapters when reloading resources

If resources are reloaded (e.g., while modifying them in an editor), references to outdated model elements are stored in the ItemProviderAdapters generated by the EMF Edit framework. The unused/out-dated elements pile up and cause a memory leak which slows down Eclipse after editing for a while.

The adapters use the singleton pattern and EObjects must therefore be explicitly removed when they are unloaded from a resource.

New Functionality (?): Search References

Maybe I am missing something here: I don't find a functionality generated by EMFText SDK similar to "Search References" in JDT. Is there already something in place? If not, are there any plans to do so?

Browser-Control for Hover Text: HTTP Links with target='_blank' or target='_new' are not doing anything when clicked

I have manually modified the XYZDefaultHoverTextProvider.java. Amongst other, the hover text now contains HTTP links with target='_blank' (or '_new'). When the hover overlay windows pops up, gets focus and I click on the link, nothing happens.

When I do the same thing with a hover window for Java source code (JavaDoc), a HTTP link works fine. Am I missing something that needs to be configured in order to get that behaviour working?

"Save as" always active

Using an EMFText editor, I can save my model as file.foo or file.xmi. For the latter task, I need to go to "Save as" and select a file name ending in .xmi. Everything fine so far. But "Save as" is only active after something has been changed in the file, otherwise it is inactive (and thus grayed out), even though I may have a reason to use "Save as" under circumstances where nothing has changed at all (said 'export' to xmi).

Minor feature request: Make "Save as" always active

(Even though not directy comparable, I guess implementing this takes less time than the workaround is dirty (deleting and reprinting exactly the same letter to make the document 'altered')).

Problem with Printing Markup - too many Linebreaks

I am now using printing markup in my grammar. When I use the markup to write/format a DSL-File, I am ending up with too many linebreaks (see attached screenshot). The markup that I add in one rule affects the printed layout in other rules.

Printing Markup - Problem with too many Newlines

MetaInformation.registerResourceFactory() is broken

the generated method overwrites the resource factories that are registered for the languages file extension with the default ResourceFactory. This is especially wrong when a ResourceFactoryDelegator is used (e.g. in case of JaMoPP).

Fix:

  • only overwrite factory when none is registred
  • register ResourceFactoryDelegator instead of ResourceFactory

Dynamic Token Styling - XYZDynamicTokenStyler.java - token.getOffset() often returns 0

Hi,

I modified the XYZDynamicTokenStyler.java in order to change a token style dependent on a model element's type and some other of its attributes. While doing this I realized that the token.getOffset() often returns 0. Because of this, resource.getLocationMap().getElementsAt(token.getOffset()) does not return the correct element. Further investigating this, I found that in XYZTokenScanner.java the required information is found in the 'offset" field. I manually changed XYZTokenScanner.java and XYZDynamicTokenStyler.java to pass that 'offset' as a parameter to getDynamicTokenStyle(). With this I was able to implement my logic as desired.

Would it be possible to enhance EMFText SDK to provide a similar solution?

Cheers,
Marcus

Invalid Code Generation for AbstractXyzInterpreter when EClass "ResultType" in Metamodel

The generated code for the AbstractXyzInterpreter contains compile errors when a metamodel class is called ResultType. The issue arises due to the following situation:

  • The first generic type parameter of the generated class also has the name "ResultType" and thus hides the type of the metamodel.
  • The interprete_..._ResultType method takes as first parameter an object of type ResultType (the type from the metamodel) but does not fully qualify its name.

At the current stage of development, the problem should also arise for metamodel elements called "ContextType", which is the name of the second generic type parameter. A fix would thus fully qualify the type of the parameter interprete_..._[MetamodelElement].

This issue does not appear with the official release 1.4.1 but with the current one from update_trunk.

LocationMap should be created by the parser instead of the resource

Since the parser is responsible for filling the location map (at least with initial values), the map should be created by the parser and returned as part of the parse result. This is more natural and reduces the dependency between parsers and the resource implementation.

We've detected this option for improvement while replacing the parser with an alternative implementation.

Changing the Size of Content Assist Window

I need a content assit window with a greater width as the default one.

When using a Java Editor, I (as a user) can increase the width of the window and when it opens up for the next time, the width is still the one I set it to in the first place. However, when I use my EMFText based editor, the width is always the same. Does EMFText (or the code that gets generated by it) provide a way to change that window size?

Automated Insertion of closing Curly Bracket and Indentation when inserting Line Break after opening Bracket

Meanwhile the editor that gets generated by EMFText SDK has the functionality to automatically adding a closing bracket and indenting the cursor when a line break is being inserted after an opening bracket.

That's fine. However, the indentation of the cursor and the inserted closing bracket is always relative to the line start. Any leading whitespaces of the previous line are ignored. Would it be possible to extend that functinality to additionally add any leading whitespaces of the line that contains the opening bracket to the cursor position and to the closing bracket? Here is an example of how it is working at the moment, when inserting a line break after "field f1 : String {"

entity MyEntity {
    field f1 : String {
    <CURSOR-POS>    
}
}

After my proposed changes, the code would look like this:

entity MyEntity {
    field f1 : String {
        <CURSOR-POS>    
    }
}

Metatype Inheritance Hierarchy leads to missing Entries in Outline View

I have a metamodel with an inheritance tree of metatypes. The root element of my model, which has no inheritance, owns a collection of elements of an abstract parent type of the aforementioned inheritance tree. As a consequence of this, my outline view does not show the model elements that have the leaves of that inheritance tree as their type (c.f. attached screenshot).

I am using Juno, Service Release 2 and
EMFText Problems with Outline View and Metatype Hierarchy
EMFText SDK 1.4.2.v201304132106

Exception when deleting a newly created DSL File - cannot delete the File

Hi all,

Here is the problem that I have:

The file extension of my DSL files is ".gapp". When I create a new file and imediately try to delete it, I get an Eclipse exception and the file cannot be deleted. I tried the same with a different file extension, where there is no EMFText Editor registered for. There the deletion worked fine. I also tried it with a .java File. There it worked as well. So it does not seem to be an Eclipse problem. Here is the exception that I get:

!MESSAGE Could not delete 'D:\W\gis\generate-it-smart\runtime-EclipseApplication(1)\emftext-gapp-playground3\myfile.gapp'.
!STACK 1
org.eclipse.core.runtime.CoreException: Problems encountered while deleting files.
at org.eclipse.core.internal.filesystem.local.LocalFile.delete(LocalFile.java:131)
at org.eclipse.core.internal.resources.ResourceTree.internalDeleteFile(ResourceTree.java:304)
at org.eclipse.core.internal.resources.ResourceTree.standardDeleteFile(ResourceTree.java:785)
at org.eclipse.core.internal.resources.Resource.unprotectedDelete(Resource.java:1973)
at org.eclipse.core.internal.resources.Resource.delete(Resource.java:803)
at org.eclipse.ltk.core.refactoring.resource.DeleteResourceChange.perform(DeleteResourceChange.java:168)
at org.eclipse.ltk.core.refactoring.CompositeChange.perform(CompositeChange.java:278)
at org.eclipse.jdt.internal.corext.refactoring.changes.DynamicValidationStateChange.access$0(DynamicValidationStateChange.java:1)
at org.eclipse.jdt.internal.corext.refactoring.changes.DynamicValidationStateChange$1.run(DynamicValidationStateChange.java:102)
at org.eclipse.jdt.internal.core.BatchOperation.executeOperation(BatchOperation.java:39)
at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:728)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:5204)
at org.eclipse.jdt.internal.corext.refactoring.changes.DynamicValidationStateChange.perform(DynamicValidationStateChange.java:105)
at org.eclipse.ltk.core.refactoring.CompositeChange.perform(CompositeChange.java:278)
at org.eclipse.jdt.internal.corext.refactoring.changes.DynamicValidationStateChange.access$0(DynamicValidationStateChange.java:1)
at org.eclipse.jdt.internal.corext.refactoring.changes.DynamicValidationStateChange$1.run(DynamicValidationStateChange.java:102)
at org.eclipse.jdt.internal.core.BatchOperation.executeOperation(BatchOperation.java:39)
at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:728)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:5204)
at org.eclipse.jdt.internal.corext.refactoring.changes.DynamicValidationStateChange.perform(DynamicValidationStateChange.java:105)
at org.eclipse.ltk.core.refactoring.CompositeChange.perform(CompositeChange.java:278)
at org.eclipse.ltk.core.refactoring.PerformChangeOperation$1.run(PerformChangeOperation.java:258)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
at org.eclipse.ltk.core.refactoring.PerformChangeOperation.executeChange(PerformChangeOperation.java:306)
at org.eclipse.ltk.internal.ui.refactoring.UIPerformChangeOperation.executeChange(UIPerformChangeOperation.java:92)
at org.eclipse.ltk.core.refactoring.PerformChangeOperation.run(PerformChangeOperation.java:218)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
at org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:87)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Contains: Could not delete: D:\W\gis\generate-it-smart\runtime-EclipseApplication(1)\emftext-gapp-playground3\myfile.gapp.

XYZResource.getErrors() throws ArrayIndexOutOfBoundsException

When I edit my textual model and the model is incorrect, sometimes an error dialog pops up that indicates that an ArrayIndexOutOfBoundsException has occurred. The following related stack trace I have found in my .log File in the Eclipse workspace:

'''
java.lang.ArrayIndexOutOfBoundsException
at org.eclipse.emf.common.util.BasicEList.toArray(BasicEList.java:255)
at com.gs.gapp.language.gapp.resource.gapp.util.GappCopiedEList.(GappCopiedEList.java:19)
at com.gs.gapp.language.gapp.resource.gapp.mopp.GappResource.getErrors(GappResource.java:765)
at com.gs.gapp.language.gapp.resource.gapp.ui.GappCodeFoldingManager.calculatePositions(GappCodeFoldingManager.java:352)
at com.gs.gapp.language.gapp.resource.gapp.ui.GappCodeFoldingManager$FoldingUpdateListener.parsingCompleted(GappCodeFoldingManager.java:19)
at com.gs.gapp.language.gapp.resource.gapp.ui.GappEditor.notifyBackgroundParsingFinished(GappEditor.java:389)
at com.gs.gapp.language.gapp.resource.gapp.ui.GappBackgroundParsingStrategy$ParsingJob.run(GappBackgroundParsingStrategy.java:107)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
'''

All this occurs inside code that got generated by the EMFText SDK. The SDK version that was used for the generation of the editor- and parser-code is 1.4.2.v201307191141. I use the editor and parser inside Kepler.

Cheers,
Marcus

Provide EMFText to gracefully degrade and correct wrong rule choices

Hello,

EMFText uses specific tokens over general tokens. This leads to failures, where EMFText chooses a RULE that matches at the beginning, but does not match in any way beyond that.
Here is an example of the problem:

We have two TOKENs:

DEFINE ITERATOR_NAME $ 'select' | 'reject' | 'forAll' | 'collect' | 'any' | 'exists' | 'one' | 'isUnique' | 'collectNested' | 'sortedBy' | 'closure' $;
DEFINE SIMPLE_NAME $ ('A'..'Z'|'a'..'z'|'_') ('A'..'Z'|'a'..'z'|'0'..'9'|'_')*$;

ITERATOR_NAME is more specific than SIMPLE_NAME and is therefore preferred when applying rules. Lets consider the following of our DSL (that is OCL):

def: forAll = 0

Now, forAll is not understand as a SIMPLE_NAME, but as an ITERATOR_NAME. This causes the following RULE to bug, i.e. the rule is not applicable. But instead of looking for alternatives (e.g. SIMPLE_NAME is still applicable before EMFText could gracefully degrade), EMFText continues in a bad state.

SimpleNameCS ::= simpleName[SIMPLE_NAME];

The fix is therefor, to use

SimpleNameCS ::= simpleName[ITERATOR_NAME] | simpleName[SIMPLE_NAME];

as ITERATOR_NAME does not mean a keyword in OCL. The case gets more worse (as the first one was resolvable), when considering the second example:

def: iterate = 0

This triggers the following rule:

IterateExpCS ::= "iterate" #0 "(" (iteratorVariable #0 ";")? resultVariable "|" bodyExpression #0 ")";

As "iterate" is more specific than

SimpleNameCS ::= simpleName[ITERATOR_NAME] | simpleName[SIMPLE_NAME];

But again, the rule is not applicable beyond the fact, that it begins with "iterate" (i.e. there are no parantheses and so on). EMFText then remains in a bad state, without trying to apply other rules that are matching.

Return a list in computeCompletionProposals of the generated XYZCodeCompletionHelper

Currently, the method computeCompletionProposals(XYZTextResource originalResource, String content, int cursorOffset) returns an array of type XYZCompletionProposal. The disadvantage of the array is the upcoming use in the method computeCompletionProposals(ITextViewer viewer, int offset) in the generated class XYZCompletionProcessor. Within this method the passed array is converted to a list with the following statement: Arrays.asList(..). But Arrays.asList(..) returns an anonymous implementation of list which does not override add(int index, elementToInsert). Thus, an UnsupportedOperationException is thrown in case someone wants to add a completion proposal at the beginning of the passed proposals list in the process method of the XYZProposalPostProcessor. I see no advantage of using an array in between since before and at the end of the whole process lists are used.

Commenting Lines with CTRL+7 does not always work as expected

Hi,

I realized the following behavior:

When the cursor is in a line and you press CTRL+7, "//" comments are added at the begining of the line. That's fine. When you now set the cursor to the next line (or any other line and press CTRL+7 again, nothing happens. You have to press CTRL+7 twice to comment the other line, too. Also, when you have commented a few lines (by pressing CTRL+7 twice), and set the cursor to one of the lines that you just have commented and press CTRL+7 again, another "//" is getting added at the begining of that line (now we have "////") instead of simply removing the comment.

This is not a big problem during modeling in terms of productivity/effeciency. But it is suggestive of the editor not working properly when it comes to "simple features". And if a tool cannot handle simple functions properly, a user unconsciously is starting to create distrust, thinking that the tool might not be able to handle complex functions properly.

How, as a workaround, could I switch off that feature until it works properly?

Cheers,
Marcus

P.S.: I use Eclipse Kepler, Build id: 20130614-0229, EMFText SDK 1.4.2.v201310112249.

Edited text is selected after saving which might result in text loss

When text is edited in an EMFText generated editor the textual representation of the edited model element is selected when Strg+S is pressed. But, if modelers edit their models the same way they implement code then it might happen that one loses text. The reason is that most developers have the habit to press Strg+S after having made small changes and just continue programming. If you do it like this in an EMFText editor the selected text is replaced by the new input. Can you remove this "feature" please?

Deresolve uses TokenResolvers instead of ReferenceResolvers, when saving an model with eProxies to textual format

To save an excising model in xmi format in a concrete textual format, the xmi file can be open with the sample reflective model editor. Then it can be saved as a file in textual format by saving it using 'Save as ...' with the corresponding extension.

The xmi file may contain references to other files. If these eProxies are resolved before saving, the serialization is correct.
If the eProxies are not resolved before saving the model, TokenResolvers are used to deresolve the references instead of ReferenceResolvers.

If the model contains unresolved proxies, these proxies should be resolved before saving the model.

To reproduce:

  1. Load an xmi file with references to other files, with the sample reflective model editor.
  2. Save file directly without exploring or validating the model to a textual file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.