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.
deep web drug links dark websites
Medicines information leaflet. Short-Term Effects.
levitra
Some information about drugs. Read now.
Hello there! This blog post couldn’t be written any better!
Going through this article reminds me of my previous roommate!
He always kept talking about this. I am going to
send this post to him. Pretty sure he’s going to have a great read.
Many thanks for sharing!
blackweb official website dark web access
Explore the diverse world of snus at SnusDirect! Discover a wide range of products to suit your taste.
I was pretty pleased to discover this great site.
I wanted to thank you for your time just for this
fantastic read!! I definitely liked every little bit of
it and I have you book marked to look at new information in your website.
Let me give you a thumbs up man. Can I show my hidden information on amazing
values and if you want to have a checkout and also share valuable info about how to change your life yalla lready
know follow me my fellow commenters!.
dark web site dark internet
darkmarket list darkmarket
So this Christmas buy your pet a CD of some popular pet music available in stores or even online.
How to shop at Shopify stores? When does Shopify split its stock?
In addition, it’s important to keep in mind that while you may be offering
service 24 hours a day, you also need to take into account your own needs and make time for yourself to recharge after a busy day.
Keep in mind that when you fail to do the right thing, your investment and effort will be put to
waste. Our pet insurance reviews will answer all of your questions and put
you on the path to choosing the right pet insurance for your dog or cat.
Pets Best’s helpline aids its customers with more than just insurance questions.
In this regard, we value and respect our customers and have made their satisfaction our priority.
If you have multiple horses, complete this stage with the dominant horse before giving the rest of
the herd access to the new horse. Giving your new horse the ability to see other horses decreases his fear response and
helps him to settle in more quickly. You have to see to it that problems
are resolved first hand.
onion market darknet market
tor marketplace tor marketplace
https://nagatoto.asia/
NAGA SLOT | NAGATOTO | AGEN SLOT NAGATOTO | LINK LOGIN DAN DAFTAR ALTERNATIF NAGA SLOT
Marvelous, what a weblog it is! This web site provides valuable information to
us, keep it up.
dark market 2023 dark markets
You actually make it seem really easy along with your presentation but I in finding this matter to be really one thing which I believe
I would never understand. It seems too complicated and extremely huge for me.
I am looking forward in your subsequent submit,
I’ll try to get the cling of it!
Pills information sheet. Brand names.
effexor
Best information about medicines. Get information now.
great publish, very informative. I ponder why the other experts of this sector
don’t notice this. You must continue your writing. I’m confident, you’ve a great readers’
base already!
online tadalafil prescription
Great site you have here but I was wondering if you
knew of any message boards that cover the same topics discussed
in this article? I’d really like to be a part of community where
I can get feedback from other experienced people that share the
same interest. If you have any recommendations, please let me know.
Thanks!
dark web market links tor markets
Its like you read my thoughts! You seem to know so much about this,
such as you wrote the book in it or something. I feel that you simply can do with a few
p.c. to pressure the message house a little bit, however instead of that, this is wonderful blog.
A great read. I’ll definitely be back.
buy valtrex nz
darknet seiten darkmarkets
Hello there! I know this is somewhat off topic but I was wondering if you knew where I could find a
captcha plugin for my comment form? I’m using
the same blog platform as yours and I’m having difficulty finding one?
Thanks a lot!
I couldn’t refrain from commenting. Very well
written!
dark web markets tor market
darknet links deep web markets
deep dark web darkmarket list
I think this is one of the most vital information for me.
And i am glad reading your article. But should remark on few
general things, The site style is great, the articles is really excellent :
D. Good job, cheers
dark web websites darkmarket
Explore the diverse world of snus at Snus Direct! Discover a wide range of products to suit your taste.
Pills information leaflet. What side effects can this medication cause?
abilify
Some about medicines. Get information here.
deep web drug url darkweb marketplace
Cavities are decomposed locations of your teeth that turn into
small openings or holes.
dark web websites dark market url
tor markets 2023 onion market
free dark web tor dark web
darknet drug links best darknet markets
dark web search engine dark market 2023
Hello, every time i used to check webpage posts here in the early hours in the
break of day, for the reason that i enjoy to find out more and more.
Saved as a favorite, I like your website!
free dark web dark market 2023
darknet sites dark markets
I take pleasure in, result in I discovered exactly what I was having a look
for. You’ve ended my four day lengthy hunt! God Bless you man. Have a nice day.
Bye
Hi my friend! I wish to say that this post is amazing, nice written and come with almost all important
infos. I would like to peer more posts like this .
dark web sites dark web market
dark web drug marketplace tor markets links
darknet websites darkmarket link
bitcoin dark web free dark web