Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

CodeMining Problem #1947

Closed
miklossy opened this issue Nov 29, 2022 · 4 comments
Closed

CodeMining Problem #1947

miklossy opened this issue Nov 29, 2022 · 4 comments

Comments

@miklossy
Copy link
Contributor

I have experienced the following Code Mining problem.

Steps to reproduce (based on the Domainmodel example shipped with the Xtext framework):

  1. Replace the the DomainmodelCodeMiningProvider.java file with the following content:
public class DomainmodelCodeMiningProvider extends AbstractXtextCodeMiningProvider {

    @Override
    protected void createCodeMinings(IDocument document, XtextResource resource, CancelIndicator indicator,
            IAcceptor<? super ICodeMining> acceptor) throws BadLocationException {
        
        if (resource.getContents().isEmpty()) {
            return;
        }
        
        // get all entities in the open document
        List<Entity> allEntities = EcoreUtil2.eAllOfType(resource.getContents().get(0), Entity.class);
        for (Entity e : allEntities) {

            // create code mining right after the entity name
            List<INode> nodes = NodeModelUtils.findNodesForFeature(e, DomainmodelPackage.Literals.ABSTRACT_ELEMENT__NAME);
            if (nodes == null || nodes.isEmpty()) {
                continue;
            }

            INode lastNode = nodes.get(nodes.size() - 1);
            int annotationOffset = lastNode.getEndOffset() + 1;

            acceptor.accept(createNewLineContentCodeMining(annotationOffset, "CodeMiningText"));
        }
    }
}
  1. I would like to write the CodeMiningText right after the entity name. It works if the curly brace is in the same line as the entity name, but there is some problem if the curly brace is in the next line:
    screenshot
@cdietrich
Copy link
Member

cdietrich commented Nov 29, 2022

you should ask platform. i also dont get: what is working, what is not

@miklossy
Copy link
Contributor Author

@cdietrich
Copy link
Member

@cdietrich
Copy link
Member

see also eclipse/xtext#2380

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants