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. -- 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]
