Skip to content

Commit a541b13

Browse files
committed
Merge branch 'DBTOOLS-1940_update_for_eclipse_plugin' into 'master'
DBTOOLS-1940 updateed for eclipse plugin See merge request codekeeper/pgcodekeeper-core!221
2 parents 997044c + 0748b4a commit a541b13

15 files changed

Lines changed: 69 additions & 113 deletions

File tree

src/main/java/org/pgcodekeeper/core/api/ApiRegistry.java

Lines changed: 0 additions & 84 deletions
This file was deleted.

src/main/java/org/pgcodekeeper/core/database/base/formatter/FormatItem.java renamed to src/main/java/org/pgcodekeeper/core/database/api/formatter/FormatItem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*******************************************************************************/
16-
package org.pgcodekeeper.core.database.base.formatter;
16+
package org.pgcodekeeper.core.database.api.formatter;
1717

1818
/**
1919
* Represents a single formatting operation to be applied to SQL text.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*******************************************************************************
2+
* Copyright 2017-2026 TAXTELECOM, LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*******************************************************************************/
16+
package org.pgcodekeeper.core.database.api.formatter;
17+
18+
import java.util.List;
19+
20+
/**
21+
* Interface for SQL formatter implementations.
22+
* Provides common functionality and structure for database-specific formatters.
23+
*/
24+
public interface IFormatter {
25+
26+
/**
27+
* Gets the list of formatting changes to apply to the SQL text.
28+
* Parses the SQL and applies formatting rules based on the configuration.
29+
*
30+
* @return List of FormatItem objects representing formatting changes
31+
*/
32+
List<FormatItem> getFormatItems();
33+
34+
/**
35+
* Formats the source text according to configuration and database type.
36+
*
37+
* @return Formatted SQL string
38+
*/
39+
String formatText();
40+
}

src/main/java/org/pgcodekeeper/core/database/api/schema/IColumn.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,6 @@ public interface IColumn extends ISubElement {
2424
default DbObjType getStatementType() {
2525
return DbObjType.COLUMN;
2626
}
27+
String getType();
28+
boolean isNotNull();
2729
}

src/main/java/org/pgcodekeeper/core/database/api/schema/IStatement.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,4 +285,8 @@ default String quote(String name) {
285285
void setLocation(ObjectLocation loc);
286286

287287
boolean hasChildren();
288+
289+
void setComment(String comment);
290+
291+
String getAuthor();
288292
}

src/main/java/org/pgcodekeeper/core/database/base/formatter/AbstractFormatter.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@
1717

1818
import java.util.*;
1919

20+
import org.pgcodekeeper.core.database.api.formatter.FormatItem;
2021
import org.pgcodekeeper.core.database.api.formatter.IFormatConfiguration;
22+
import org.pgcodekeeper.core.database.api.formatter.IFormatter;
2123

2224
/**
2325
* Abstract base class for SQL formatter implementations.
2426
* Provides common functionality and structure for database-specific formatters.
2527
*/
26-
public abstract class AbstractFormatter {
28+
public abstract class AbstractFormatter implements IFormatter {
2729

2830
protected final String source;
2931
protected final int start;
@@ -37,13 +39,7 @@ protected AbstractFormatter(String source, int offset, int length, IFormatConfig
3739
this.config = config;
3840
}
3941

40-
protected abstract List<FormatItem> getFormatItems();
41-
42-
/**
43-
* Formats the source text according to configuration and database type.
44-
*
45-
* @return Formatted SQL string
46-
*/
42+
@Override
4743
public String formatText() {
4844
List<FormatItem> list = getFormatItems();
4945
if (list.isEmpty()) {

src/main/java/org/pgcodekeeper/core/database/base/schema/meta/MetaStatement.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,16 @@ public String getComment() {
9797
return comment;
9898
}
9999

100+
@Override
100101
public void setComment(String comment) {
101102
this.comment = comment;
102103
}
103104

105+
@Override
106+
public String getAuthor() {
107+
throw new UnsupportedOperationException();
108+
}
109+
104110
/**
105111
* Returns the length of the object in the source file.
106112
*

src/main/java/org/pgcodekeeper/core/database/ch/formatter/ChFormatter.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import org.antlr.v4.runtime.Lexer;
2323
import org.pgcodekeeper.core.database.api.formatter.IFormatConfiguration;
2424
import org.pgcodekeeper.core.database.base.formatter.*;
25-
import org.pgcodekeeper.core.database.base.formatter.FormatItem;
25+
import org.pgcodekeeper.core.database.api.formatter.FormatItem;
2626
import org.pgcodekeeper.core.database.base.parser.CodeUnitToken;
2727
import org.pgcodekeeper.core.database.ch.parser.generated.*;
2828
import org.pgcodekeeper.core.database.ch.parser.generated.CHParser.*;
@@ -45,13 +45,6 @@ public ChFormatter(String source, int offset, int length, IFormatConfiguration c
4545
super(source, offset, length, config);
4646
}
4747

48-
49-
/**
50-
* Gets the list of formatting changes to apply to the ClickHouse SQL text.
51-
* Parses the SQL and applies formatting rules to create view statements and their subqueries.
52-
*
53-
* @return List of FormatItem objects representing the formatting changes
54-
*/
5548
@Override
5649
public List<FormatItem> getFormatItems() {
5750
List<FormatItem> changes = new ArrayList<>();

src/main/java/org/pgcodekeeper/core/database/ms/formatter/MsFormatter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import org.pgcodekeeper.core.database.api.formatter.IFormatConfiguration;
2121
import org.pgcodekeeper.core.database.base.formatter.AbstractFormatter;
22-
import org.pgcodekeeper.core.database.base.formatter.FormatItem;
22+
import org.pgcodekeeper.core.database.api.formatter.FormatItem;
2323

2424
/**
2525
* Microsoft SQL Server specific SQL formatter implementation.

src/main/java/org/pgcodekeeper/core/database/ms/parser/MsParserUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ private static void checkToClean(long cleaningInterval, long parserLastStart) {
136136
* Clears the MS SQL parser cache.
137137
*/
138138
// new method for cleanCacheOfAllParsers()
139-
public void cleanCacheMsParser() {
139+
public static void cleanCacheMsParser() {
140140
if (msParserLastStart != 0) {
141141
cleanParserCache();
142142
}

0 commit comments

Comments
 (0)