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

ai.vespa.schemals.schemadocument.parser.IdentifyDirtyNodes Maven / Gradle / Ivy

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

import java.util.ArrayList;
import java.util.List;

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

import ai.vespa.schemals.common.SchemaDiagnostic;
import ai.vespa.schemals.context.ParseContext;
import ai.vespa.schemals.tree.Node;

/**
 * Mark all dirty nodes as Syntax error
 */
public class IdentifyDirtyNodes extends Identifier {

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

    public List identify(T node) {
        List ret = new ArrayList<>();

        if (
            node.getIsDirty() &&
            node.isLeaf()
        ) {
            ret.add(new SchemaDiagnostic.Builder()
                .setRange(node.getRange())
                .setMessage("Invalid syntax.")
                .setSeverity(DiagnosticSeverity.Error)
                .build());
        }

        return ret;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy