From b0b2caeeb94f7f70b8be960500491fc5dccceca1 Mon Sep 17 00:00:00 2001 From: wannabe Date: Wed, 24 May 2017 15:59:09 +0300 Subject: [PATCH 1/2] Unresolved struct field inspection --- .../unresolved/GoAddStructFieldFix.java | 65 +++++++++++++++++++ .../GoUnresolvedReferenceInspection.java | 17 ++++- src/com/goide/psi/impl/GoElementFactory.java | 9 ++- testData/quickfixes/add-struct-field/blank.go | 11 ++++ .../add-struct-field/simple-after.go | 12 ++++ .../quickfixes/add-struct-field/simple.go | 11 ++++ .../withoutAssignment-after.go | 12 ++++ .../add-struct-field/withoutAssignment.go | 11 ++++ .../add-struct-field/withoutElements-after.go | 10 +++ .../add-struct-field/withoutElements.go | 10 +++ .../GoAddStructFieldQuickFixTest.java | 44 +++++++++++++ 11 files changed, 209 insertions(+), 3 deletions(-) create mode 100644 src/com/goide/inspections/unresolved/GoAddStructFieldFix.java create mode 100644 testData/quickfixes/add-struct-field/blank.go create mode 100644 testData/quickfixes/add-struct-field/simple-after.go create mode 100644 testData/quickfixes/add-struct-field/simple.go create mode 100644 testData/quickfixes/add-struct-field/withoutAssignment-after.go create mode 100644 testData/quickfixes/add-struct-field/withoutAssignment.go create mode 100644 testData/quickfixes/add-struct-field/withoutElements-after.go create mode 100644 testData/quickfixes/add-struct-field/withoutElements.go create mode 100644 tests/com/goide/quickfix/GoAddStructFieldQuickFixTest.java diff --git a/src/com/goide/inspections/unresolved/GoAddStructFieldFix.java b/src/com/goide/inspections/unresolved/GoAddStructFieldFix.java new file mode 100644 index 0000000000..d5c0f43836 --- /dev/null +++ b/src/com/goide/inspections/unresolved/GoAddStructFieldFix.java @@ -0,0 +1,65 @@ +/* + * Copyright 2013-2017 Sergey Ignatov, Alexander Zolotov, Florin Patan + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.goide.inspections.unresolved; + +import com.goide.psi.GoFieldDeclaration; +import com.goide.psi.GoStructType; +import com.goide.psi.impl.GoElementFactory; +import com.intellij.codeInspection.LocalQuickFixOnPsiElement; +import com.intellij.openapi.project.Project; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiFile; +import com.intellij.util.ObjectUtils; +import com.intellij.util.containers.ContainerUtil; +import org.jetbrains.annotations.Nls; +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +public class GoAddStructFieldFix extends LocalQuickFixOnPsiElement { + public static final String QUICK_FIX_NAME = "Add missing field"; + private final String myFieldText; + private final String myTypeText; + + protected GoAddStructFieldFix(String fieldText, String typeText, @NotNull GoStructType element) { + super(element); + myFieldText = fieldText; + myTypeText = typeText; + } + + @NotNull + @Override + public String getText() { + return QUICK_FIX_NAME; + } + + @Override + public void invoke(@NotNull Project project, @NotNull PsiFile file, @NotNull PsiElement startElement, @NotNull PsiElement endElement) { + GoStructType structType = ObjectUtils.tryCast(startElement, GoStructType.class); + if (structType == null) return; + List declarations = structType.getFieldDeclarationList(); + PsiElement anchor = !declarations.isEmpty() ? ContainerUtil.getLastItem(declarations) : structType.getLbrace(); + if (anchor != null) structType.addAfter(GoElementFactory.createFieldDeclaration(project, myFieldText, myTypeText), anchor); + } + + @Nls + @NotNull + @Override + public String getFamilyName() { + return QUICK_FIX_NAME; + } +} diff --git a/src/com/goide/inspections/unresolved/GoUnresolvedReferenceInspection.java b/src/com/goide/inspections/unresolved/GoUnresolvedReferenceInspection.java index 34444ce28b..6ce4d2e6a5 100644 --- a/src/com/goide/inspections/unresolved/GoUnresolvedReferenceInspection.java +++ b/src/com/goide/inspections/unresolved/GoUnresolvedReferenceInspection.java @@ -20,6 +20,7 @@ import com.goide.codeInsight.imports.GoImportPackageQuickFix; import com.goide.inspections.GoInspectionBase; import com.goide.psi.*; +import com.goide.psi.impl.GoPsiImplUtil; import com.goide.psi.impl.GoReference; import com.intellij.codeInsight.highlighting.ReadWriteAccessDetector; import com.intellij.codeInspection.LocalInspectionToolSession; @@ -33,6 +34,7 @@ import com.intellij.psi.formatter.FormatterUtil; import com.intellij.psi.impl.source.resolve.reference.impl.providers.FileReference; import com.intellij.psi.util.PsiTreeUtil; +import com.intellij.util.ObjectUtils; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -74,7 +76,12 @@ public void visitReferenceExpression(@NotNull GoReferenceExpression o) { } else if (reference.resolve() == null) { LocalQuickFix[] fixes = LocalQuickFix.EMPTY_ARRAY; - if (isProhibited(o, qualifier)) { + GoType type = qualifier != null ? qualifier.getGoType(null) : null; + GoStructType structType = type != null ? ObjectUtils.tryCast(type.getUnderlyingType(), GoStructType.class) : null; + if (!"_".equals(reference.getCanonicalText()) && structType != null) { + fixes = new LocalQuickFix[]{new GoAddStructFieldFix(reference.getCanonicalText(), getTypeName(o), structType)}; + } + else if (isProhibited(o, qualifier)) { fixes = createImportPackageFixes(o, reference, holder.isOnTheFly()); } else if (holder.isOnTheFly()) { @@ -159,6 +166,14 @@ else if (holder.isOnTheFly()) { }; } + private static String getTypeName(GoReferenceExpression referenceExpression) { + GoAssignmentStatement assignment = PsiTreeUtil.getParentOfType(referenceExpression, GoAssignmentStatement.class); + if (assignment == null) return "interface {}"; + GoExpression expression = GoPsiImplUtil.getRightExpression(assignment, referenceExpression); + GoType type = expression != null ? expression.getGoType(null) : null; + return type != null ? type.getText() : "interface {}"; + } + @NotNull private static LocalQuickFix[] createImportPackageFixes(@NotNull PsiElement target, @NotNull PsiReference reference, boolean onTheFly) { if (onTheFly) { diff --git a/src/com/goide/psi/impl/GoElementFactory.java b/src/com/goide/psi/impl/GoElementFactory.java index a9c4939ad2..7f8674e9b0 100644 --- a/src/com/goide/psi/impl/GoElementFactory.java +++ b/src/com/goide/psi/impl/GoElementFactory.java @@ -74,7 +74,7 @@ public static GoIfStatement createIfStatement(@NotNull Project project, public static GoImportDeclaration createEmptyImportDeclaration(@NotNull Project project) { return PsiTreeUtil.findChildOfType(createFileFromText(project, "package main\nimport (\n\n)"), GoImportDeclaration.class); } - + @NotNull public static GoImportDeclaration createImportDeclaration(@NotNull Project project, @NotNull String importString, @Nullable String alias, boolean withParens) { @@ -191,7 +191,7 @@ public static GoGoStatement createGoStatement(@NotNull Project project, @NotNull @NotNull public static GoForStatement createForStatement(@NotNull Project project, @NotNull String text) { - GoFile file = createFileFromText(project, "package a; func a() {\n for {\n" + text + "\n}\n}"); + GoFile file = createFileFromText(project, "package a; func a() {\n for {\n" + text + "\n}\n}"); return PsiTreeUtil.findChildOfType(file, GoForStatement.class); } @@ -266,4 +266,9 @@ public static GoTypeDeclaration createTypeDeclaration(@NotNull Project project, GoFile file = createFileFromText(project, "package a; type " + name + " " + type.getText()); return PsiTreeUtil.findChildOfType(file, GoTypeDeclaration.class); } + + public static GoFieldDeclaration createFieldDeclaration(@NotNull Project project, @NotNull String fieldText, @NotNull String typeText) { + GoFile file = createFileFromText(project, "package a; var _ = struct { " + fieldText + " " + typeText + " }"); + return PsiTreeUtil.findChildOfType(file, GoFieldDeclaration.class); + } } \ No newline at end of file diff --git a/testData/quickfixes/add-struct-field/blank.go b/testData/quickfixes/add-struct-field/blank.go new file mode 100644 index 0000000000..986af3874d --- /dev/null +++ b/testData/quickfixes/add-struct-field/blank.go @@ -0,0 +1,11 @@ +package main + +type S struct { + bb interface{} + cc interface{} +} + +func main() { + s := S{} + s._ = "aa" +} \ No newline at end of file diff --git a/testData/quickfixes/add-struct-field/simple-after.go b/testData/quickfixes/add-struct-field/simple-after.go new file mode 100644 index 0000000000..f2a7f565b9 --- /dev/null +++ b/testData/quickfixes/add-struct-field/simple-after.go @@ -0,0 +1,12 @@ +package main + +type S struct { + bb interface{} + cc interface{} + aa string +} + +func main() { + s := S{} + s.aa = "aa" +} \ No newline at end of file diff --git a/testData/quickfixes/add-struct-field/simple.go b/testData/quickfixes/add-struct-field/simple.go new file mode 100644 index 0000000000..f5da0ea8a3 --- /dev/null +++ b/testData/quickfixes/add-struct-field/simple.go @@ -0,0 +1,11 @@ +package main + +type S struct { + bb interface{} + cc interface{} +} + +func main() { + s := S{} + s.aa = "aa" +} \ No newline at end of file diff --git a/testData/quickfixes/add-struct-field/withoutAssignment-after.go b/testData/quickfixes/add-struct-field/withoutAssignment-after.go new file mode 100644 index 0000000000..303410b80a --- /dev/null +++ b/testData/quickfixes/add-struct-field/withoutAssignment-after.go @@ -0,0 +1,12 @@ +package main + +type S struct { + bb interface{} + cc interface{} + aa interface{} +} + +func main() { + s := S{} + s.aa +} \ No newline at end of file diff --git a/testData/quickfixes/add-struct-field/withoutAssignment.go b/testData/quickfixes/add-struct-field/withoutAssignment.go new file mode 100644 index 0000000000..fba0f54a07 --- /dev/null +++ b/testData/quickfixes/add-struct-field/withoutAssignment.go @@ -0,0 +1,11 @@ +package main + +type S struct { + bb interface{} + cc interface{} +} + +func main() { + s := S{} + s.aa +} \ No newline at end of file diff --git a/testData/quickfixes/add-struct-field/withoutElements-after.go b/testData/quickfixes/add-struct-field/withoutElements-after.go new file mode 100644 index 0000000000..524df589df --- /dev/null +++ b/testData/quickfixes/add-struct-field/withoutElements-after.go @@ -0,0 +1,10 @@ +package main + +type S struct { + aa string +} + +func main() { + s := S{} + s.aa = "aa" +} \ No newline at end of file diff --git a/testData/quickfixes/add-struct-field/withoutElements.go b/testData/quickfixes/add-struct-field/withoutElements.go new file mode 100644 index 0000000000..18a797abaa --- /dev/null +++ b/testData/quickfixes/add-struct-field/withoutElements.go @@ -0,0 +1,10 @@ +package main + +type S struct { + +} + +func main() { + s := S{} + s.aa = "aa" +} \ No newline at end of file diff --git a/tests/com/goide/quickfix/GoAddStructFieldQuickFixTest.java b/tests/com/goide/quickfix/GoAddStructFieldQuickFixTest.java new file mode 100644 index 0000000000..ec251decf3 --- /dev/null +++ b/tests/com/goide/quickfix/GoAddStructFieldQuickFixTest.java @@ -0,0 +1,44 @@ +/* + * Copyright 2013-2017 Sergey Ignatov, Alexander Zolotov, Florin Patan + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.goide.quickfix; + +import com.goide.SdkAware; +import com.goide.inspections.unresolved.GoUnresolvedReferenceInspection; +import org.jetbrains.annotations.NotNull; + +@SdkAware +public class GoAddStructFieldQuickFixTest extends GoQuickFixTestBase { + + private static final String ADD_STRUCT_FIELD = "Add missing field"; + + @Override + protected void setUp() throws Exception { + super.setUp(); + myFixture.enableInspections(GoUnresolvedReferenceInspection.class); + } + + @NotNull + @Override + protected String getBasePath() { + return "quickfixes/add-struct-field"; + } + + public void testSimple() { doTest(ADD_STRUCT_FIELD); } + public void testWithoutElements() { doTest(ADD_STRUCT_FIELD); } + public void testWithoutAssignment() { doTest(ADD_STRUCT_FIELD); } + public void testBlank() { doTestNoFix(ADD_STRUCT_FIELD, true); } +} From 2558b51227de514d70886ae5f13fe9806473758e Mon Sep 17 00:00:00 2001 From: wannabe Date: Wed, 24 May 2017 15:59:09 +0300 Subject: [PATCH 2/2] Review marks --- .../unresolved/GoAddStructFieldFix.java | 76 +++++++++++++++---- .../GoUnresolvedReferenceInspection.java | 11 +-- src/com/goide/psi/impl/GoElementFactory.java | 7 +- .../add-struct-field/complexType-after.go | 12 +++ .../add-struct-field/complexType.go | 11 +++ .../withoutAssignment-after.go | 2 +- .../add-struct-field/withoutElements-after.go | 2 +- .../GoAddStructFieldQuickFixTest.java | 1 + 8 files changed, 91 insertions(+), 31 deletions(-) create mode 100644 testData/quickfixes/add-struct-field/complexType-after.go create mode 100644 testData/quickfixes/add-struct-field/complexType.go diff --git a/src/com/goide/inspections/unresolved/GoAddStructFieldFix.java b/src/com/goide/inspections/unresolved/GoAddStructFieldFix.java index d5c0f43836..04ad5f6152 100644 --- a/src/com/goide/inspections/unresolved/GoAddStructFieldFix.java +++ b/src/com/goide/inspections/unresolved/GoAddStructFieldFix.java @@ -16,29 +16,32 @@ package com.goide.inspections.unresolved; -import com.goide.psi.GoFieldDeclaration; -import com.goide.psi.GoStructType; -import com.goide.psi.impl.GoElementFactory; -import com.intellij.codeInspection.LocalQuickFixOnPsiElement; +import com.goide.GoConstants; +import com.goide.psi.*; +import com.goide.psi.impl.GoPsiImplUtil; +import com.goide.util.GoUtil; +import com.intellij.codeInsight.template.Template; +import com.intellij.codeInsight.template.TemplateManager; +import com.intellij.codeInsight.template.impl.ConstantNode; +import com.intellij.codeInspection.LocalQuickFixAndIntentionActionOnPsiElement; +import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; +import com.intellij.psi.util.PsiTreeUtil; import com.intellij.util.ObjectUtils; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.List; -public class GoAddStructFieldFix extends LocalQuickFixOnPsiElement { +public class GoAddStructFieldFix extends LocalQuickFixAndIntentionActionOnPsiElement { public static final String QUICK_FIX_NAME = "Add missing field"; - private final String myFieldText; - private final String myTypeText; - protected GoAddStructFieldFix(String fieldText, String typeText, @NotNull GoStructType element) { + protected GoAddStructFieldFix(@NotNull PsiElement element) { super(element); - myFieldText = fieldText; - myTypeText = typeText; } @NotNull @@ -48,12 +51,59 @@ public String getText() { } @Override - public void invoke(@NotNull Project project, @NotNull PsiFile file, @NotNull PsiElement startElement, @NotNull PsiElement endElement) { - GoStructType structType = ObjectUtils.tryCast(startElement, GoStructType.class); + public void invoke(@NotNull Project project, + @NotNull PsiFile file, + @Nullable Editor editor, + @NotNull PsiElement startElement, + @NotNull PsiElement endElement) { + if (editor == null) return; + GoReferenceExpression referenceExpression = ObjectUtils.tryCast(startElement, GoReferenceExpression.class); + GoStructType structType = referenceExpression != null ? resolveStructType(referenceExpression) : null; if (structType == null) return; + List declarations = structType.getFieldDeclarationList(); PsiElement anchor = !declarations.isEmpty() ? ContainerUtil.getLastItem(declarations) : structType.getLbrace(); - if (anchor != null) structType.addAfter(GoElementFactory.createFieldDeclaration(project, myFieldText, myTypeText), anchor); + if (anchor == null) return; + + startTemplate(project, editor, file, referenceExpression, anchor); + } + + private static void startTemplate(@NotNull Project project, + @NotNull Editor editor, + @NotNull PsiFile file, + GoReferenceExpression referenceExpression, + PsiElement anchor) { + Template template = TemplateManager.getInstance(project).createTemplate("", ""); + template.addTextSegment(referenceExpression.getReference().getCanonicalText() + " "); + template.addVariable(new ConstantNode(getTypeName(referenceExpression, file)), true); + template.addTextSegment("\n"); + editor.getCaretModel().moveToOffset(anchor.getTextRange().getEndOffset() + 1); + template.setToReformat(true); + TemplateManager.getInstance(project).startTemplate(editor, template); + } + + + private static String getTypeName(GoReferenceExpression referenceExpression, PsiFile file) { + GoAssignmentStatement assignment = PsiTreeUtil.getParentOfType(referenceExpression, GoAssignmentStatement.class); + if (assignment == null) return GoConstants.INTERFACE_TYPE; + GoExpression expression = GoPsiImplUtil.getRightExpression(assignment, referenceExpression); + GoType type = expression != null ? expression.getGoType(null) : null; + + if (type instanceof GoSpecType) { + GoSpecType spec = (GoSpecType)type; + GoFile typeFile = ObjectUtils.tryCast(spec.getContainingFile(), GoFile.class); + if (typeFile != null && (file.isEquivalentTo(typeFile) || GoUtil.inSamePackage(typeFile, file))) { + return spec.getIdentifier().getText(); + } + } + return type != null ? GoPsiImplUtil.getText(type) : GoConstants.INTERFACE_TYPE; + } + + @Nullable + private static GoStructType resolveStructType(@NotNull GoReferenceExpression referenceExpression) { + GoReferenceExpression qualifier = referenceExpression.getQualifier(); + GoSpecType type = qualifier != null ? ObjectUtils.tryCast(qualifier.getGoType(null), GoSpecType.class) : null; + return type != null ? ObjectUtils.tryCast(type.getType(), GoStructType.class) : null; } @Nls diff --git a/src/com/goide/inspections/unresolved/GoUnresolvedReferenceInspection.java b/src/com/goide/inspections/unresolved/GoUnresolvedReferenceInspection.java index 6ce4d2e6a5..1d9733f877 100644 --- a/src/com/goide/inspections/unresolved/GoUnresolvedReferenceInspection.java +++ b/src/com/goide/inspections/unresolved/GoUnresolvedReferenceInspection.java @@ -20,7 +20,6 @@ import com.goide.codeInsight.imports.GoImportPackageQuickFix; import com.goide.inspections.GoInspectionBase; import com.goide.psi.*; -import com.goide.psi.impl.GoPsiImplUtil; import com.goide.psi.impl.GoReference; import com.intellij.codeInsight.highlighting.ReadWriteAccessDetector; import com.intellij.codeInspection.LocalInspectionToolSession; @@ -79,7 +78,7 @@ else if (reference.resolve() == null) { GoType type = qualifier != null ? qualifier.getGoType(null) : null; GoStructType structType = type != null ? ObjectUtils.tryCast(type.getUnderlyingType(), GoStructType.class) : null; if (!"_".equals(reference.getCanonicalText()) && structType != null) { - fixes = new LocalQuickFix[]{new GoAddStructFieldFix(reference.getCanonicalText(), getTypeName(o), structType)}; + fixes = new LocalQuickFix[]{new GoAddStructFieldFix(o)}; } else if (isProhibited(o, qualifier)) { fixes = createImportPackageFixes(o, reference, holder.isOnTheFly()); @@ -166,14 +165,6 @@ else if (holder.isOnTheFly()) { }; } - private static String getTypeName(GoReferenceExpression referenceExpression) { - GoAssignmentStatement assignment = PsiTreeUtil.getParentOfType(referenceExpression, GoAssignmentStatement.class); - if (assignment == null) return "interface {}"; - GoExpression expression = GoPsiImplUtil.getRightExpression(assignment, referenceExpression); - GoType type = expression != null ? expression.getGoType(null) : null; - return type != null ? type.getText() : "interface {}"; - } - @NotNull private static LocalQuickFix[] createImportPackageFixes(@NotNull PsiElement target, @NotNull PsiReference reference, boolean onTheFly) { if (onTheFly) { diff --git a/src/com/goide/psi/impl/GoElementFactory.java b/src/com/goide/psi/impl/GoElementFactory.java index 7f8674e9b0..fb523fa240 100644 --- a/src/com/goide/psi/impl/GoElementFactory.java +++ b/src/com/goide/psi/impl/GoElementFactory.java @@ -191,7 +191,7 @@ public static GoGoStatement createGoStatement(@NotNull Project project, @NotNull @NotNull public static GoForStatement createForStatement(@NotNull Project project, @NotNull String text) { - GoFile file = createFileFromText(project, "package a; func a() {\n for {\n" + text + "\n}\n}"); + GoFile file = createFileFromText(project, "package a; func a() {\n for {\n" + text + "\n}\n}"); return PsiTreeUtil.findChildOfType(file, GoForStatement.class); } @@ -266,9 +266,4 @@ public static GoTypeDeclaration createTypeDeclaration(@NotNull Project project, GoFile file = createFileFromText(project, "package a; type " + name + " " + type.getText()); return PsiTreeUtil.findChildOfType(file, GoTypeDeclaration.class); } - - public static GoFieldDeclaration createFieldDeclaration(@NotNull Project project, @NotNull String fieldText, @NotNull String typeText) { - GoFile file = createFileFromText(project, "package a; var _ = struct { " + fieldText + " " + typeText + " }"); - return PsiTreeUtil.findChildOfType(file, GoFieldDeclaration.class); - } } \ No newline at end of file diff --git a/testData/quickfixes/add-struct-field/complexType-after.go b/testData/quickfixes/add-struct-field/complexType-after.go new file mode 100644 index 0000000000..e40003bb7e --- /dev/null +++ b/testData/quickfixes/add-struct-field/complexType-after.go @@ -0,0 +1,12 @@ +package main + +type S struct { + bb interface{} + cc interface{} + aa S +} + +func main() { + s := S{} + s.aa = S{} +} \ No newline at end of file diff --git a/testData/quickfixes/add-struct-field/complexType.go b/testData/quickfixes/add-struct-field/complexType.go new file mode 100644 index 0000000000..c64e00f996 --- /dev/null +++ b/testData/quickfixes/add-struct-field/complexType.go @@ -0,0 +1,11 @@ +package main + +type S struct { + bb interface{} + cc interface{} +} + +func main() { + s := S{} + s.aa = S{} +} \ No newline at end of file diff --git a/testData/quickfixes/add-struct-field/withoutAssignment-after.go b/testData/quickfixes/add-struct-field/withoutAssignment-after.go index 303410b80a..914ac78545 100644 --- a/testData/quickfixes/add-struct-field/withoutAssignment-after.go +++ b/testData/quickfixes/add-struct-field/withoutAssignment-after.go @@ -8,5 +8,5 @@ type S struct { func main() { s := S{} - s.aa + s.aa } \ No newline at end of file diff --git a/testData/quickfixes/add-struct-field/withoutElements-after.go b/testData/quickfixes/add-struct-field/withoutElements-after.go index 524df589df..b5143a161c 100644 --- a/testData/quickfixes/add-struct-field/withoutElements-after.go +++ b/testData/quickfixes/add-struct-field/withoutElements-after.go @@ -6,5 +6,5 @@ type S struct { func main() { s := S{} - s.aa = "aa" + s.aa = "aa" } \ No newline at end of file diff --git a/tests/com/goide/quickfix/GoAddStructFieldQuickFixTest.java b/tests/com/goide/quickfix/GoAddStructFieldQuickFixTest.java index ec251decf3..2cbd260e29 100644 --- a/tests/com/goide/quickfix/GoAddStructFieldQuickFixTest.java +++ b/tests/com/goide/quickfix/GoAddStructFieldQuickFixTest.java @@ -39,6 +39,7 @@ protected String getBasePath() { public void testSimple() { doTest(ADD_STRUCT_FIELD); } public void testWithoutElements() { doTest(ADD_STRUCT_FIELD); } + public void testComplexType() { doTest(ADD_STRUCT_FIELD); } public void testWithoutAssignment() { doTest(ADD_STRUCT_FIELD); } public void testBlank() { doTestNoFix(ADD_STRUCT_FIELD, true); } }