Skip to content
This repository was archived by the owner on Jul 13, 2025. It is now read-only.

Case-insensitive Discovery message type names#1956

Merged
andreamlin merged 23 commits intogoogleapis:masterfrom
andreamlin:caseinsensitve4
May 4, 2018
Merged

Case-insensitive Discovery message type names#1956
andreamlin merged 23 commits intogoogleapis:masterfrom
andreamlin:caseinsensitve4

Conversation

@andreamlin
Copy link
Contributor

@andreamlin andreamlin commented Apr 30, 2018

Windows NTFS is case-insensitive, so this PR escapes DiscoveryField identifiers that are the same, disregarding character casing.

Introduce global table of DiscoveryFields to prevent duplicate creation of DiscoveryFields from the same Schema.
Constructor for DiscoveryFields enforces unique, case-insensitive identifiers for message-type Schemas.
Refactor SchemaTypeName* utils to use DiscoveryFields instead of Schemas. This allows the TypeName utils to use the DiscoveryField's unique identifiers.

@andreamlin andreamlin changed the title case insensitive filenames (WIP) Case-insensitive Discovery message type names Apr 30, 2018
@andreamlin
Copy link
Contributor Author

PTAL

@codecov-io
Copy link

codecov-io commented Apr 30, 2018

Codecov Report

Merging #1956 into master will decrease coverage by 0.07%.
The diff coverage is 74.28%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1956      +/-   ##
============================================
- Coverage     86.01%   85.94%   -0.08%     
- Complexity     4933     4949      +16     
============================================
  Files           452      452              
  Lines         19655    19719      +64     
  Branches       2055     2076      +21     
============================================
+ Hits          16906    16947      +41     
- Misses         2065     2076      +11     
- Partials        684      696      +12
Impacted Files Coverage Δ Complexity Δ
...va/com/google/api/codegen/util/CommonAcronyms.java 90.9% <ø> (ø) 17 <0> (ø) ⬇️
...i/codegen/transformer/SchemaTypeFormatterImpl.java 36.84% <0%> (ø) 5 <0> (ø) ⬇️
...i/codegen/transformer/SchemaTypeNameConverter.java 66.66% <0%> (ø) 5 <0> (ø) ⬇️
...degen/discogapic/transformer/DiscoGapicParser.java 91.52% <100%> (+0.45%) 22 <5> (+1) ⬆️
...oogle/api/codegen/config/DiscoveryMethodModel.java 82.1% <100%> (-0.37%) 40 <0> (ø)
.../java/com/google/api/codegen/util/SymbolTable.java 100% <100%> (ø) 10 <2> (+1) ⬆️
...er/java/JavaDiscoGapicSchemaToViewTransformer.java 95.91% <100%> (+0.04%) 16 <7> (-3) ⬇️
...r/java/JavaDiscoGapicRequestToViewTransformer.java 94.79% <100%> (+0.02%) 18 <0> (ø) ⬇️
...a/JavaDiscoGapicResourceNameToViewTransformer.java 100% <100%> (ø) 15 <0> (ø) ⬇️
...oogle/api/codegen/transformer/SchemaTypeTable.java 70% <25%> (-0.5%) 26 <1> (ø)
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a8f6389...cb9767e. Read the comment docs.

private final Schema originalSchema;
private final DiscoApiModel apiModel;

// Unformatted type name for this Field. For message-type Fields, this will be globally unique.

This comment was marked as spam.

This comment was marked as spam.

public abstract String httpMethod();

/** @return the ID. */
/** @return the ID. This is unique. */

This comment was marked as spam.

This comment was marked as spam.


@Override
public String getNicknameFor(Schema type) {
public String getNicknameFor(DiscoveryField type) {

This comment was marked as spam.

This comment was marked as spam.

@andreamlin
Copy link
Contributor Author

Made adjustments. PTAL

* content but different parents will still have different hashCodes.
*/
@Override
public int hashCode() {

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

.compareTo(o2.getValue().getDefaultPackageName());
}
};
private static Map<Map.Entry<Schema, DiscoApiModel>, DiscoveryField> globalObjects =

This comment was marked as spam.

This comment was marked as spam.

@garrettjonesgoogle garrettjonesgoogle requested a review from pongad May 2, 2018 15:45
@garrettjonesgoogle
Copy link
Member

  • @pongad in case I can't finish this review in a timely fashion - could you take a look too?

@andreamlin
Copy link
Contributor Author

FIXED things. PTAL

if (isTopLevelSchema(schema)) {
// Within this namespace, get a unique name for this message-type schema.
SchemaNamer messageNamer;
if (namespaceToSchemaNamer.containsKey(namespace)) {

This comment was marked as spam.

This comment was marked as spam.

Preconditions.checkNotNull(schema);
Preconditions.checkNotNull(rootApiModel);
return new DiscoveryField(schema, rootApiModel);
public static synchronized DiscoveryField create(Schema schema, DiscoApiModel rootApiModel) {

This comment was marked as spam.

This comment was marked as spam.

private Map<Schema, String> messageNames = new TreeMap<>(messageSchemaComparator);

String getSchemaName(Schema schema, String basename) {
if (messageNames.containsKey(schema)) {

This comment was marked as spam.

This comment was marked as spam.

return Objects.equals(
getApiModel().getDefaultPackageName(),
(otherModelData.getApiModel().getDefaultPackageName()))
&& getSchema().hashCode() == otherModelData.getSchema().hashCode();

This comment was marked as spam.

This comment was marked as spam.

* content but different parents will still have different hashCodes.
*/
@Override
public int hashCode() {

This comment was marked as spam.

* @param comparator function to determine equality on Strings
*/
public SymbolTable(Comparator<String> comparator) {
symbolTable = new ConcurrentSkipListSet<>(comparator);

This comment was marked as spam.

This comment was marked as spam.

@andreamlin
Copy link
Contributor Author

Made fixes. PTAL

* content but different parents will still have different hashCodes.
*/
@Override
public int hashCode() {

This comment was marked as spam.

@andreamlin andreamlin merged commit 4362afd into googleapis:master May 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants