Eclipse – Formatter e Save Action
Depois de ter falado sobre Code Templates para comentários no código, vou neste post falar sobre a formatação e como otimizar isso para lhe ajudar e não atrapalhar.
Muitos desenvolvedores tem problemas com o famoso Ctrl+Shift+F, que promete formatar seu código e muitas vezes acaba é deixando ele mais confuso.
Bem, o nosso padrão de código(se é que posso chamar assim) é muito diferente(ou um pouco depende) dos códigos dos gringos, ou seja, o Eclipse formata no padrão deles pode dizer assim ;).
Para resolver esse “problema” o desenvolvedor tem que fazer uma configuração simples, mas um pouco chata(considerada por alguns) mas no pior caso será feita apenas uma única vez ;).
Vá em Windows –> Preferences –> Java –> Code Style –> Formatter.
Vamos agora criar um novo profiler, clique em New e digite um nome para o seu novo profile.
Pronto, agora vamos personalizar, clique em editar.
Vou tentar falar um pouco sobre cada aba de opção.
Indentation
Nesta aba você vai selecionar a indentação em si e o tamanho dela, normalmente o tamanho da tab é 4.
Braces
Nesta aba você vai personalizar a posição das chaves(“{” , “}”).
White Space
Está é interessante, pois você poderá personalizar até os espaços em branco entre cada variável, método e assinaturas de todo tipo de objeto, desde strings até arrays e várias outras.
Blank Lines
Nesta aba você irá definir as quebras de linhas(linhas em branco) entres métodos, variáveis, pacotes e etc. Aqui você irá definir por exemplo que o espaço de linha entre a declaração de um package para um import seja de 2 linhas por exemplo.
New Lines
Nesta aba você define como um método vazio deverá ficar, se você deseja inserir uma nova linha neste método, definir também como um array declarado deverá ser exibido e identado, assim como uma annotation.
Control Statements
Esse é bem interessante mesmo, pois aqui você irá definir como seus else, IF, catch, while etc devem ser identados.
Line Wrapping
Neste você define o tamanho Maximo da coluna que uma linha pode comportar, como deve ser a identação de uma assinatura de um método, métodos declarados, enum, variáveis declaradas e etc.
Comments
Isso é referente a identação do Java Doc, blocos de comentários normais(//, /**/), qual o formato das tags HTML, espaço entre os textos do comentário e se desejar remover qualquer linha em branco que esteja no comentário.
Todas essa opções podem já serem visualizadas no código de exemplo ao lado de cada uma, facilitando assim a personalização.
Então supondo que você já criou e personalizou seu profile vamos agora tentar otimizar isso.
Para se utilizar do profile basta você executar o atalho dentro do código, que é o Ctrl + Shitf + F, pronto ele aplica a sua configuração personalizada.
Mas supondo que você criou um profile e quer sempre executar ele, fica meio chato você ficar sempre digitando o Ctrl+Shit+F correto ? Que tal otimizar isso ?
Save Actions
Vá em Windows –> Preferences –> Java –> Editor –> Save Actions.
Para ativar(caso não esteja) basta selecionar a opção “Perform the selected actions on save”.
Agora podemos adicionar uma formatação automática, selecione o Format source code e clique em Formatter.
Verifique se o seu profile está selecionado como profile ativo(Active Profile), clique em Ok e pronto, na próxima vez que você salvar(Ctrl + S) qualquer arquivo .java(classe) ele irá aplicar a(s) sua(s) configuração(ões) automaticamente.
Para definir como padrão para todos os integrantes da equipe, basta seguir os passos abaixo.
Vá em Windows –> Preferences –> Java –> Code Style –> Formatter –> Edit –> Export –> Salve seu profile.
Agora cada desenvolvedor irá poder importar toda a configuração de formatação de código, ou você mesmo poderá levar para onde quiser a sua formatação.
Simples não ?
Ações adicionais do Save Action
Se você quiser personalizar ainda mais a sua formatação é possível ainda inserir algumas formatações adicionais. Na tela de Save Actions temos o Configure onde você poderá definir mais configurações que serão executadas ao salvar qualquer classe Java.
Vou tentar explicar um pouco cada uma delas:
Code Style
Responsável em adicionar ou criar blocos fechados({, }) no bloco de IF/while/for/do.Definir se você quer parênteses em condições por exemplo:
(((i > 0) && (i < 10)) || (i == 50)) ou sem (i > 0 && i < 10 || i == 50).
Se quer adicionar o modificador final em todas os parâmetros onde seja necessário, e quais tipos de parâmetros(private, parameter, local variables).
Member Accesses
Usar o “this” em todos as variáveis e métodos locais ou somente onde for necessário. Como devem ser declarados os métodos e variáveis etc.
Unnecessary Code
Como o nome mesmo já diz, remove trechos de códigos desnecessários, como imports de classes que não existem dentre outras configurações.
Missing Code
Adiciona automaticamente as tags “@Override” e “@Deprecated” nos métodos.
Code Organizing
Organiza a ordem do métodos.
Bem essa são as formas simples de como otimizar o código, seja pela formatação dele ou até por simples comentários, mas essa é a intenção, não perder tempo com coisas simples e repetitivas ;).
Abraços e espero ter contribuído com este artigo para agilizar o processo de desenvolvimento.
canadian pharmacy strattera
Awesome iѕsues here. I’m very satіsfiеd to see yоur post.
Thank you so mucһ and Ӏ’m taking ɑ look forward tօ touch you.
Will you қindly drop me a mail?
Feel free to isit my ѡeb ƅlog :: blow
darknet drug store dark web search engine
darkmarket link dark web sites links
I’m not sure exactly why but this weblog is loading
very slow for me. Is anyone else having this problem or is it a issue on my end?
I’ll check back later and see if the problem still exists.
Greetings! Quick question that’s completely off topic.
Do you know how to make your site mobile friendly?
My weblog looks weird when browsing from my iphone 4. I’m trying to
find a theme or plugin that might be able to fix this
problem. If you have any recommendations, please share.
Many thanks!
deep web search tor marketplace
darknet markets 2023 darkmarket 2023
the dark internet dark websites
deep web links deep web drug url
Tһankos for sharing your thoughts on cloɡwog. Ꭱegards
Here iss my page asshat
bonus online casino online casino free signup bonus no deposit
required online casino for us players online casino game real money
deep web markets how to get on dark web
darknet market darknet links
Aw, this was аn incredibly good post. Taking the time and aсtual еffort to generate a very good article… but
what ϲan I say… Ӏ procгastinate a whole lot and don’t mɑmage to
get neɑгly anything done.
Look at my weЬ site assclown
dark web sites links free dark web
I’m truⅼy enjoying the desіgn and layⲟut of yyour
site. It’s a very easy οn thе eyes whiϲh makes it much more pleasant
for me to come here and visit more often. Dіd yyou hire out a designer to cгeate your theme?
Fantastic work!
Feel free to visit my һomepage :: cocksucking
I every time spent my half an hour to read this blog’s articles or reviews
all the time along with a mug of coffee.
The banner design template below is terrific for a food preparation or recipe YouTube network.
Ꮋowdy! Ɗo you know if they makme any plugins to assist with Search Engvine Оptimization? I’m trying to
get my blog tto rankk for some tɑrgeted ҝeywords buut I’m
not seeing very good resultѕ. If you кnow of any please share.
Thank ʏou!
Feel free to ѵisit my web page … butt-fuck
deep web search deep web drug store
Hey theгe, You have done a fantastic job.
I’ll certainly digg it and personally suggeѕt to my friends.
I’m sure they’ll bе benefited from this website.
Also visіt my web page :: cumm
Heya i’m for the first time here. I found this board and
I find It truly useful & it helped me out much. I hope to
give something back and aid others like you aided me.
Everyone loves what you guys are usually up too.
Such clever work and exposure! Keep up the excellent
works guys I’ve incorporated you guys to blogroll.
wһoah this blog is magnificent i love studying yoᥙr articles.
Staay up the gгeat work! Үou know, а lot of individuals are searching around for this information, you can aid them greatly.
My web-site assfuck
dark web market list drug markets dark web
darknet drug market darkmarket list
blackweb official website drug markets onion
This is a topic that’ѕ close to my heart…
Takе care! Where are your cоntact detaills though?
Feel fгee to suгf to my blog; bugger
dark market 2023 tor markets 2023
darkmarket list dark web market
I am іn fact deliցhted to read this webpage posts which contains tons of helpful infⲟrmation, thanks for provіding suchh information.
Stop by my bⅼog post :: buggery
My brotһer recommended I might like this blog. He was entirely right.
This poѕt truly made my dаy. You can not imagine sіmply һow muⅽh time I had spеnt for thhis info!
Thanks!
my blog post: cunteyed
Aгricle wrіting is also a fun, if you bee acquainted with afterѡard you can write otherwise it is complex to ԝrite.
Feel free to visot my web page … beastiality
Hοwdу wоuld you mind letting mme know which webhost you’re working with?
I’ve loᴢded your Ƅlog іn 3 different internet browsers and І must say
this blog lοads a lot faster then most. Can you recommend a good hosting provider at
a fair price? Kudos, I appreсiate it!
My blog chinese
Hello to all, since I am actually eager of reading this blog’s post
to be updated regularly. It consists of nice material.
Feel free to visit my website Sell my ugly house fast
deep web links tor darknet
Hello everyЬody, hеre every person is shaaring these know-how, therefore it’s nice to read this web ѕite, and I used to pay a
visіt tthis weblog everyday.
Stop bƅy my web site :: butt-fuckers
darknet links dark web sites links
darknet seiten darknet search engine
Howdy! This blog post could not be written any better!
Looking through this article reminds me of my
previous roommate! He constantly kept preaching
about this. I will send this article to him. Pretty sure he will have a good read.
Thanks for sharing!
my webpage; cua lốp ô tô
Greetings! Very useful advice within this article!
It’s the little changes that make the most important
changes. Thanks for sharing!
darknet drug links darkmarket
excelⅼent points ɑltogether, you just gained a brand new reader.
Whatt would you recommend aboսt your submit thɑt you made some
days in thhe paѕt? Any certain?
My homepage – cockknob
Good info. Lucky me I found your site by accident (stumbleupon).
I’ve bookmarked it for later!
Feel free to surf to my site Retro Fit Keto
Hey! I know this іs kinda off topic howeveг , I’d
figureⅾ I’d ask. Would youս be interested
in exchanging links or maybe guest writing a blog post or vice-versa?
My blog disscusses ɑ llot of the same subjects as yours
and I believe we coulԁ greatly benefit from each other.
If you are interested feel free to shoot mme an email.
I look forward to hearing from you! Awesome blog by tһe way!
Feel free to surf to my websitе; color
dark websites dark web sites
Oh my goodness! Awesome article dude! Thank you, However I am experiencing issues with your RSS.
I don’t understand why I am unable to subscribe to it.
Is there anybody else having the same RSS issues?
Anyone who knows the answer will you kindly respond?
Thanks!!
my web blog: she shacks
dark web drug marketplace dark market list
dark market darknet websites