Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: replace the old parsing strategy and move towards a tree based one #733

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 0 additions & 83 deletions karapace/protobuf/dependency.py

This file was deleted.

39 changes: 17 additions & 22 deletions karapace/protobuf/known_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,26 +107,21 @@ def static_init(cls) -> None:
cls.index_simple[item] = key


@static_init
class DependenciesHardcoded:
index: Set = set()

@classmethod
def static_init(cls) -> None:
cls.index = {
"bool",
"bytes",
"double",
"float",
"fixed32",
"fixed64",
"int32",
"int64",
"sfixed32",
"sfixed64",
"sint32",
"sint64",
"string",
"uint32",
"uint64",
}
index: Set[str] = {
"bool",
"bytes",
"double",
"float",
"fixed32",
"fixed64",
"int32",
"int64",
"sfixed32",
"sfixed64",
"sint32",
"sint64",
"string",
"uint32",
"uint64",
}
21 changes: 14 additions & 7 deletions karapace/protobuf/proto_file_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
from karapace.dependency import Dependency
from karapace.protobuf.compare_result import CompareResult, Modification
from karapace.protobuf.compare_type_storage import CompareTypes
from karapace.protobuf.extend_element import ExtendElement
from karapace.protobuf.location import Location
from karapace.protobuf.option_element import OptionElement
from karapace.protobuf.service_element import ServiceElement
from karapace.protobuf.syntax import Syntax
from karapace.protobuf.type_element import TypeElement
from typing import Dict, List, Optional
from typing import Dict, List, NewType, Optional


def _collect_dependencies_types(compare_types: CompareTypes, dependencies: Optional[Dict[str, Dependency]], is_self: bool):
Expand All @@ -29,18 +32,22 @@ def _collect_dependencies_types(compare_types: CompareTypes, dependencies: Optio
_collect_dependencies_types(compare_types, sub_deps, is_self)


TypeName = NewType("TypeName", str)
PackageName = NewType("PackageName", str)


class ProtoFileElement:
def __init__(
self,
location: Location,
package_name: Optional[str] = None,
package_name: Optional[PackageName] = None,
syntax: Optional[Syntax] = None,
imports: Optional[list] = None,
public_imports: Optional[list] = None,
imports: Optional[List[TypeName]] = None,
public_imports: Optional[List[TypeName]] = None,
types: Optional[List[TypeElement]] = None,
services: Optional[list] = None,
extend_declarations: Optional[list] = None,
options: Optional[list] = None,
services: Optional[List[ServiceElement]] = None,
extend_declarations: Optional[List[ExtendElement]] = None,
options: Optional[List[OptionElement]] = None,
) -> None:
if types is None:
types = list()
Expand Down
Loading