Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Inplace Variable Introduce refactoring #1772

Merged

Conversation

auduchinok
Copy link
Contributor

Needs adding tests and probably introduce using dialog.

}
else if (expressions.size() == 1) {
GoExpression expression = ContainerUtil.getFirstItem(expressions);
if (expression == null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance to have a list of null values here?

@auduchinok auduchinok force-pushed the extract_variable_refactoring branch 6 times, most recently from 30b9eb8 to a4380fb Compare July 30, 2015 17:11
if (!CommonRefactoringUtil.checkReadOnlyStatus(file)) return;
if (editor.getSettings().isVariableInplaceRenameEnabled()) {
final TemplateState templateState = TemplateManagerImpl.getTemplateState(editor);
if (templateState != null && !templateState.isFinished()) return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add tooltip

@zolotov
Copy link
Contributor

zolotov commented Jul 31, 2015

selection-tests are needed

return PsiTreeUtil.findElementOfClassAtRange(operation.getFile(), selectionModel.getSelectionStart(), selectionModel.getSelectionEnd(),
                                          GoExpression.class);

if (element instanceof PsiWhiteSpace || (parenthesesParent != null && parenthesesParent.getRparen() == element)) {
element = file.findElementAt(offset - 1);
}
return element instanceof GoExpression ? (GoExpression)element : PsiTreeUtil.getParentOfType(element, GoExpression.class);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getNonStrictParentOfType

@zolotov
Copy link
Contributor

zolotov commented Jul 31, 2015

Cannot perform refactoring:

package main

func main() {
    println(3<caret>)
}

@zolotov
Copy link
Contributor

zolotov commented Jul 31, 2015

Wrong result

package main

func main() {
    i := test()
}

func test() int {

}

return true;
}

private static PsiElement findAnchor(@NotNull List<PsiElement> occurrences) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optimize with PsiTreeUtil.findCommonParent(occurrences)

@auduchinok auduchinok force-pushed the extract_variable_refactoring branch 2 times, most recently from 5d1bb5a to f339631 Compare August 3, 2015 14:26
@auduchinok auduchinok force-pushed the extract_variable_refactoring branch 2 times, most recently from eb2eba3 to 729aa51 Compare August 3, 2015 16:23
Refactor and fix

Fix test

Annotate Introduce Operation
zolotov added a commit that referenced this pull request Aug 3, 2015
…ctoring

Add Inplace Variable Introduce refactoring
@zolotov zolotov merged commit 8157f8b into go-lang-plugin-org:master Aug 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants