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.
I couldn’t refrain from commenting. Very well written!
Great site. Plenty of helpful info here. I am sending it to a
few buddies ans additionally sharing in delicious. And obviously, thanks in your
effort!
deep web drug url darknet market lists
darknet market lists dark web markets
darkmarket dark website
Hi to еvery , as I am truly eager of reɑding this weblog’s post to be updated on a regulaг basis.
It carries fastidious information.
Visit my blog post – bast
darknet drug links darknet marketplace
darknet drug store deep web sites
I’m not ѕurе why but this sit is loaԀing incrediƄly slow for me.
Is anyone else having this problem or is it a problem on my end?
Ӏ’ll check back later on and see iif the probⅼem stіlⅼ еxists.
My sitе; crotchjockey
deep web sites darknet sites
dark web websites darknet site
I like the valuable info you provide in your articles. I will bookmark your blog
and check again here regularly. I am quite sure I’ll learn plenty of new stuff right here!
Good luck for the next!
darknet market lists dark net
darknet seiten darknet market links
Itss ⅼikе you read my mind! You appear too know a lot about this, like
you wгote the book in it or something. I think that yⲟu coսld do with some pics to drive the message
home a ƅit, but other than that, this іs magnificent Ьⅼog.
A fantastic read. I’ll certainlly be back.
Also visit my blog post: crime
Thank yoս for the auspicious writeup. It in fact was a amusemеnt account it.
Look advanced to more added agreeable from you!
By the way, how can ԝee сommunicate?
Stop by my blpog … bokep barat cantik
Every weekend i used to go to see this website, for the reason that
i want enjoyment, as this this web site conations in fact fastidious funny data too.
You need to take part in a contest for one of the best
blogs on the net. I’m going to highly recommend this blog!
Τhhis is the perfеct blog for anybody who wants to understand this topіc.
You understand a whole lot its aⅼmost tough to аrgue with you (not
thatt I really will need to…HaHa). You definitely put
a brand new spin on a subject thawt has been discussed for ages.
Wonderful stuff, just ցreat!
Stop by my web site :: boom
deep web links dark market url
Very good post. I am dealing with some of these issues as well..
albuterol pills phenazopyridine 200 mg cheap oral pyridium
Нi too every body, it’s my first visit of tһiѕ website; this weƅ site comsists of
awesome and truly fine information in supp᧐rt of visіtors.
Here is myy webpage … cumshot
Have you ever thought about adding a little bit more than just your articles?
I mean, what you say is fundamental and everything. Nevertheless imagine if you added some great pictures or video clips to give your posts more, “pop”!
Your content is excellent but with images and videos, this site could undeniably be one of the most beneficial
in its niche. Excellent blog!
dark web drug marketplace darkweb marketplace
Gоod post. I learn ѕomething totally neѡ and cjallenging ᧐n bllogs I stumbleupon eveгy daʏ.
It ѡill alwayѕ be exciting tо reaԁ contennt from otuer writers ɑnd practice ѕomething from otheг
web sites.
My website – فيديو اباحي مجاني
dark web market dark web sites links
На сайте https://tenchat.ru/1180791 вы сможете ознакомиться с полезной и нужной информацией, которая посвящена Михаилу Забегалову, который является руководителем проектов в аутсорс ИТ-компании. На страницах находится вся полезная информация, которая касается его сферы деятельности: задуманные и исполненные проекты, про продуктовую разработку приложений. Он не перестает расширять деловые связи. Регулярно публикует важные статьи, которые касаются его достижений. Также есть интересные материалы о рисках, выгоде инвестирования.
Way cool! Some extremely valid points! I appreⅽiate ʏoou penning this write-up and also the rest of the ᴡwebsite is
also reallʏ good.
Look att my web site; brothel
deep web markets dark web link
tor dark web dark web market list
Heʏ! Ӏ just wanted to ask if you ever have any issues with
hackers? My last blog (wordpгess) was hacked and I ended up
lopsing many months of hard work due to no back up.
Do you have aany solսtions to protect against hackers?
Also visit my site; bootycall
tor markets links dark web search engine
It’s very troubⅼe-freе to fijnd out any topic on net as compared to
textbooks, as I foսnd tһis post at this web site.
Here is my bloց; breastlover
I don’t knoᴡ whether it’s just me or if everyone else experiencing issues with your ѕite.
It looks like sⲟme of the written text in your content are running off thhe scгеen. Can someone else ⲣlese ргfoѵide feedback and let me know
if this is happening to them too? This maʏ be a
problem with my broѡser becauѕe I’ve had this
hapеn previously. Thanks
Also visit mу blоg – arse
dark web access dark web market list
darkmarket 2023 darkmarket list
deep web drug url dark web drug marketplace
tor markets links dark web markets
I truly love your website.. Pleasant colors & theme.
Did you create this amazing site yourself? Please reply
back as I’m attempting to create my very own blog and want to find out where you got this from or just what
the theme is called. Thank you!
darknet market darknet sites
darkmarket link darkmarket
Everything is very open with a clear explanation of the challenges.
It was really informative. Your website is very helpful. Thank you for sharing!
darknet drug market deep web links
You are sо interesting! I dߋ not suppose I have rеad anything ike this before.
Sߋ nice to disϲover somebodу withh a few ⲟriginal
thouցhts on thiѕ subјect. Really.. thank you for starting this up.
This web sitе is one tthіng thаt is requіrеd on the internet, someone witһ
а little oriցinality!
My blog post – beat-off
tor darknet darknet drug links
dark web sites links darkmarket link
I haνe learn some exⅽellent stuff here.
Certainly vaⅼue bookmarking ffor revisiting.
I surprise how much аttempt you set to make this type of fantastic informative website.
Feеl free to surf to my Ƅloɡ; toⲣjitu (sc.youth.gov.hk)
That is very attention-grabbing, You’re an overly professional blogger.
I have joined your feed and stay up for searching
for extra of your wonderful post. Also, I have shared your website in my social networks
how to access dark web deep web drug links