Search in sources :

Example 1 with IEObjectDocumentationProviderExtension

use of org.eclipse.xtext.documentation.IEObjectDocumentationProviderExtension in project xtext-xtend by eclipse.

the class XtendValidator method checkJavaDocRefs.

@Check
public void checkJavaDocRefs(XtendMember member) {
    if (isIgnored(IssueCodes.JAVA_DOC_LINKING_DIAGNOSTIC))
        return;
    List<INode> documentationNodes = ((IEObjectDocumentationProviderExtension) documentationProvider).getDocumentationNodes(member);
    for (INode node : documentationNodes) {
        for (ReplaceRegion region : javaDocTypeReferenceProvider.computeTypeRefRegions(node)) {
            String typeRefString = region.getText();
            if (typeRefString != null && typeRefString.length() > 0) {
                IScope scope = scopeProvider.getScope(member, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE);
                IEObjectDescription candidate = scope.getSingleElement(qualifiedNameConverter.toQualifiedName(typeRefString));
                if (candidate == null) {
                    Severity severity = getIssueSeverities(getContext(), getCurrentObject()).getSeverity(IssueCodes.JAVA_DOC_LINKING_DIAGNOSTIC);
                    if (severity != null)
                        getChain().add(createDiagnostic(severity, "javaDoc: " + typeRefString + " cannot be resolved to a type", member, region.getOffset(), region.getLength(), IssueCodes.JAVA_DOC_LINKING_DIAGNOSTIC));
                }
            }
        }
    }
}
Also used : INode(org.eclipse.xtext.nodemodel.INode) ReplaceRegion(org.eclipse.xtext.util.ReplaceRegion) IScope(org.eclipse.xtext.scoping.IScope) Severity(org.eclipse.xtext.diagnostics.Severity) RichString(org.eclipse.xtend.core.xtend.RichString) IEObjectDocumentationProviderExtension(org.eclipse.xtext.documentation.IEObjectDocumentationProviderExtension) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) Check(org.eclipse.xtext.validation.Check)

Aggregations

RichString (org.eclipse.xtend.core.xtend.RichString)1 Severity (org.eclipse.xtext.diagnostics.Severity)1 IEObjectDocumentationProviderExtension (org.eclipse.xtext.documentation.IEObjectDocumentationProviderExtension)1 INode (org.eclipse.xtext.nodemodel.INode)1 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)1 IScope (org.eclipse.xtext.scoping.IScope)1 ReplaceRegion (org.eclipse.xtext.util.ReplaceRegion)1 Check (org.eclipse.xtext.validation.Check)1