Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
224 changes: 141 additions & 83 deletions src/com/goide/intentions/GoMoveToStructInitializationIntention.java

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/com/goide/psi/impl/GoElementFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,10 @@ public static GoTypeDeclaration createTypeDeclaration(@NotNull Project project,
GoFile file = createFileFromText(project, "package a; type " + name + " " + type.getText());
return PsiTreeUtil.findChildOfType(file, GoTypeDeclaration.class);
}

@NotNull
public static GoCompositeLit createCompositeLit(@NotNull Project project, @NotNull GoType type) {
GoFile file = createFileFromText(project, "package a; var _ = " + type.getText() + "{}");
return PsiTreeUtil.findChildOfType(file, GoCompositeLit.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package main

type S struct {
B
}

type B struct {
bar string
}

func main() {
var s S
s.bar<caret> = "bar"
print(s.bar)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package main

type S struct {
foo string
}

func main() {
var s string
s.foo <caret>= "bar"
print(s.foo)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package main

type S struct {
foo string
}

func main() {
s := S{foo: "bar"}

print(s.foo)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package main

type S struct {
foo string
}

func main() {
var (s S)
s.foo <caret>= "bar"
print(s.foo)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package main

type S struct {
foo string
}

func main() {
s := S{foo: "bar"}

print(s.foo)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package main

type S struct {
foo string
}

func main() {
var s S
s.foo <caret>= "bar"
print(s.foo)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package main

type S struct {
foo string
}

func main() {
var s, b S
s.foo <caret>= "bar"
print(s.foo)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package main

type S struct {
foo string
}

func main() {
var s S = S{foo: "bar"}

print(s.foo)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package main

type S struct {
foo string
}

func main() {
var s S = S{}
s.foo <caret>= "bar"
print(s.foo)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package main

type S struct {
foo string
bar string
}

func main() {
var s S = S{bar: "a", foo: "bar"}

print(s.foo)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package main

type S struct {
foo string
bar string
}

func main() {
var s S = S{bar: "a"}
s.foo <caret>= "bar"
print(s.foo)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package main

type S struct {
foo string
}

func main() {
var s S
var b S
s.foo <caret>= "bar"
print(b.foo)
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,24 @@ protected String getBasePath() {
public void testMultipleFieldsPartlyAssigned() { doTest(); }
public void testWithParens() { doTest(); }
public void testFieldExtractedFromParens() { doTest(); }
public void testStructDeclaration() { doTest(); }
public void testParensStructDeclaration() { doTest(); }
public void testStructDeclarationWithEmptyInit() { doTest(); }
public void testStructDeclarationWithNonEmptyInit() { doTest(); }

public void testDuplicateFields() { doTest(); }
public void testMultiReturnFunction() { doTestNoFix(); }
public void testWrongStruct() { doTestNoFix(); }
public void testNotStructDeclaration() { doTestNoFix(); }
public void testExistingDeclaration() { doTestNoFix(); }
public void testNotExistingField() { doTestNoFix(); }
public void testJustAssignedVarWrongCaret() { doTestNoFix(); }
public void testJustAssignedVarWrongCaretWithParens() { doTestNoFix(); }
public void testJustInitializedVarWrongCaret() { doTestNoFix(); }
public void testJustAssignedVarBothParens() { doTestNoFix(); }
public void testJustAssignedFieldParens() { doTestNoFix(); }
public void testStructDeclarationMultipleExpressions() { doTestNoFix(); }
public void testStructDeclarationWrongQualifier() { doTestNoFix(); }
public void testFieldOfAnonymousField() { doTestNoFix(); }
}