2 * Copyright (c) 2024 PANTHEON.tech, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.model.api.meta;
10 import org.eclipse.jdt.annotation.NonNull;
11 import org.eclipse.jdt.annotation.NonNullByDefault;
12 import org.eclipse.jdt.annotation.Nullable;
15 * A {@link StatementSourceReference} which acts as its own {@link DeclarationReference}, i.e. referring to a statement
16 * source present in textual source format.
19 public abstract class StatementDeclaration extends StatementSourceReference implements DeclarationReference {
21 * A {@link StatementDeclaration} which acts as its own {@link DeclarationInText}.
23 public abstract static class InText extends StatementDeclaration implements DeclarationInText {
25 protected final int line() {
30 protected final int column() {
35 protected @Nullable String file() {
41 * A {@link StatementDeclaration.InText} which acts as its own {@link DeclarationInFile}.
43 public abstract static class InTextFile extends InText implements DeclarationInFile {
45 protected final @NonNull String file() {
51 public final StatementOrigin statementOrigin() {
52 return StatementOrigin.DECLARATION;
56 public final @NonNull DeclarationReference declarationReference() {
61 public final String toHumanReadable() {
62 final var sb = new StringBuilder();
63 final var file = file();
64 sb.append(file != null ? file : "<UNKNOWN>");
65 final var line = line();
67 sb.append(':').append(line);
69 final var column = column();
71 sb.append(':').append(column);
77 public final String toString() {
78 return toHumanReadable();
81 protected abstract @Nullable String file();
83 protected abstract int line();
85 protected abstract int column();