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.
darknet market links dark web sites
dark web market darkmarket list
generic viagra online pharmacy uk viagra brand name
generic drug viagra 10 pills viagra onde comprar online generic
viagra soft online
Great post however I was wondering if you could write a litte more on this topic?
I’d be very grateful if you could elaborate a little bit further.
Many thanks!
deep web drug url tor markets
Incredible points. Solid arguments. Keep up the amazing work.
my blog post :: eng.worthword.com
Info certainly utilized!!
tor market links blackweb official website
You could certainly see your skills within the work you write.
The world hopes for more passionate writers such as you who aren’t afraid to mention how they believe.
At all times follow your heart.
What’s up to every one, it’s really a fastidious for me to pay a visit this web site, it contains precious Information.
prescription drug singulair
tor market links darknet links
An interesting discussion is worth comment. I do think that you need to write more on this
subject matter, it may not be a taboo subject but usually folks don’t talk about such subjects.
To the next! Many thanks!!
dark web market deep web sites
I don’t even understand how I stopped up right here, but I believed this
post used to be great. I don’t know who you might be however certainly you’re going to a well-known blogger for those who aren’t already.
Cheers!
tor marketplace dark net
darknet markets tor dark web
deep web sites drug markets dark web
Excellent blog! Do you have any tips for aspiring writers?
I’m planning to start my own site soon but I’m a little lost on everything.
Would you suggest starting with a free platform like WordPress or go for a paid option? There are so many choices out there that I’m
completely confused .. Any recommendations? Thanks a lot!
Hi there, i read your blog from time to time and i own a similar one
and i was just wondering if you get a lot of spam feedback?
If so how do you reduce it, any plugin or anything you can recommend?
I get so much lately it’s driving me mad so any assistance is very much appreciated.
I enjoyed reading your post and found it to be very informative and thought-provoking.
I appreciate the research and effort you put into it. Keep up the great
work!
darkweb marketplace tor market links
Blue Solutions
art institute of vancouver web design
dark web access darknet market links
dark market onion tor market links
Hi there to every one, the contents present at this website are truly remarkable for people experience, well, keep up the good work fellows.
Hey I know this is off topic but I was wondering if you knew of any widgets
I could add to my blog that automatically tweet my newest twitter updates.
I’ve been looking for a plug-in like this for quite some time and
was hoping maybe you would have some experience with something like this.
Please let me know if you run into anything. I truly enjoy reading your blog and I look
forward to your new updates.
This site was… how do you say it? Relevant!!
Finally I’ve found something which helped me.
Appreciate it!
darknet markets darkmarket list
Amazing things here. I am very happy to see your article.
Thank you so much and I’m taking a look forward to contact you.
Will you kindly drop me a e-mail?
This piece of writing is genuinely a pleasant one it helps new the web users,
who are wishing in favor of blogging.
I’m not sure why but this blog is loading extremely slow for me.
Is anyone else having this issue or is it a problem on my end?
I’ll check back later and see if the problem still exists.
Hello! I’ve been following your website for a
while now and finally got the bravery to go ahead and give
you a shout out from New Caney Tx! Just wanted to mention keep up the great job!
cost of zoloft in canada
tor markets 2023 black internet
deep web drug url dark web markets
There is definately a lot to find out about this topic.
I really like all of the points you have made.
It’s a shame you don’t have a donate button! I’d most certainly donate to this outstanding blog!
I suppose for now i’ll settle for book-marking and adding
your RSS feed to my Google account. I look forward to fresh updates and will
talk about this blog with my Facebook group. Chat soon!
Hi my loved one! I wish to say that this article is awesome, nice written and include approximately all
vital infos. I would like to see more posts like this .
Hey there! I’ve been reading your blog for a long time now and finally got the bravery to go ahead and give you a shout
out from Huffman Texas! Just wanted to tell you keep
up the good work!
I loved as much as you’ll receive carried out right here.
The sketch is tasteful, your authored subject matter stylish.
nonetheless, you command get bought an edginess over
that you wish be delivering the following. unwell unquestionably come more formerly again as exactly the same nearly a lot often inside case
you shield this increase.
You really make it seem so easy with your presentation but I find this matter
to be really something that I think I would never understand.
It seems too complex and very broad for me. I am looking forward
for your next post, I’ll try to get the hang of it!
My programmer is trying to convince me to move to .net frokm PHP.
I have always isliked the idea because of the expenses.
But he’s tryiong none the less. I’ve been using Movable-type oon varous websites for about a year
and am anxious about switching to another platform.
I have heard excellent things about blogengine.net. Is there a way I can import all
my wordpress posts into it? Any kind of help woukd
be really appreciated!
Feell free to visiut my web-site – agen slot online
I like the valuable information you provide in your articles.
I’ll bookmark your blog and check again here regularly.
I’m quite certain I will learn many new stuff right here!
Good luck for the next!
dark web sites tor dark web
Hello there, I discovered your site by means of Google whilst searching for a similar subject, your website came
up, it appears to be like good. I have bookmarked it in my google bookmarks.
Hi there, just became aware of your weblog through Google, and found that it’s really informative.
I’m going to watch out for brussels. I’ll be grateful for those who continue this in future.
Lots of people might be benefited out of your writing. Cheers!
I have fun with, result in I found exactly what I used to be looking
for. You have ended my four day long hunt! God Bless you man. Have
a nice day. Bye
dark web markets darkmarket 2023
tor markets 2023 deep web search
My partner and I absolutely love your blog and
find most of your post’s to be what precisely I’m looking for.
can you offer guest writers to write content to suit
your needs? I wouldn’t mind producing a post or elaborating on a number of the subjects you write with regards to here.
Again, awesome blog!