Skip to content

Commit

Permalink
fix: Simple bug fixes.
Browse files Browse the repository at this point in the history
* Fixes #145
   * Renamed `intergration` to `integration` globally
* Fixes #217
   * Added skippedDocComment before `syntax`, `import`, `package`, `option`,
     and `reserved` keywords in grammar
      * The root cause is the change to docComment to make it non-skipped, so
        we have to add it everywhere. Skipped comments (the `//` type) can be
        absolutely anywhere because the grammar _skips_ them.
   * Note, this _might_ also fix #319

Signed-off-by: Joseph Sinclair <121976561+jsync-swirlds@users.noreply.github.com>
  • Loading branch information
jsync-swirlds committed Jan 9, 2025
1 parent 3d3b2ff commit 45f9884
Show file tree
Hide file tree
Showing 25 changed files with 50 additions and 133 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
/*
* Copyright (C) 2022-2023 Hedera Hashgraph, LLC
*
* 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.
*/

// SPDX-License-Identifier: Apache-2.0
plugins { id("com.diffplug.spotless") }

spotless {
Expand Down Expand Up @@ -51,22 +36,8 @@ spotless {

licenseHeader(
"""
##
# Copyright (C) ${'$'}YEAR Hedera Hashgraph, LLC
#
# 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.
##
"""
# SPDX-License-Identifier: Apache-2.0
"""
.trimIndent(),
"(name|on)"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
/*
* Copyright (C) 2022-2023 Hedera Hashgraph, LLC
*
* 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.
*/

// SPDX-License-Identifier: Apache-2.0
plugins { id("com.diffplug.spotless") }

spotless {
Expand All @@ -31,22 +16,8 @@ spotless {
// of our test classes which are in the default package.
licenseHeader(
"""
/*
* Copyright (C) ${'$'}YEAR Hedera Hashgraph, LLC
*
* 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.
*/${"\n\n"}
"""
// SPDX-License-Identifier: Apache-2.0
"""
.trimIndent(),
"(package|import)"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
/*
* Copyright (C) 2022-2023 Hedera Hashgraph, LLC
*
* 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.
*/

// SPDX-License-Identifier: Apache-2.0
plugins { id("com.diffplug.spotless") }

spotless {
Expand All @@ -22,21 +7,7 @@ spotless {

licenseHeader(
"""
/*
* Copyright (C) ${'$'}YEAR Hedera Hashgraph, LLC
*
* 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.
*/${"\n\n"}
// SPDX-License-Identifier: Apache-2.0
"""
.trimIndent(),
"(import|plugins|repositories)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
* Original source is published under Apache License 2.0.
*
* Changes from the source above:
* - rewrite to antlr
* - rewrite to antlr.
* - extract some group to rule.
*
* @author anatawa12
* - Allow document comments in a few added places.
*/

grammar Protobuf3;
Expand All @@ -29,30 +28,32 @@ proto

docComment: DOC_COMMENT*;

skippedDocComment: (WS | SKIPPED_DOC_COMMENT | LINE_COMMENT | COMMENT)*;

optionComment: OPTION_LINE_COMMENT;

// Syntax

syntax
: SYNTAX EQ (PROTO3_LIT_SINGLE | PROTO3_LIT_DOBULE) SEMI
: skippedDocComment SYNTAX EQ (PROTO3_LIT_SINGLE | PROTO3_LIT_DOBULE) SEMI
;

// Import Statement

importStatement
: IMPORT ( WEAK | PUBLIC )? strLit SEMI
: skippedDocComment IMPORT ( WEAK | PUBLIC )? strLit SEMI
;

// Package

packageStatement
: PACKAGE fullIdent SEMI
: skippedDocComment PACKAGE fullIdent SEMI
;

// Option

optionStatement
: OPTION optionName EQ constant SEMI
: skippedDocComment OPTION optionName EQ constant SEMI
;

optionName
Expand Down Expand Up @@ -80,6 +81,8 @@ fieldNumber

// Oneof and oneof field

// Note, oneOf isn't a message or field, so docComment is broken here, but the current
// PBJ compiler requires docComment.
oneof
: docComment ONEOF oneofName LC ( optionStatement | oneofField | emptyStatement_ )* RC
;
Expand Down Expand Up @@ -134,7 +137,7 @@ type_
// Reserved

reserved
: RESERVED ( ranges | reservedFieldNames ) SEMI
: skippedDocComment RESERVED ( ranges | reservedFieldNames ) SEMI
;

ranges
Expand Down Expand Up @@ -348,6 +351,7 @@ WS : [ \t\r\n\u000C]+ -> skip;
OPTION_LINE_COMMENT: '//' WS? '<<<' .*? '>>>' ~[\r\n]*;
LINE_COMMENT: '//' ~[\r\n]* -> skip;
DOC_COMMENT: '/**' .*? '*/';
SKIPPED_DOC_COMMENT: '/**' .*? '*/' -> skip;
COMMENT: '/*' .*? '*/' -> skip;

keywords
Expand Down
2 changes: 1 addition & 1 deletion pbj-integration-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ testing {

useJUnitPlatform { includeTags("FUZZ_TEST") }
enableAssertions = false
systemProperties["com.hedera.pbj.intergration.test.fuzz.useRandomSeed"] = true
systemProperties["com.hedera.pbj.integration.test.fuzz.useRandomSeed"] = true
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.hedera.pbj.intergration.jmh;
package com.hedera.pbj.integration.jmh;

import com.hedera.pbj.runtime.io.buffer.Bytes;
import com.hedera.pbj.test.proto.pbj.Hasheval;
Expand Down Expand Up @@ -152,4 +152,4 @@ public void benchJavaRecordNotEquals(Blackhole blackhole) {
blackhole.consume(hashevalJavaRecord.equals(hashevalJavaRecordDifferent));
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.hedera.pbj.intergration.jmh;
package com.hedera.pbj.integration.jmh;

import com.hedera.pbj.test.proto.pbj.TimestampTest;
import org.openjdk.jmh.annotations.Benchmark;
Expand Down Expand Up @@ -102,4 +102,4 @@ public void benchJavaRecordNotEquals(Blackhole blackhole) {
blackhole.consume(timestampStandardRecord.equals(timestampStandardRecordDifferent));
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.hedera.pbj.intergration.jmh;
package com.hedera.pbj.integration.jmh;

import com.hedera.pbj.intergration.test.TestHashFunctions;
import com.hedera.pbj.integration.test.TestHashFunctions;
import com.hedera.pbj.runtime.io.buffer.Bytes;
import com.hedera.pbj.test.proto.pbj.Hasheval;
import com.hedera.pbj.test.proto.pbj.Suit;
Expand Down Expand Up @@ -53,4 +53,4 @@ public void hashBenchFieldWise(Blackhole blackhole) throws IOException {
TestHashFunctions.hash2(hasheval);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.hedera.pbj.intergration.jmh;
package com.hedera.pbj.integration.jmh;

import com.google.protobuf.GeneratedMessage;
import com.google.protobuf.GeneratedMessageV3;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.hedera.pbj.intergration.jmh;
package com.hedera.pbj.integration.jmh;

import com.google.protobuf.CodedOutputStream;
import com.google.protobuf.GeneratedMessage;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.hedera.pbj.intergration.jmh;
package com.hedera.pbj.integration.jmh;

import com.google.protobuf.CodedInputStream;
import com.google.protobuf.CodedOutputStream;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.hedera.pbj.intergration.test;
package com.hedera.pbj.integration.test;

import static com.hedera.pbj.compiler.PbjCompilerTask.compileFilesIn;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.hedera.pbj.intergration.test;
package com.hedera.pbj.integration.test;

import static java.util.Collections.shuffle;
import static java.util.Collections.sort;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.hedera.pbj.intergration.test;
package com.hedera.pbj.integration.test;

import com.google.protobuf.CodedOutputStream;
import com.hedera.pbj.runtime.io.buffer.BufferedData;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.hedera.pbj.intergration.test;
package com.hedera.pbj.integration.test;

import com.hedera.hapi.node.base.FeeSchedule;
import com.hedera.hapi.node.base.TransactionFeeSchedule;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.hedera.pbj.intergration.test;
package com.hedera.pbj.integration.test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
Expand Down Expand Up @@ -89,4 +89,4 @@ void differentObjectsWithNoDefaulHashCode4() {

assertNotEquals(tst.hashCode(), tst2.hashCode());
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.hedera.pbj.intergration.test;
package com.hedera.pbj.integration.test;

import com.google.protobuf.ByteString;
import com.google.protobuf.util.JsonFormat;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.hedera.pbj.intergration.test;
package com.hedera.pbj.integration.test;

import static org.junit.jupiter.api.Assertions.assertThrows;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.hedera.pbj.intergration.test;
package com.hedera.pbj.integration.test;

import com.hedera.pbj.runtime.ParseException;
import com.hedera.pbj.runtime.io.buffer.BufferedData;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.hedera.pbj.intergration.test;
package com.hedera.pbj.integration.test;

import com.hedera.pbj.runtime.ParseException;
import com.hedera.pbj.runtime.io.buffer.BufferedData;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.hedera.pbj.intergration.test;
package com.hedera.pbj.integration.test;

import com.hedera.pbj.runtime.Codec;
import com.hedera.pbj.runtime.io.WritableSequentialData;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.hedera.pbj.intergration.test;
package com.hedera.pbj.integration.test;

import com.hedera.hapi.node.base.tests.AccountIDTest;
import com.hedera.hapi.node.base.tests.ContractIDTest;
Expand Down Expand Up @@ -199,7 +199,7 @@ void fuzzTest() {

private Random buildRandom() {
final boolean useRandomSeed
= Boolean.valueOf(System.getProperty("com.hedera.pbj.intergration.test.fuzz.useRandomSeed"));
= Boolean.valueOf(System.getProperty("com.hedera.pbj.integration.test.fuzz.useRandomSeed"));
final long seed = useRandomSeed ? new Random().nextLong() : FIXED_RANDOM_SEED;

System.out.println("Fuzz tests are configured to use a "
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.hedera.pbj.intergration.test;
package com.hedera.pbj.integration.test;

import com.hedera.pbj.test.proto.pbj.Hasheval;
import com.hedera.pbj.test.proto.pbj.TimestampTest;
Expand Down Expand Up @@ -99,4 +99,4 @@ private static int processForBetterDistribution(int val) {
val += val << 30;
return val;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.hedera.pbj.intergration.test;
package com.hedera.pbj.integration.test;

import com.google.protobuf.CodedOutputStream;
import com.hedera.pbj.runtime.io.buffer.BufferedData;
Expand Down Expand Up @@ -101,4 +101,4 @@ public static Stream<NoToStringWrapper<TimestampTest>> createModelTestArguments(
return ARGUMENTS.stream().map(NoToStringWrapper::new);
}

}
}
Loading

0 comments on commit 45f9884

Please sign in to comment.