René's URL Explorer Experiment


Title: Handle type annotations · Issue #5 · google/google-java-format · GitHub

Open Graph Title: Handle type annotations · Issue #5 · google/google-java-format

X Title: Handle type annotations · Issue #5 · google/google-java-format

Description: We always want to format type annotations in-line: @Nullable Object foo() {} This is tricky in contexts where type annotations could be mixed together with declaration annotations, such as field, method, and variable declarations. There'...

Open Graph Description: We always want to format type annotations in-line: @Nullable Object foo() {} This is tricky in contexts where type annotations could be mixed together with declaration annotations, such as field, m...

X Description: We always want to format type annotations in-line: @Nullable Object foo() {} This is tricky in contexts where type annotations could be mixed together with declaration annotations, such as field, m...

Opengraph URL: https://github.com/google/google-java-format/issues/5

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Handle type annotations","articleBody":"We always want to format type annotations in-line:\n\n```\n@Nullable Object foo() {}\n```\n\nThis is tricky in contexts where type annotations could be mixed together with declaration annotations, such as field, method, and variable declarations. There's no syntactic information to we can use to distinguish between `@NullableType Object foo() {}` and `@Deprecated Object foo() {}`, but we want to output the first annotation in-line, and the second vertically.\n\nCurrently, we output ambiguous annotations as declaration annotations. This is fine for Java 7, and has the advantage of never incorrectly formatting a declaration annotation as a type annotation.\n\nHere are some possible heuristics we could use to support this case for Java 8:\n\n1) If the annotation occurs before a regular modifier, it's probably a declaration annotation:\n\n```\n@Deprecated\nstatic Object foo() {}\n```\n\n2) If the annotation occurs after regular modifiers, and it isn't on a void-returning method, it's probably a type annotation:\n\n```\nstatic @Nullable Object foo() {}\n```\n\n3) If the declaration isn't a void-returning method, and it has no regular modifiers, consider the existing formatting: type annotations are probably on the same line as the type, declaration annotations are probably vertical. (The risk here is that we'd preserve things like `@Override Object foo() {}`.)\n\n4) If the declaration is named `@Override`, it's probably a declaration annotation. This would offset the disadvantage of (3), but it could be confusing if `@Override` behaves differently than other annotations.\n\n5) An annotation with parameters is unlikely to be a type annotation, and should probably be formatted vertically.\n","author":{"url":"https://github.com/cushon","@type":"Person","name":"cushon"},"datePublished":"2015-05-16T03:20:28Z","url":"https://github.com/google/google-java-format/issues/5"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:474e5925-ec25-b8e6-74a3-757298e802b8
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idAB92:76282:2902D2:37AE2A:6AFBB12D
html-safe-nonce1a6f7791c344feba525a341e0149382bcfd5209ce66df075ae86a17259841751
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQjkyOjc2MjgyOjI5MDJEMjozN0FFMkE6NkFGQkIxMkQiLCJ2aXNpdG9yX2lkIjoiNTE0OTMyMTE1MjkzMzExNDE1NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacc1f251ce5130e70fb2aeaec84583a015eb359bf4c8570d530976521a1550f5bd
hovercard-subject-tagissue:76931469
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/google/google-java-format/5/issue_layout
twitter:imagehttps://opengraph.githubassets.com/bc0113c2b1d6e01ff5d22c2de2ba95fdff53b0b1c380201d7566b1a4036ba2e8/google/google-java-format/issues/5
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/bc0113c2b1d6e01ff5d22c2de2ba95fdff53b0b1c380201d7566b1a4036ba2e8/google/google-java-format/issues/5
og:image:altWe always want to format type annotations in-line: @Nullable Object foo() {} This is tricky in contexts where type annotations could be mixed together with declaration annotations, such as field, m...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamecushon
hostnamegithub.com
expected-hostnamegithub.com
Nonee25fbd830d3e6ad0e8935c105cf4fdc70c593dffcd27bb45b790ae4fece5ea55
turbo-cache-controlno-preview
go-importgithub.com/google/google-java-format git https://github.com/google/google-java-format.git
octolytics-dimension-user_id1342004
octolytics-dimension-user_logingoogle
octolytics-dimension-repository_id35448780
octolytics-dimension-repository_nwogoogle/google-java-format
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id35448780
octolytics-dimension-repository_network_root_nwogoogle/google-java-format
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release08c8f17f9d27054a108b8b6254e405de0151f660
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/google/google-java-format/issues/5#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgoogle%2Fgoogle-java-format%2Fissues%2F5
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgoogle%2Fgoogle-java-format%2Fissues%2F5
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=google%2Fgoogle-java-format
Reloadhttps://github.com/google/google-java-format/issues/5
Reloadhttps://github.com/google/google-java-format/issues/5
Reloadhttps://github.com/google/google-java-format/issues/5
googlehttps://github.com/google
google-java-formathttps://github.com/google/google-java-format
Codehttps://github.com/google/google-java-format
Issues84 (84)https://github.com/google/google-java-format/issues
Pull requests35 (35)https://github.com/google/google-java-format/pulls
Actionshttps://github.com/google/google-java-format/actions
Projectshttps://github.com/google/google-java-format/projects
Wikihttps://github.com/google/google-java-format/wiki
Security and qualityhttps://github.com/google/google-java-format/security
Insightshttps://github.com/google/google-java-format/pulse
https://github.com/google/google-java-format
New issuehttps://github.com/login?return_to=https://github.com/google/google-java-format/issues/5
New issuehttps://github.com/login?return_to=https://github.com/google/google-java-format/issues/5
Handle type annotationshttps://github.com/google/google-java-format/issues/5#top
https://github.com/cushon
cushonhttps://github.com/cushon
on May 16, 2015https://github.com/google/google-java-format/issues/5#issue-76931469
https://github.com/cpovirk
cpovirkhttps://github.com/cpovirk
on May 20, 2015https://github.com/google/google-java-format/issues/5#issuecomment-103909069
https://github.com/kevinb9n
kevinb9nhttps://github.com/kevinb9n
on May 20, 2015https://github.com/google/google-java-format/issues/5#issuecomment-103921215
https://github.com/cgdecker
cgdeckerhttps://github.com/cgdecker
on May 20, 2015https://github.com/google/google-java-format/issues/5#issuecomment-103922640
https://github.com/mernst
mernsthttps://github.com/mernst
on Sep 13, 2016https://github.com/google/google-java-format/issues/5#issuecomment-246857800
Nullness Checkerhttp://types.cs.washington.edu/checker-framework/current/checker-framework-manual.html
@AssertNonNullIfNonNullhttp://types.cs.washington.edu/checker-framework/api/org/checkerframework/checker/nullness/qual/AssertNonNullIfNonNull.html
@Covarianthttp://types.cs.washington.edu/checker-framework/api/org/checkerframework/checker/nullness/qual/Covariant.html
@EnsuresNonNullhttp://types.cs.washington.edu/checker-framework/api/org/checkerframework/checker/nullness/qual/EnsuresNonNull.html
@EnsuresNonNullIfhttp://types.cs.washington.edu/checker-framework/api/org/checkerframework/checker/nullness/qual/EnsuresNonNullIf.html
@KeyForhttp://types.cs.washington.edu/checker-framework/api/org/checkerframework/checker/nullness/qual/KeyFor.html
@RequiresNonNullhttp://types.cs.washington.edu/checker-framework/api/org/checkerframework/checker/nullness/qual/RequiresNonNull.html
https://github.com/mernst
mernsthttps://github.com/mernst
on May 12, 2018https://github.com/google/google-java-format/issues/5#issuecomment-388575298
Daikonhttps://github.com/codespecs/daikon
https://github.com/plume-lib/run-google-java-formathttps://github.com/plume-lib/run-google-java-format
lst of annotations that should be treated as type annotationshttps://github.com/plume-lib/run-google-java-format/blob/master/fixup-google-java-format.py#L29
https://github.com/cushon
cushonhttps://github.com/cushon
on May 16, 2018https://github.com/google/google-java-format/issues/5#issuecomment-389693089
https://github.com/mernst
mernsthttps://github.com/mernst
on May 17, 2018https://github.com/google/google-java-format/issues/5#issuecomment-389707089
https://github.com/msridhar
msridharhttps://github.com/msridhar
on Dec 9, 2018https://github.com/google/google-java-format/issues/5#issuecomment-445559144
https://github.com/mernst
mernsthttps://github.com/mernst
on Oct 12, 2020https://github.com/google/google-java-format/issues/5#issuecomment-707301108
https://github.com/mernst
mernsthttps://github.com/mernst
on Oct 26, 2020https://github.com/google/google-java-format/issues/5#issuecomment-716647426
@cushonhttps://github.com/cushon
https://github.com/cushon
cushonhttps://github.com/cushon
on Nov 10, 2020https://github.com/google/google-java-format/issues/5#issuecomment-724956959
https://github.com/mernst
mernsthttps://github.com/mernst
on Nov 10, 2020https://github.com/google/google-java-format/issues/5#issuecomment-724965855
https://github.com/mernst
mernsthttps://github.com/mernst
on Apr 7, 2021https://github.com/google/google-java-format/issues/5#issuecomment-815152614
@cushonhttps://github.com/cushon
https://github.com/kevinb9n
kevinb9nhttps://github.com/kevinb9n
on Jun 17, 2021https://github.com/google/google-java-format/issues/5#issuecomment-862922928
#1https://github.com/google/google-java-format/issues/1
#5https://github.com/google/google-java-format/issues/5
https://github.com/cushon
cushonhttps://github.com/cushon
on Aug 24, 2021https://github.com/google/google-java-format/issues/5#issuecomment-904890426
copybara-servicehttps://github.com/apps/copybara-service
on Aug 24, 2021https://github.com/google/google-java-format/issues/5#event-5203393954
Format type annotation as part of the type, not part of the modifiers…https://github.com/google/google-java-format/commit/355e9d8a6080b9bcc61977b3dd7c00e7aaf0d8df
355e9d8https://github.com/google/google-java-format/commit/355e9d8a6080b9bcc61977b3dd7c00e7aaf0d8df
Format type annotation as part of the type, not part of the modifiers…https://github.com/google/google-java-format/commit/cbe3ad809d96f95988c6f3d15bb52706ce9ad02e
cbe3ad8https://github.com/google/google-java-format/commit/cbe3ad809d96f95988c6f3d15bb52706ce9ad02e
Format type annotation as part of the type, not part of the modifiers…https://github.com/google/google-java-format/commit/c268537bb2a19f05c748b1d029de2c9e73dbf121
c268537https://github.com/google/google-java-format/commit/c268537bb2a19f05c748b1d029de2c9e73dbf121
Format type annotation as part of the type, not part of the modifiers…https://github.com/google/google-java-format/commit/a4c75f64b5789850b85d43b308bea967b8d2853e
a4c75f6https://github.com/google/google-java-format/commit/a4c75f64b5789850b85d43b308bea967b8d2853e
Format type annotation as part of the type, not part of the modifiers…https://github.com/google/google-java-format/commit/1a875792f6a074f3f0a504ddb8c7cd932ba6b073
1a87579https://github.com/google/google-java-format/commit/1a875792f6a074f3f0a504ddb8c7cd932ba6b073
Format type annotation as part of the type, not part of the modifiers…https://github.com/google/google-java-format/commit/81306b9e3780e7c6737aa01287ed8b6879553144
81306b9https://github.com/google/google-java-format/commit/81306b9e3780e7c6737aa01287ed8b6879553144
Format type annotation as part of the type, not part of the modifiers…https://github.com/google/google-java-format/commit/865cff01c1bd5b7393f0dd88dbb92a499289e376
865cff0https://github.com/google/google-java-format/commit/865cff01c1bd5b7393f0dd88dbb92a499289e376
https://github.com/mernst
mernsthttps://github.com/mernst
on Jul 13, 2022https://github.com/google/google-java-format/issues/5#issuecomment-1183524424
@cushonhttps://github.com/cushon
1.12.0https://github.com/google/google-java-format/releases/tag/v1.12.0
two @Nullable annotationshttps://github.com/google/google-java-format/pull/653/files#diff-0c133fd389bc6f207e146ba08dbc50dd78aa088ff31cdc56cb14ebb31e97ec49R288-R289
your proposalhttps://github.com/google/google-java-format/issues/5#issuecomment-904890426
https://github.com/cushon
cushonhttps://github.com/cushon
on Jul 13, 2022https://github.com/google/google-java-format/issues/5#issuecomment-1183638329
https://github.com/ViliusS
ViliusShttps://github.com/ViliusS
on Dec 19, 2023https://github.com/google/google-java-format/issues/5#issuecomment-1863566661
@cushonhttps://github.com/cushon
https://google.github.io/styleguide/javaguide.htmlhttps://google.github.io/styleguide/javaguide.html
@mernsthttps://github.com/mernst
#802https://github.com/google/google-java-format/pull/802
Sign up for freehttps://github.com/signup?return_to=https://github.com/google/google-java-format/issues/5
Sign in to commenthttps://github.com/login?return_to=https://github.com/google/google-java-format/issues/5
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.