These are chat archives for JnRouvignac/AutoRefactor

31st
Oct 2016
Luis Cruz
@luiscruz
Oct 31 2016 17:48
Hi Jean-Noël!!
:)
So, I’m not able to properly import Android Studio projects to the Eclipse
The importer does not work, so I have to create a new Android project and manually import manifest, source code, resources, etc.
The problem with the importer is that it does not recognize the main source code of the project
and since it does not recognize it as java source code, AutoRefactor menus are not shown.
In alternative, I can run alt+shift+Yand it will apply AutoRefactor. The only drawback is that I have to manually apply to every file.
I have applied it to this project: https://github.com/trikita/talalarmo
And Wakelock anti pattern is refactored :clap: :D
Luis Cruz
@luiscruz
Oct 31 2016 17:54
However, indentation is weird.. Don’t know if there is an easy workaround
Here is a part of the input:
    @Override
    public void onBackPressed() {
        stopAlarm();
        super.onBackPressed();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mWakeLock.release();
    }

    private void stopAlarm() {
Here is the output:
    @Override
    public void onBackPressed() {
        stopAlarm();
        super.onBackPressed();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    @Override
    protected void onPause() {
                super.onPause();
                if (!mWakeLock.isHeld()) {
                    mWakeLock.release();
                }
            }

    private void stopAlarm() {
Jean-Noël Rouvignac
@JnRouvignac
Oct 31 2016 18:01
Hi Luis!
Congratulations!
Luis Cruz
@luiscruz
Oct 31 2016 18:02
I’m now fixing some of your reviews that are still missing
Let me see if I can finish this today ;)
Jean-Noël Rouvignac
@JnRouvignac
Oct 31 2016 18:04
Alas I am getting late for the reviews :(
Luis Cruz
@luiscruz
Oct 31 2016 18:05
no worries ;) I’ll get rid of the ones we have now and when you’re available we continue ;)
Jean-Noël Rouvignac
@JnRouvignac
Oct 31 2016 18:05
I have 2 PRs in addition to yours and I have not found time to review them yet
Luis Cruz
@luiscruz
Oct 31 2016 18:07
yea no worries, if you don’t have time I’ll start reviewing myself the remaining rules
;)
Jean-Noël Rouvignac
@JnRouvignac
Oct 31 2016 18:10
Yes please apply some of the comments I made earlier
You know a bit better wha
What I am looking for now
Luis Cruz
@luiscruz
Oct 31 2016 18:12
yea ;)
Would mind explaining how to use insertLast(ASTNode listHolder, StructuralPropertyDescriptor locationInParent, ASTNode nodeToInsert)
?

for a body declaration:

insertLast(typeDeclaration, typeDeclaration.getBodyDeclarationsProperty(),declaration)

Would work?
forget, I’ll try it first
Jean-Noël Rouvignac
@JnRouvignac
Oct 31 2016 18:17
Yep I think so
Luis Cruz
@luiscruz
Oct 31 2016 18:21
perfect :D
Jean-Noël Rouvignac
@JnRouvignac
Oct 31 2016 18:27
;)
Concerning indentation, it may be down to JDT configuration for formatting
But I have found it to be disconcerting at times
Jean-Noël Rouvignac
@JnRouvignac
Oct 31 2016 18:41
Re: importing from android studio
What do you call the importer ?
The Java importer ?
Something else?
Luis Cruz
@luiscruz
Oct 31 2016 18:42
no, after installing Android plugin there is a new kind of projects — Android
that already imports the sdk and necessary tools
Screen Shot 2016-10-31 at 18.44.03.png
Jean-Noël Rouvignac
@JnRouvignac
Oct 31 2016 18:44
Ah crap :(
Bug report?
Luis Cruz
@luiscruz
Oct 31 2016 18:45
it is important because according to the project different versions of sdks should apply..
I can do that, but they are not supporting Eclipse for Android development anymore :(
Jean-Noël Rouvignac
@JnRouvignac
Oct 31 2016 18:46
I think this is now an eclipse project named and more
AndMore
Luis Cruz
@luiscruz
Oct 31 2016 18:47
side note:
I get this error with mvn clean install
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:0.23.1:compile (default-compile) on project org.autorefactor.plugin: Compilation failure: Compilation failure:
[ERROR] /home/travis/build/JnRouvignac/AutoRefactor/plugin/src/main/java/org/autorefactor/refactoring/ASTBuilder.java:[421]
[ERROR] modifiers(vde).add(final0());
[ERROR] ^^^^^^^^^
[ERROR] The method modifiers(IExtendedModifier...) in the type ASTBuilder is not applicable for the arguments (VariableDeclarationExpression)
[ERROR] 1 problem (1 error)
[ERROR] -> [Help 1]
Err with code from master?
I think I got this after merging
but I can run and test the project anyway :\
but declareExpr is not mine:
    public VariableDeclarationExpression declareExpr(Type type, SimpleName varName, Expression initializer) {
        final VariableDeclarationFragment fragment = declareFragment(varName, initializer);
        final VariableDeclarationExpression vde = ast.newVariableDeclarationExpression(fragment);
        modifiers(vde).add(final0());
        vde.setType(type);
        return vde;
    }
since I’ve created the modifiers method I wonder if it was pointing to a different modifiersmethod before..
Jean-Noël Rouvignac
@JnRouvignac
Oct 31 2016 18:54
Ah! Where did you declare it?
Luis Cruz
@luiscruz
Oct 31 2016 18:54
should it be vde.modifiers()? should I change the new modfiers()method name?
ASTBuilder
Jean-Noël Rouvignac
@JnRouvignac
Oct 31 2016 18:54
Name shadowing?
Luis Cruz
@luiscruz
Oct 31 2016 18:54
probably
Jean-Noël Rouvignac
@JnRouvignac
Oct 31 2016 18:55
Try that
See if it helps
Luis Cruz
@luiscruz
Oct 31 2016 18:55
vde.modifiers()?
or changing the method name?
Jean-Noël Rouvignac
@JnRouvignac
Oct 31 2016 18:55
The latter
I think I know
Name shadowing indeed
Ok just put a random name
I'll fix it post merge
Luis Cruz
@luiscruz
Oct 31 2016 18:58
alright renamed to modifiersList