You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2021/12/14 13:25:22 UTC
[camel] 01/07: CAMEL-17331: camel-core - Add line number metadata to model
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit ab9f776fae34fab764aaafe4e4e21b0a93af64de
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Dec 14 11:49:21 2021 +0100
CAMEL-17331: camel-core - Add line number metadata to model
---
.../camel/{NamedNode.java => LineNumberAware.java} | 33 +++++++---------------
.../src/main/java/org/apache/camel/NamedNode.java | 2 +-
.../camel/model/OptionalIdentifiedDefinition.java | 13 +++++++++
3 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/core/camel-api/src/main/java/org/apache/camel/NamedNode.java b/core/camel-api/src/main/java/org/apache/camel/LineNumberAware.java
similarity index 52%
copy from core/camel-api/src/main/java/org/apache/camel/NamedNode.java
copy to core/camel-api/src/main/java/org/apache/camel/LineNumberAware.java
index 0484e8a..fa9f299 100644
--- a/core/camel-api/src/main/java/org/apache/camel/NamedNode.java
+++ b/core/camel-api/src/main/java/org/apache/camel/LineNumberAware.java
@@ -17,36 +17,23 @@
package org.apache.camel;
/**
- * Represents a node in the {@link org.apache.camel.model routes} which is identified by an id.
+ * An entity that can point to a given line number from a source {@link org.apache.camel.spi.Resource} such as YAML and
+ * XML DSL parsers.
*/
-public interface NamedNode {
+public interface LineNumberAware {
/**
- * Gets the value of the id property.
- */
- String getId();
-
- /**
- * Returns a short name for this node which can be useful for ID generation or referring to related resources like
- * images
+ * The line number of this entity.
*
- * @return defaults to "node" but derived nodes should overload this to provide a unique name
- */
- String getShortName();
-
- /**
- * Returns a label to describe this node such as the expression if some kind of expression node
+ * @return -1 if line number is not possible to know
*/
- String getLabel();
+ int getLineNumber();
/**
- * Returns the description text or null if there is no description text associated with this node
- */
- String getDescriptionText();
-
- /**
- * Returns the parent
+ * Sets the line number of this entity. parsing the source file and provide the line number representing this node.
+ *
+ * @param lineNumber the line number
*/
- NamedNode getParent();
+ void setLineNumber(int lineNumber);
}
diff --git a/core/camel-api/src/main/java/org/apache/camel/NamedNode.java b/core/camel-api/src/main/java/org/apache/camel/NamedNode.java
index 0484e8a..9e40b6b 100644
--- a/core/camel-api/src/main/java/org/apache/camel/NamedNode.java
+++ b/core/camel-api/src/main/java/org/apache/camel/NamedNode.java
@@ -19,7 +19,7 @@ package org.apache.camel;
/**
* Represents a node in the {@link org.apache.camel.model routes} which is identified by an id.
*/
-public interface NamedNode {
+public interface NamedNode extends LineNumberAware {
/**
* Gets the value of the id property.
diff --git a/core/camel-core-model/src/main/java/org/apache/camel/model/OptionalIdentifiedDefinition.java b/core/camel-core-model/src/main/java/org/apache/camel/model/OptionalIdentifiedDefinition.java
index a680f06..ade87e3 100644
--- a/core/camel-core-model/src/main/java/org/apache/camel/model/OptionalIdentifiedDefinition.java
+++ b/core/camel-core-model/src/main/java/org/apache/camel/model/OptionalIdentifiedDefinition.java
@@ -20,6 +20,7 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import org.apache.camel.NamedNode;
@@ -38,6 +39,7 @@ public abstract class OptionalIdentifiedDefinition<T extends OptionalIdentifiedD
private String id;
private Boolean customId;
private DescriptionDefinition description;
+ private transient int lineNumber = -1;
@Override
public String getId() {
@@ -80,6 +82,17 @@ public abstract class OptionalIdentifiedDefinition<T extends OptionalIdentifiedD
return null;
}
+ @Override
+ public int getLineNumber() {
+ return lineNumber;
+ }
+
+ @Override
+ @XmlTransient
+ public void setLineNumber(int lineNumber) {
+ this.lineNumber = lineNumber;
+ }
+
// Fluent API
// -------------------------------------------------------------------------