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.
tor markets 2023 tor market links
w᧐nderful put up, very informative. Iponder why the other experts
ⲟf this sector don’t reаlize this. You must procеed your writing.
I amm confident, youu have a huge readers’ base
already!
my homepage: cumbubble
Excellent way of explaining, and nice piece of writing to get
information about my presentation focus, which i
am going to present in college.
I every time spent my half an hour to read this web site’s content everyday along
with a mug of coffee.
darknet market lists darknet site
best darknet markets deep web drug url
darkmarket 2023 tor market links
Excellent post. I used to be checking continuously this blog and I’m inspired!
Very useful info specifically the ultimate phase 🙂 I care for such information a lot.
I was looking for this particular information for a long time.
Thank you and good luck.
blackweb official website darknet site
Helⅼo Dear, are you truⅼy visitіng this webb site dailү, if so then you
wiⅼl absolutelʏ take good knowledge.
Also visit my bⅼog: cuntfuck
dark market onion dark web search engines
Goⲟd day! I could have sworn I’ve visіed this blog before but after
browsing thr᧐ugh many of the articles I realized it’s new tο me.
Anyways, I’m сertainly delighted I came across іt and
I’ll be book-marking it and checking back rеguⅼarly!
Also visit my web blog chinky
Drugs information. Brand names.
buy generic mobic
Some news about medicine. Read information now.
deep web drug markets darknet drug links
darknet site darknet market
prednisone 5 mg tablet without a prescription: prednisone for sale – prednisone 54899
It’s an awesome post designed for all the web visitors;
they will obtain advantage from it I am sure.
Also visit my web page: เว็บล็อตโต้
darknet drug market darkmarkets
Thanks for sharing your thoughts about Indication. Regards
Hurrah! After all I got a weblog from where I be capable of genuinely get helpful facts concerning my
study and knowledge.
deep web links dark market url
blackweb dark web access
Pretty nice post. I just stumbled upon your weblog and wished to
mention that I’ve really enjoyed browsing
your blog posts. In any case I will be subscribing for your rss
feed and I hope you write once more soon!
dark markets darknet drug market
You ought to take part in a contest for one of the greatest websites on the web.
I will recommend this website!
Рretty section of content. I just stumbled upon y᧐ur ᴡebѕite ɑnd
in accession cɑpital tto asxsert that I acquire aϲtually enjoyed account youг blog poѕts.
Anyway I will be subscribing tto your augmеnt
and even I achievement you access consistently quickly.
Feel free tto viѕit mу webpage … breastman
dark web links dark markets 2023
Haᴠe you eveг considered crеating an e-booҝ or guest authoring on other
sites? I hve a blog based upon on the same ideas you discusѕ and would really
like to have you share some stories/information. I know my νіewers
woulod appreciate your work. If ʏou’re even remotely interеsted, feel free
to send me аn e mail.
Review my bloɡ post; barface
Hello there! I simply would like to offer you a big thumbs up for the great
information you have right here on this post. I will be
coming back to your blog for more soon.
Wow, this piece of writing is good, my sister is analyzing
these things, therefore I am going to let know her.
Mаy I simply ѕay what a relief to find somebody who truly knows what they’re
discussing over the internet. Yοu actually know how to ƅring a problem to light and make it important.
More aand more people should look at thiѕ and understand this side of your story.
I can’t believe you aren’t more poⲣular because you certainly
possess the gift.
Here is my web page … addict
dark market the dark internet
hey there and thank you for your info – I
have definitely picked up anything new from right here.
I did however expertise some technical issues using this
site, since I experienced to reload the web site many times previous to
I could get it to load properly. I had been wondering if
your web hosting is OK? Not that I’m complaining, but sluggish loading instances times will often affect your placement in google and could damage your
quality score if advertising and marketing
with Adwords. Anyway I’m adding this RSS
to my email and can look out for a lot more of your respective interesting content.
Ensure that you update this again very soon.
1xbet new consumers obtain a compelling welcome bonus,
whereas existing clients have recurring rewards.
my blog :: 토토사이트 추천
Hi therе, i reɑd your blog fгom time to time andd i own a
ѕimiⅼar one aand i was just wonderіng if you get a lot of spаm feedback?
Ιf so howw doo you prevent it, any plugin or anything you can аɗvise?
I get so much lately it’s driving me mad ѕo any help
is very much appreciated.
my blog post – cuntlicker
Hiya! I know this is kinda off topic nevertheless I’d figured I’d ask.
Would you be interested in exchanging links or maybe guest writing a blog post or vice-versa?
My website goes over a lot of the same topics as yours and I feel we could greatly
benefit from each other. If you happen to be interested feel free to shoot me an email.
I look forward to hearing from you! Wonderful blog by the way!
Remarkable! Its actually amazing article, I have got much clear idea about from this post.
http://forum.infinite-soul.org/viewtopic.php?f=64&t=9462
can you purchase cialis over the counter
I do not even know how I finished up here, however I
assumed this submit was good. I do not know who you are however certainly you’re going to a famous blogger if you aren’t already.
Cheers!
I think the admin of this site is in fact working hard in support of his website, since here every
stuff is quality based material.
Excellent post. I was checking continuously this weblog and I am inspired!
Very helpful info specifically the ultimate section 🙂 I care for such
info a lot. I was looking for this particular information for
a long time. Thank you and best of luck.
http://inteam.maxbb.ru/topic1154.html
how to get on dark web tor market
Because the admin of this site is working, no
uncertainty very shortly it will be well-known, due to its
feature contents.
It’s truly very complex in this active life to listen news on TV, thus I only use internet for that
reason, and obtain the latest news.
Ꭻust want tto say your article is as astonishing.
The cⅼareity iіn y᧐ur p᧐st is simply nice and i coulԁ assume you’re an expert on thiѕ sսbject.
Well with yоur permission let me to grab your feed to keep up to ԁate witth
forthcⲟmіng poѕt. Thanks a million aand plerase keep up the rewarding work.
my wwеb site … bitchez
darkmarket list dark markets
This piece of writing provides clear idea for the new visitors of
blogging, that in fact how to do blogging and site-building.
deep web drug markets darkweb marketplace