All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ai.vespa.schemals.schemadocument.parser.schema.IdentifyStructInheritance Maven / Gradle / Ivy

There is a newer version: 8.441.21
Show newest version
package ai.vespa.schemals.schemadocument.parser.schema;

import java.util.ArrayList;

import org.eclipse.lsp4j.Diagnostic;
import org.eclipse.lsp4j.DiagnosticSeverity;

import ai.vespa.schemals.parser.ast.identifierStr;
import ai.vespa.schemals.parser.ast.inheritsStruct;
import ai.vespa.schemals.schemadocument.parser.Identifier;
import ai.vespa.schemals.common.SchemaDiagnostic;
import ai.vespa.schemals.context.ParseContext;
import ai.vespa.schemals.tree.SchemaNode;

/**
 * IdentifyStructInheritance identifies if a struct inherits from another struct and adds it to a list to resolve later
 */
public class IdentifyStructInheritance extends Identifier {

	public IdentifyStructInheritance(ParseContext context) {
		super(context);
	}

	@Override
	public ArrayList identify(SchemaNode node) {
        ArrayList ret = new ArrayList<>();

        if (!node.isSchemaASTInstance(identifierStr.class)) return ret;
        if (node.getParent() == null || !node.getParent().getSchemaNode().isSchemaASTInstance(inheritsStruct.class)) return ret;

        if (!node.hasSymbol()) {
            ret.add(new SchemaDiagnostic.Builder()
                .setRange(node.getRange())
                .setMessage("Should be reference")
                .setSeverity(DiagnosticSeverity.Warning)
                .build());
        }

        context.addUnresolvedInheritanceNode(node);

        return ret;
	}

    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy