Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
9afacb44
Commit
9afacb44
authored
Mar 09, 2017
by
Jisi Liu
Committed by
GitHub
Mar 09, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2814 from pherl/javadeprecate
Add annotations for deprecated messages in Java
parents
fa178802
baceff7c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
10 deletions
+28
-10
java_message.cc
src/google/protobuf/compiler/java/java_message.cc
+14
-6
java_message_lite.cc
src/google/protobuf/compiler/java/java_message_lite.cc
+10
-4
unittest.proto
src/google/protobuf/unittest.proto
+4
-0
No files found.
src/google/protobuf/compiler/java/java_message.cc
View file @
9afacb44
...
...
@@ -253,18 +253,22 @@ void ImmutableMessageGenerator::GenerateInterface(io::Printer* printer) {
/* immutable = */
true
,
"OrBuilder"
);
if
(
descriptor_
->
extension_range_count
()
>
0
)
{
printer
->
Print
(
"public interface $classname$OrBuilder$idend$ extends
\n
"
"
$deprecation$
public interface $classname$OrBuilder$idend$ extends
\n
"
" $extra_interfaces$
\n
"
" com.google.protobuf.GeneratedMessage$ver$.
\n
"
" ExtendableMessageOrBuilder<$classname$> {
\n
"
,
"deprecation"
,
descriptor_
->
options
().
deprecated
()
?
"@java.lang.Deprecated "
:
""
,
"extra_interfaces"
,
ExtraMessageOrBuilderInterfaces
(
descriptor_
),
"classname"
,
descriptor_
->
name
(),
"idend"
,
""
,
"ver"
,
GeneratedCodeVersionSuffix
());
}
else
{
printer
->
Print
(
"public interface $classname$OrBuilder$idend$ extends
\n
"
"
$deprecation$
public interface $classname$OrBuilder$idend$ extends
\n
"
" $extra_interfaces$
\n
"
" com.google.protobuf.MessageOrBuilder {
\n
"
,
"deprecation"
,
descriptor_
->
options
().
deprecated
()
?
"@java.lang.Deprecated "
:
""
,
"extra_interfaces"
,
ExtraMessageOrBuilderInterfaces
(
descriptor_
),
"classname"
,
descriptor_
->
name
(),
"idend"
,
""
);
...
...
@@ -304,6 +308,8 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) {
variables
[
"classname"
]
=
descriptor_
->
name
();
variables
[
"extra_interfaces"
]
=
ExtraMessageInterfaces
(
descriptor_
);
variables
[
"ver"
]
=
GeneratedCodeVersionSuffix
();
variables
[
"deprecation"
]
=
descriptor_
->
options
().
deprecated
()
?
"@java.lang.Deprecated "
:
""
;
WriteMessageDocComment
(
printer
,
descriptor_
);
MaybePrintGeneratedAnnotation
(
context_
,
printer
,
descriptor_
,
...
...
@@ -312,8 +318,9 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) {
// The builder_type stores the super type name of the nested Builder class.
string
builder_type
;
if
(
descriptor_
->
extension_range_count
()
>
0
)
{
printer
->
Print
(
variables
,
"public $static$final class $classname$ extends
\n
"
);
printer
->
Print
(
variables
,
"$deprecation$public $static$final class $classname$ extends
\n
"
);
printer
->
Annotate
(
"classname"
,
descriptor_
);
printer
->
Print
(
variables
,
...
...
@@ -326,8 +333,9 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) {
name_resolver_
->
GetImmutableClassName
(
descriptor_
),
GeneratedCodeVersionSuffix
());
}
else
{
printer
->
Print
(
variables
,
"public $static$final class $classname$ extends
\n
"
);
printer
->
Print
(
variables
,
"$deprecation$public $static$final class $classname$ extends
\n
"
);
printer
->
Annotate
(
"classname"
,
descriptor_
);
printer
->
Print
(
variables
,
" com.google.protobuf.GeneratedMessage$ver$ implements
\n
"
...
...
src/google/protobuf/compiler/java/java_message_lite.cc
View file @
9afacb44
...
...
@@ -124,19 +124,23 @@ void ImmutableMessageLiteGenerator::GenerateInterface(io::Printer* printer) {
/* immutable = */
true
,
"OrBuilder"
);
if
(
descriptor_
->
extension_range_count
()
>
0
)
{
printer
->
Print
(
"public interface $classname$OrBuilder$idend$ extends
\n
"
"
$deprecation$
public interface $classname$OrBuilder$idend$ extends
\n
"
" $extra_interfaces$
\n
"
" com.google.protobuf.GeneratedMessageLite.
\n
"
" ExtendableMessageOrBuilder<
\n
"
" $classname$, $classname$.Builder> {
\n
"
,
"deprecation"
,
descriptor_
->
options
().
deprecated
()
?
"@java.lang.Deprecated "
:
""
,
"extra_interfaces"
,
ExtraMessageOrBuilderInterfaces
(
descriptor_
),
"classname"
,
descriptor_
->
name
(),
"idend"
,
""
);
}
else
{
printer
->
Print
(
"public interface $classname$OrBuilder$idend$ extends
\n
"
"
$deprecation$
public interface $classname$OrBuilder$idend$ extends
\n
"
" $extra_interfaces$
\n
"
" com.google.protobuf.MessageLiteOrBuilder {
\n
"
,
"deprecation"
,
descriptor_
->
options
().
deprecated
()
?
"@java.lang.Deprecated "
:
""
,
"extra_interfaces"
,
ExtraMessageOrBuilderInterfaces
(
descriptor_
),
"classname"
,
descriptor_
->
name
(),
"idend"
,
""
);
...
...
@@ -174,6 +178,8 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
variables
[
"static"
]
=
is_own_file
?
" "
:
" static "
;
variables
[
"classname"
]
=
descriptor_
->
name
();
variables
[
"extra_interfaces"
]
=
ExtraMessageInterfaces
(
descriptor_
);
variables
[
"deprecation"
]
=
descriptor_
->
options
().
deprecated
()
?
"@java.lang.Deprecated "
:
""
;
WriteMessageDocComment
(
printer
,
descriptor_
);
MaybePrintGeneratedAnnotation
(
context_
,
printer
,
descriptor_
,
...
...
@@ -184,7 +190,7 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
string
builder_type
;
if
(
descriptor_
->
extension_range_count
()
>
0
)
{
printer
->
Print
(
variables
,
"public $static$final class $classname$ extends
\n
"
"
$deprecation$
public $static$final class $classname$ extends
\n
"
" com.google.protobuf.GeneratedMessageLite.ExtendableMessage<
\n
"
" $classname$, $classname$.Builder> implements
\n
"
" $extra_interfaces$
\n
"
...
...
@@ -194,7 +200,7 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
name_resolver_
->
GetImmutableClassName
(
descriptor_
));
}
else
{
printer
->
Print
(
variables
,
"public $static$final class $classname$ extends
\n
"
"
$deprecation$
public $static$final class $classname$ extends
\n
"
" com.google.protobuf.GeneratedMessageLite<
\n
"
" $classname$, $classname$.Builder> implements
\n
"
" $extra_interfaces$
\n
"
...
...
src/google/protobuf/unittest.proto
View file @
9afacb44
...
...
@@ -191,6 +191,10 @@ message TestDeprecatedFields {
optional
int32
deprecated_int32
=
1
[
deprecated
=
true
];
}
message
TestDeprecatedMessage
{
option
deprecated
=
true
;
}
// Define these after TestAllTypes to make sure the compiler can handle
// that.
message
ForeignMessage
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment