Search in sources :

Example 1 with CPrimitiveObject

use of com.nedap.archie.aom.CPrimitiveObject in project archetype-languageserver by nedap.

the class ArchetypeHoverInfo method getHoverInfoForCObject.

private void getHoverInfoForCObject(DocumentInformation documentInformation, CObject definition, Archetype archetypeForTerms) {
    ArchetypeTerm term = archetypeForTerms.getTerm(definition, language);
    String content;
    if (term != null) {
        content = "### " + definition.getRmTypeName() + ": " + term.getText() + "\n\n\t" + term.getDescription();
    } else {
        content = "### No term found";
    }
    CObject flattenedObject = (definition instanceof CPrimitiveObject) ? definition : archetypeForTerms.itemAtPath(definition.getPath());
    if (flattenedObject == null) {
        // fallback if something went wrong
        flattenedObject = definition;
    }
    MultiplicityInterval occurrences = flattenedObject.effectiveOccurrences(metaModels::referenceModelPropMultiplicity);
    content += "\n occurrences: " + occurrences;
    content += "\n\n path: " + definition.getPath();
    Hover hover = new Hover();
    hover.setContents(new MarkupContent(MARKDOWN, content.toString()));
    Range range = getHoverRange(documentInformation, definition);
    if (range != null) {
        hoverRanges.addRange(range, hover);
    }
}
Also used : TerminologyCodeWithArchetypeTerm(com.nedap.archie.aom.terminology.TerminologyCodeWithArchetypeTerm) ArchetypeTerm(com.nedap.archie.aom.terminology.ArchetypeTerm) CObject(com.nedap.archie.aom.CObject) Hover(org.eclipse.lsp4j.Hover) Range(org.eclipse.lsp4j.Range) CPrimitiveObject(com.nedap.archie.aom.CPrimitiveObject) MarkupContent(org.eclipse.lsp4j.MarkupContent) MultiplicityInterval(com.nedap.archie.base.MultiplicityInterval)

Aggregations

CObject (com.nedap.archie.aom.CObject)1 CPrimitiveObject (com.nedap.archie.aom.CPrimitiveObject)1 ArchetypeTerm (com.nedap.archie.aom.terminology.ArchetypeTerm)1 TerminologyCodeWithArchetypeTerm (com.nedap.archie.aom.terminology.TerminologyCodeWithArchetypeTerm)1 MultiplicityInterval (com.nedap.archie.base.MultiplicityInterval)1 Hover (org.eclipse.lsp4j.Hover)1 MarkupContent (org.eclipse.lsp4j.MarkupContent)1 Range (org.eclipse.lsp4j.Range)1