[ 
https://issues.apache.org/jira/browse/TINKERPOP-3028?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17852736#comment-17852736
 ] 

ASF GitHub Bot commented on TINKERPOP-3028:
-------------------------------------------

spmallette commented on code in PR #2640:
URL: https://github.com/apache/tinkerpop/pull/2640#discussion_r1629336099


##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/translator/JavaTranslateVisitor.java:
##########
@@ -0,0 +1,271 @@
+/*
+ * 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.tinkerpop.gremlin.language.translator;
+
+import org.antlr.v4.runtime.tree.ParseTree;
+import org.antlr.v4.runtime.tree.TerminalNode;
+import org.apache.tinkerpop.gremlin.language.grammar.GremlinParser;
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategies;
+import org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy;
+import org.apache.tinkerpop.gremlin.util.DatetimeHelper;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+/**
+ * Converts a Gremlin traversal string into a Java source code representation 
of that traversal with an aim at
+ * sacrificing some formatting for the ability to compile correctly.
+ * <ul>
+ *     <li>Range syntax has no direct support</li>
+ *     <li>Normalizes whitespace</li>
+ *     <li>Normalize numeric suffixes to lower case</li>
+ *     <li>If floats are not suffixed they will translate as BigDecimal</li>
+ *     <li>Makes anonymous traversals explicit with double underscore</li>
+ *     <li>Makes enums explicit with their proper name</li>
+ * </ul>
+ */
+public class JavaTranslateVisitor extends AbstractTranslateVisitor {
+    public JavaTranslateVisitor() {
+        super("g");
+    }
+
+    public JavaTranslateVisitor(final String graphTraversalSourceName) {
+        super(graphTraversalSourceName);
+    }
+
+    @Override
+    public Void visitStructureVertex(final 
GremlinParser.StructureVertexContext ctx) {
+        sb.append("new DetachedVertex(");

Review Comment:
   I suppose `ReferenceVertex` is better. This is truly a "reference" I guess. 





> Convert translators to make use of the grammar
> ----------------------------------------------
>
>                 Key: TINKERPOP-3028
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-3028
>             Project: TinkerPop
>          Issue Type: Improvement
>          Components: translator
>    Affects Versions: 3.6.6
>            Reporter: Stephen Mallette
>            Assignee: Stephen Mallette
>            Priority: Major
>
> {{Translator}} infrastructure uses bytecode and reflection which has a number 
> of technical imperfections and exemptions for it to work properly. Switching 
> to the grammar for translation simplifies the code, removes friction and 
> complexity when generating GLV tests, and should perform better. The focus 
> for this issue is the Java series of translators which are relied on quite 
> heavily. 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to