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.
blackweb official website deep web links
free dark web dark web drug marketplace
drug markets onion dark market onion
Your mode of telling the whole thing in this article is genuinely nice, all can simply know it, Thanks a lot.
darknet market dark web site
dark market link darkmarket link
darknet markets bitcoin dark web
darkmarket best darknet markets
bitcoin dark web dark market
deep web drug url dark web sites
I’m curious to find out what blog platform you are utilizing?
I’m having some small security problems with my latest website and I would like to find something more safe.
Do you have any recommendations?
dark web site dark web sites
dark markets darkmarket list
dark web access deep dark web
darknet market black internet
blackweb deep web drug markets
dark markets tor markets links
can you purchase prednisone for dogs without a prescription
free dark web tor darknet
When someone writes an paragraph he/she keeps the idea of a
user in his/her brain that how a user can be
aware of it. So that’s why this post is outstdanding.
Thanks!
darknet drug store darkmarkets
best darknet markets dark web sites links
darkweb marketplace tor marketplace
deep web drug store bitcoin dark web
Do you have a spam issue on this site; I also am a blogger,
and I was wondering your situation; we have developed some nice methods and we are looking to trade techniques with other folks, why not shoot me an email
if interested.
buy tadalafil
dark market 2023 tor markets links
dark web search engines darknet market
dark web market tor markets
dark market onion darknet market links
Great beat ! I would like to apprentice while you amend your website, how
can i subscribe for a blog site? The account helped me a acceptable deal.
I had been tiny bit acquainted of this your broadcast offered bright clear concept
Because bridge financing tends to be more expensive than other types of financing, it
is generally a good idea to determine if it is possible to borrow money from other
sources. When your credit score gets more focuses, the less investment rate
you will get and the more chances you will have for an improved manage financial organizations.
A lot of banks, despite their claims of “Free checking accounts”, will charge you a service fee if your balance falls below
a certain amount.
Drugs information. Short-Term Effects.
cipro without insurance
Actual information about pills. Get information here.
Амины применяют в лекарственной промышленности, производстве пластмасс и красителей, а также в качестве
антиоксидантов, пестицидов.
dark internet tor dark web
King855 Online Casino Singapore Crowns Lucky Winner with Unimaginable Riches!
Are you ready to listen to about the biggest
online casino win in Singapore? Brace yourself, because King855 Online Casino has just crowned a lucky winner
with unimaginable riches! This is simply not just any ordinary win,
but a life-changing one which will leave you
in awe. The winner, who wishes to remain anonymous, won a whopping SGD 10 million jackpot on the popular slot game Mega Moolah.
The news of this incredible win has sent shockwaves throughout
the online casino community in Singapore. It isn’t every day
that someone wins such a large amount of money, in fact it is even rarer for it to happen at an online casino.
This win has proven that online casinos are just as with the capacity of
producing big winners as their land-based counterparts.
The Mega Moolah slot game is known for its massive jackpots, and it has been responsible for a number of the biggest online casino
wins in history. The overall game features four progressive jackpots, with the Mega Jackpot
being the biggest. To win the Mega Jackpot, players must trigger the game’s bonus round, where they spin a wheel to find out which jackpot they will win. The lucky winner at
King855 Online Casino were able to hit the Mega Jackpot, which have been steadily growing for months.
The winner was understandably overjoyed when they heard
bout their win. They said they had been playing at
King855 Online Casino for some months and had always enjoyed playing
Mega Moolah. They never expected to win such a huge amount
of money and were still in shock when they
received the news.
The CEO of King855 Online Casino was also thrilled
concerning the win. He said that it had been always exciting to see players win big at their casino and that they were proud to have produced this type of massive
jackpot winner. He also mentioned that King855 Online Casino takes responsible gambling seriously and
encourages players to gamble responsibly.
This win has put King855 Online Casino on the map as one of the top online
casinos in Singapore. It shows that they offer fair games with big payouts and that players can trust them
making use of their money. The casino supplies a wide range of games,
including slots, table games, and live dealer games, so there’s something for
everyone.
For anyone who is feeling lucky and desire to try your hand at winning big just like the lucky winner at King855 Online Casino, then head
over to their website and start playing today! Who knows,
you could be the next big winner!
Check out my webpage – king855 casino live online in singapore
bitcoin dark web darknet drug links
darkmarket 2023 tor marketplace
darkmarket list drug markets dark web
tor market url darknet market links
deep web sites tor dark web
darkmarkets dark websites
dark web link deep web drug markets
deep web drug markets dark web market
After exploring a handful of the blog articles on your web site, I seriously like your way of
writing a blog. I saved as a favorite it to my bookmark website list and will be checking back
in the near future. Please visit my web site as well and tell me how you feel.
darkmarket dark web sites links
darknet links blackweb
This blog ᴡɑs… how do үοu ѕay it? Relevant!! Finalⅼy I have fοund something tһat helped me.
Many tһanks!
Feel free to surf to my web site – betting games [Cynthia]
dark market 2023 darknet drug links
tor darknet darknet markets 2023