Skip to content

Commit 1b82f95

Browse files
committed
Added some functionality back in and updated unit tests
1 parent c87d18a commit 1b82f95

File tree

5 files changed

+14
-6
lines changed

5 files changed

+14
-6
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ allprojects {
3939
}
4040
test {
4141
java.srcDir 'src/test/java'
42+
resources.srcDirs 'src/main/resources'
4243
}
4344
}
4445

src/main/java/com/notzippy/intellij/go/intellij/highlighting/GoAnnotator.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import com.notzippy.intellij.go.grammar.psi.*;
2020
import com.notzippy.intellij.go.intellij.GoConstants;
21+
import com.notzippy.intellij.go.intellij.quickfix.GoEmptySignatureQuickFix;
2122
import com.notzippy.intellij.go.parser.GoTypes;
2223
import com.notzippy.intellij.go.grammar.psi.impl.GoCType;
2324
import com.notzippy.intellij.go.grammar.psi.impl.GoPsiImplUtil;
@@ -185,11 +186,13 @@ else if (element instanceof GoFunctionDeclaration) {
185186
if (result != null && !result.isVoid()) {
186187
Annotation annotation = holder.createErrorAnnotation(result, declaration.getName() +
187188
" function must have no arguments and no return values");
189+
annotation.registerFix(new GoEmptySignatureQuickFix(declaration));
188190
}
189191
GoParameters parameters = signature.getParameters();
190192
if (!parameters.getParameterDeclarationList().isEmpty()) {
191193
Annotation annotation = holder.createErrorAnnotation(parameters, declaration.getName() +
192194
" function must have no arguments and no return values");
195+
annotation.registerFix(new GoEmptySignatureQuickFix(declaration));
193196
}
194197
}
195198
}

src/main/java/com/notzippy/intellij/go/intellij/intentions/GoMoveToStructInitializationIntention.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,13 @@ public String getFamilyName() {
5353

5454
@Override
5555
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
56-
return getData(element) != null;
56+
boolean available = getData(element) != null;
57+
return available;
5758
}
5859

5960
@Nullable
6061
private static Data getData(@NotNull PsiElement element) {
61-
if (!element.isValid() || !element.isWritable()) return null;
62+
if (!element.isValid()) return null; // removed || !element.isWritable())
6263
GoAssignmentStatement assignment = getValidAssignmentParent(element);
6364
GoReferenceExpression selectedFieldReference = assignment != null ? getFieldReferenceExpression(element, assignment) : null;
6465
GoCompositeLit compositeLit = selectedFieldReference != null ? getStructLiteralByReference(selectedFieldReference, assignment) : null;
@@ -71,6 +72,9 @@ private static Data getData(@NotNull PsiElement element) {
7172
@Nullable
7273
private static GoAssignmentStatement getValidAssignmentParent(@Nullable PsiElement element) {
7374
GoAssignmentStatement assignment = PsiTreeUtil.getNonStrictParentOfType(element, GoAssignmentStatement.class);
75+
if (assignment == null) {
76+
assignment = PsiTreeUtil.getNonStrictParentOfType(element.getPrevSibling(), GoAssignmentStatement.class);
77+
}
7478
return assignment != null && assignment.isValid() && getLeftHandElements(assignment).size() == assignment.getExpressionList().size()
7579
? assignment : null;
7680
}

src/main/java/com/notzippy/intellij/go/intellij/quickfix/GoEmptySignatureQuickFix.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616

1717
package com.notzippy.intellij.go.intellij.quickfix;
1818

19-
import com.notzippy.intellij.go.grammar.psi.GoFunctionDeclaration;
20-
import com.notzippy.intellij.go.grammar.psi.GoSignature;
21-
import com.notzippy.intellij.go.grammar.psi.impl.GoElementFactory;
2219
import com.intellij.codeInspection.LocalQuickFixAndIntentionActionOnPsiElement;
2320
import com.intellij.openapi.editor.Editor;
2421
import com.intellij.openapi.project.Project;
2522
import com.intellij.psi.PsiElement;
2623
import com.intellij.psi.PsiFile;
2724
import com.intellij.util.ObjectUtils;
25+
import com.notzippy.intellij.go.grammar.psi.GoFunctionDeclaration;
26+
import com.notzippy.intellij.go.grammar.psi.GoSignature;
27+
import com.notzippy.intellij.go.grammar.psi.impl.GoElementFactory;
2828
import org.jetbrains.annotations.Nls;
2929
import org.jetbrains.annotations.NotNull;
3030
import org.jetbrains.annotations.Nullable;

src/test/java/com/notzippy/intellij/go/intellij/stubs/GoPackageClauseStubTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public void tryClosure() {
4343
}
4444
catch (AssertionError e) {
4545
String message = e.getMessage();
46-
assertTrue(message.contains("Access to tree elements not allowed in tests"));
46+
assertTrue(message.contains("Access to tree elements not allowed"));
4747
assertTrue(message.contains("bar.go"));
4848
throw e;
4949
}

0 commit comments

Comments
 (0)