maedhroz commented on code in PR #2195:
URL: https://github.com/apache/cassandra/pull/2195#discussion_r1134685343


##########
src/java/org/apache/cassandra/cql3/StatementSource.java:
##########
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.cassandra.cql3;
+
+import java.util.Objects;
+import java.util.regex.Pattern;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import com.google.common.base.Preconditions;
+
+import org.antlr.runtime.Token;
+import org.apache.cassandra.cql3.statements.QualifiedStatement;
+
+import static java.lang.Math.max;
+import static java.lang.Math.min;
+
+public class StatementSource
+{
+    public static final StatementSource INTERNAL = 
Bounds.EMPTY.describeSource(null);
+
+    public final String text;
+    public final Bounds bounds;
+
+    public StatementSource(@Nullable String text, @Nonnull Bounds bounds)
+    {
+        Objects.requireNonNull(bounds);
+        this.text = text;
+        this.bounds = bounds;
+    }
+
+    public String describe(boolean mayIncludeSourceText)
+    {
+        if (this == INTERNAL)
+        {
+            return "<<<internal statement>>>";
+        }
+        else
+        {
+            if (!bounds.isEmpty() && text != null && mayIncludeSourceText)
+                return String.format("at %d:%d - %s", bounds.startLine + 1, 
bounds.startChar + 1, text);

Review Comment:
   nit: Another way to do it that could avoid the dash...
   
   `at [2:1] SELECT....`
   
   Matter of style though, so feel free to ignore.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to