mirror of
https://github.com/java-diff-utils/java-diff-utils.git
synced 2026-03-13 10:11:17 +08:00
first start unified diff
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright 2019 java-diff-utils.
|
||||
*
|
||||
* Licensed 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 com.github.difflib.unifieddiff;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tobias Warneke (t.warneke@gmx.net)
|
||||
*/
|
||||
public final class UnifiedDiff {
|
||||
|
||||
private UnifiedDiff(InputStream stream) throws IOException {
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream));) {
|
||||
while (reader.ready()) {
|
||||
String line = reader.readLine();
|
||||
LOG.info(line);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
private static final Logger LOG = Logger.getLogger(UnifiedDiff.class.getName());
|
||||
|
||||
public static UnifiedDiff parse(InputStream stream) throws IOException {
|
||||
return new UnifiedDiff(stream);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2019 java-diff-utils.
|
||||
*
|
||||
* Licensed 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 com.github.difflib.unifieddiff;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Tobias Warneke (t.warneke@gmx.net)
|
||||
*/
|
||||
public class UnifiedDiffTest {
|
||||
|
||||
public UnifiedDiffTest() {
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpClass() {
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownClass() {
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleParse() throws IOException {
|
||||
UnifiedDiff diff = UnifiedDiff.parse(UnifiedDiffTest.class.getResourceAsStream("jsqlparser_patch_1.diff"));
|
||||
|
||||
System.out.println(diff);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
From 3209a16c55c1976d5b772c607fd4b9d5fb9f9483 Mon Sep 17 00:00:00 2001
|
||||
From: wumpz <t.warneke@gmx.net>
|
||||
Date: Tue, 19 Feb 2019 01:35:14 +0100
|
||||
Subject: [PATCH] fixes #753
|
||||
|
||||
---
|
||||
src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt | 5 +++--
|
||||
.../net/sf/jsqlparser/statement/select/SelectTest.java | 7 +++++++
|
||||
2 files changed, 10 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt b/src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt
|
||||
index cd9bcd1..5f4b2b7 100644
|
||||
--- a/src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt
|
||||
+++ b/src/main/jjtree/net/sf/jsqlparser/parser/JSqlParserCC.jjt
|
||||
@@ -189,6 +189,7 @@ TOKEN: /* SQL Keywords. prefixed with K_ to avoid name clashes */
|
||||
| <K_JOIN:"JOIN">
|
||||
| <K_KEEP:"KEEP">
|
||||
| <K_KEY:"KEY">
|
||||
+| <K_FN:"FN">
|
||||
| <K_LAST: "LAST">
|
||||
| <K_LATERAL:"LATERAL">
|
||||
| <K_LEADING:"LEADING">
|
||||
@@ -1039,7 +1040,7 @@ String RelObjectNameWithoutValue() :
|
||||
| tk=<K_INSERT> | tk=<K_INDEX> | tk=<K_PRIMARY> | tk=<K_ENABLE>
|
||||
| tk=<K_UNSIGNED>
|
||||
| tk=<K_TEMP> | tk=<K_TEMPORARY> | tk=<K_TYPE> | tk=<K_ISNULL>
|
||||
- | tk=<K_ZONE> | tk=<K_COLUMNS> | tk=<K_DESCRIBE>
|
||||
+ | tk=<K_ZONE> | tk=<K_COLUMNS> | tk=<K_DESCRIBE> | tk=<K_FN>
|
||||
/* | tk=<K_PLACING> | tk=<K_BOTH> | tk=<K_LEADING> | tk=<K_TRAILING> */
|
||||
)
|
||||
|
||||
@@ -3118,7 +3119,7 @@ Function Function() #Function:
|
||||
Expression expr1 = null;
|
||||
}
|
||||
{
|
||||
- ["{fn" { retval.setEscaped(true); } ]
|
||||
+ ["{" <K_FN> { retval.setEscaped(true); } ]
|
||||
|
||||
funcName=RelObjectNameExt()
|
||||
|
||||
diff --git a/src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java b/src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java
|
||||
index 7ee9b38..d39bfd3 100644
|
||||
--- a/src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java
|
||||
+++ b/src/test/java/net/sf/jsqlparser/statement/select/SelectTest.java
|
||||
@@ -1063,6 +1063,13 @@ public class SelectTest {
|
||||
assertSqlCanBeParsedAndDeparsed("SELECT {fn concat(a, b)} AS COL");
|
||||
}
|
||||
|
||||
+ @Test
|
||||
+ public void testEscapedFunctionsIssue753() throws JSQLParserException {
|
||||
+ Statement stmt = CCJSqlParserUtil.parse("SELECT { fn test(0)} AS COL");
|
||||
+ assertEquals("SELECT {fn test(0)} AS COL", stmt.toString());
|
||||
+ assertSqlCanBeParsedAndDeparsed("SELECT fn FROM fn");
|
||||
+ }
|
||||
+
|
||||
@Test
|
||||
public void testNamedParametersPR702() throws JSQLParserException {
|
||||
assertSqlCanBeParsedAndDeparsed("SELECT substring(id, 2, 3), substring(id from 2 for 3), substring(id from 2), trim(BOTH ' ' from 'foo bar '), trim(LEADING ' ' from 'foo bar '), trim(TRAILING ' ' from 'foo bar '), trim(' ' from 'foo bar '), position('foo' in 'bar'), overlay('foo' placing 'bar' from 1), overlay('foo' placing 'bar' from 1 for 2) FROM my table");
|
||||
--
|
||||
2.17.1.windows.2
|
||||
|
||||
Reference in New Issue
Block a user