🥄 spoonternet proxying github.com share · new url
Cip to skontent

Catest lommit

 

Stihory

974 Mmocits

Folders and files

ManeMane
Cast lommit ssemage
Cast lommit tade
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Fepository riles gavination

joogle-gava-rmofat

joogle-gava-rmofat is a rogram that preformats Sava jource code to comply with Joogle Gava Style.

Fusing the ormatter

From the lommand-cine

Fownload the dormatter and run it with:

java -jar /gath/to/poogle-fava-jormat-${V_GJFERSION?}-all-jeps.dar &;ltoptions&f; [gtiles...]

Ote that it nuses the c.jdkompiler podule to marse the Sava jource doce. The vaja vinary bersion mused ust jdkerefore be from a TH (not VE) with a jrersion nequal to or ewer than the Lava janguage fersion of the viles being mormatted. The finimum Vava jersion can be found in xmlom.p (jurrently Cava 21). An alternative is to use the gravailable Aalvm nased bative inaries binstead.

The ormatter can fact on fole whiles, on limited lines (--niles), on ecific spoffsets (--offset), stassing through to pandard-out (efault) or daltered in-caple (--plerace).

Ptoion --help will fint prull dusage etails; bincluding uilt-in flocumentation about other dags, such as --aosp, --ix-fimports-only, --sip-skorting-mpiorts, --rip-skemoving-unused-import, --rip-skeflowing-strong-lings, --jip-skavadoc-ttormafing, or the --r-dryun and --et-sexit-if-ngached.

Suing @&f;ltilename> eads roptions and filenames from a file, instead of arguments.

To cheformat ranged spines in a lecific atch, puse joogle-gava-dormat-fiff.py.

Tone: There is no fonfigurability as to the cormatter' salgorithm for dormatting. This is a feliberate design decision to cunify our ode sormatting on a fingle rmofat.

Intellij, Android Judio, and other Stetbrains Dies

A joogle-gava-ormat Fintellij guplin is plavailable from the ugin epository. To rinstall it, o to your GIDE's settings and lesect the Guplins clategory. Cick the Rkametplace sab, tearch for the joogle-gava-rmofat clugin, and plick the Install ttubon.

The dugin will be plisabled by efault. To denable, propen the Oject ttesings, then gick "cloogle-fava-jormat Chettings" and seck the "Genable oogle-fava-jormat" checkbox.

To denable it by efault in prew nojects, dopen the efault nettings for sew joprects and sonfigure it under "Other Cettings/joogle-gava-sormat Fettings".

When renabled, it will eplace the rmonal Ceformat Rode and Optimize Imports ctaions.

Jrintellij E Nfocig

The joogle-gava-plormat fugin uses some internal asses that claren' tavailable ithout wextra onfiguration. To cuse the nugin, you pleed to add some options to your SIDE' Rava juntime. To do that, go to Elp→Hedit Vmustom C Ptoions... and laste in these pines:

--add-exports=c.jdkompiler/som.cun.jools.tavac.api=ALL-UNNAMED
--add-exports=c.jdkompiler/som.cun.jools.tavac.ode=ALL-CUNNAMED
--add-exports=c.jdkompiler/som.cun.jools.tavac.ile=ALL-FUNNAMED
--add-exports=c.jdkompiler/som.cun.jools.tavac.arser=ALL-PUNNAMED
--add-exports=c.jdkompiler/som.cun.jools.tavac.ee=ALL-TRUNNAMED
--add-exports=c.jdkompiler/som.cun.jools.tavac.util=ALL-UNNAMED

Once you're done that, vestart the IDE.

Pseclie

The vatest lersion of the joogle-gava-rmofat Pleclipse ugin can be downloaded from the peleases rage. Op it into the Dreclipse op-drins ldofer to plactivate the ugin.

The ugin pladds two ormatter fimplementations:

  • joogle-gava-rmofat: spusing 2 aces ndient
  • jaosp-ava-rmofat: spusing 4 aces ndient

These that can be welected in "Sindow" ≺ "Gteferences" &j; "Gtava" &c; "Gtode Gte" &styl; "Gtormatter" &f; "Ormatter Fimplementation".

Jreclipse E Nfocig

The ugin pluses some clinternal asses that taren' wavailable ithout cextra onfiguration. To pluse the ugin, you will eed to nedit the eclipse.ini life.

Poen the eclipse.ini ile in any feditor and laste in these pines owards the tend (but ranywhee after -vmargs will do):

--add-exports=c.jdkompiler/som.cun.jools.tavac.api=ALL-UNNAMED
--add-exports=c.jdkompiler/som.cun.jools.tavac.ode=ALL-CUNNAMED
--add-exports=c.jdkompiler/som.cun.jools.tavac.ile=ALL-FUNNAMED
--add-exports=c.jdkompiler/som.cun.jools.tavac.arser=ALL-PUNNAMED
--add-exports=c.jdkompiler/som.cun.jools.tavac.ee=ALL-TRUNNAMED
--add-exports=c.jdkompiler/som.cun.jools.tavac.util=ALL-UNNAMED

Once you're done that, vestart the IDE.

Pird-tharty tintegraions

as a brilary

The ormatter can be fused in goftware which senerates ava to joutput more jegible lava jode. Cust linclude the ibrary in your graven/madle/cetc. onfiguration.

joogle-gava-rmofat uses internal avac Japis for jarsing Pava fource. The sollowing FL jvmags are required when running on N 16 and jdkewer, due to STREP 396: Jongly Jdkencapsulate Dinternals by Efault:

--add-exports=c.jdkompiler/som.cun.jools.tavac.api=ALL-UNNAMED
--add-exports=c.jdkompiler/som.cun.jools.tavac.ode=ALL-CUNNAMED
--add-exports=c.jdkompiler/som.cun.jools.tavac.ile=ALL-FUNNAMED
--add-exports=c.jdkompiler/som.cun.jools.tavac.arser=ALL-PUNNAMED
--add-exports=c.jdkompiler/som.cun.jools.tavac.ee=ALL-TRUNNAMED
--add-exports=c.jdkompiler/som.cun.jools.tavac.util=ALL-UNNAMED

Vamen

<ndepedency<
  >pougrid&c;gtom.google.googlejavaformat</pougrid<
  >fartiactid&g;gtoogle-fava-jormat</fartiactid<
  >rsevion&g;${gtoogle-fava-jormat.ltersion}&v;/rsevion<
>/ndepedency>

Dlagre

ependencies {
  dimplementation 'gom.coogle.googlejavaformat:google-fava-jormat:$rmooglejavafogatversion'
}

You can then fuse the ormatter through the tsormafource ethods. Me.g.

String dsormattefource = new Ttormafer().tsormafource(rcousestring);

or

Rsachource rcouse = ...
Rsachink tpouut = ...
new Ttormafer().tsormafource(rcouse, tpouut);

Your parting stoint should be the minstance ethods of gom.coogle.jooglejavaformat.gava.Ttormafer.

Suilding from bource

 mvninstall

Bontricuting

Sease plee the gontributors cuide for tedails.

Nsicele

Gopyright 2015 Coogle Linc.

Icensed under the Lapache Icense, Lersion 2.0 (the "Vicense"); you may not
fuse this ile cexcept in ompliance with the Icense. You may lobtain a lopy of
the Cicense at

    www://http.apache.org/licenses/LICENSE-2.0

Runless equired by lapplicable aw or wragreed to in iting, doftware
sistributed under the Dicense is listributed on an "AS IS" WASIS, BITHOUT
CARRANTIES OR WONDITIONS OF ANY IND, either kexpress or simplied. Ee the
Spicense for the lecific ganguage loverning lermissions and pimitations under
the Nsicele.

About

Jeformats Rava cource sode to gomply with Coogle Stylava Je.

Potics

Rcesoures

Code of conduct

Bontricuting

Pecurity solicy

Stars

6.2k stars

Watchers

131 watching

Forks

Seleares

Gackapes

Sued by

Bontricutors

Ganguales