Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 3 commits
  • 4 files changed
  • 0 comments
  • 1 contributor
Jul 28, 2012
Mihai Claudiu Toader mtoader Merge pull request #85 from catalinc/master
Fix failing tests under Windows.

Use the proper file separator.
c618e22
Mihai Claudiu Toader mtoader Bumped the version number / updated the log in preparation for next r…
…elease.

Signed-off-by: Mihai Claudiu Toader <mtoader@gmail.com>
6fda309
Mihai Claudiu Toader mtoader Correctly implement the type evalution for index expressions.
Added proper GoTypeMap abstraction.

Signed-off-by: Mihai Claudiu Toader <mtoader@gmail.com>
4ec52b6
43 src/META-INF/plugin.xml
... ... @@ -1,7 +1,7 @@
1 1 <idea-plugin version="2" url="http://github.com/mtoader/google-go-lang-idea-plugin">
2 2 <id>ro.redeul.google.go</id>
3 3 <name>Google Go language</name>
4   - <version>0.7.1</version>
  4 + <version>0.9.0</version>
5 5 <vendor email="mtoader@gmail.com" url="http://redeul.ro">mtoader@gmail.com</vendor>
6 6 <description>
7 7 <![CDATA[
@@ -10,42 +10,47 @@
10 10
11 11 <ul>
12 12 <li>Basic language parsing and highlighting</li>
13   - <li>Code folding</li>
14   - <li>Brace matching</li>
  13 + <li>Code folding and Brace matching</li>
15 14 <li>Comment/Uncomment (Single/Multiple line) support</li>
16   - <li>Go SDK (work with the latest release and on windows)</li>
17   - <li>File type icon</li>
18 15 <li>Go application file and library generation.</li>
19 16 <li>Auto completion of sdk package names and/or local application packages.</li>
20 17 <li>Compilation of the go applications (supported semantics are similar to those of gobuild)</li>
21   - <li>Go To definition (for types) works across files and Go SDK</li>
22   - <li>gofmt based Code formatting - (only when called with Ctrl + Alt + L)</li>
23   - <li>Type name completion and resolution</li>
24   - <li>Function name completion</li>
  18 + <li>Native plugin code formatter</li>
25 19 <li>GoTo class (go types) implementation</li>
26 20 <li>ColorsAndSettings page with a new color scheme</li>
  21 + <li>Completion/Resolution of vars/types/functions/structs/methods (works across some expression chains).</li>
  22 + <li>Refactorings: Introduce variable/constant</li>
  23 + <li>Inspections: Unused imports/variables/constants/parameters/symbols</li>
  24 + <li>Inspections: Validate the format param for the fmt.Print suite of functions</li>
  25 + <li>Intentions: Invert if condition/Merge nested 'if's/Split into 2 'if's/Convert switch statement to if chain.</li>
  26 + <li>Intentions: Convert between interpreted string and raw string.</li>
  27 + <li>Intention: Add/Remove parentheses.</li>
  28 + <li>Intention: Move simple statement out.</li>
  29 + <li>Documentation for functions, methods, variable, constants and types.</li>
  30 + <li>Function parameter information.</li>
  31 + <li>Ctrl+Shift+T to jump between source file and test file.</li>
  32 + <li>Navigation from stack trace in output panel.</li>
  33 + <li>Ctrl+Shift+Enter to add curly brackets for "func", "if" and "for" statements.</li>
  34 + <li>Live templates: "sout", "souf", "soutm" and "soutp".</li>
  35 + <li>Go aware imports optimizer and auto import generator</li>
  36 + <li>Import usage highlighting (and detecting of wrong imports)</li>
  37 + <li>Better Structure view</li>
27 38 <li>Automatically add new line at end of file</li>
28 39 <li>Force UTF-8 encoding for go files</li>
29   - <li>Go module type</li>
30   - <li>Go SDK indexing mode</li>
31   - <li>Makefile based build system (bring your own Makefile). Experimental. Configured in project settings.</li>
32   - <li>Completion / resolution of vars/types/functions/struct members/etc.</li>
33   - <li>Simple structure view</li>
34   - <li>Go aware imports optimizer (experimental)</li>
35   - <li>Support GO sdk as packaged by the gophers/go PPA on Ubuntu. (supports Go 1 release)</li>
36   - <li>Partial error highlighting of non existent imported packages.</li>
37 40 <li>Detection of bundled Go Sdk packages (useful when deployed as GoIde)</li>
38 41 <li>Run configuration creator (right click on a program file and you can run it). </li>
39   - <li>Run configuration validation.</li>
  42 + <li>Go SDK (Go 1.0 on linux/mac/windows)</li>
  43 + <li>Go module type</li>
40 44 <li>Go App engine sdk type</li>
41 45 <li>Go App engine credentials safe storage</li>
42 46 <li>Added go application wizard</li>
  47 + <li>Makefile based build system (bring your own Makefile). Experimental. Configured in project settings.</li>
43 48 </ul>
44 49 ]]>
45 50 </description>
46 51 <change-notes>
47 52 <![CDATA[
48   - <h3>0.7.1 changes:</h3>
  53 + <h3>0.9.0 changes:</h3>
49 54 <ul>
50 55 <li>[feature] Refactoring: Introduce variable.</li>
51 56 <li>[feature] Refactoring: Introduce constant.</li>
44 src/ro/redeul/google/go/lang/psi/impl/expressions/primary/GoIndexExpressionImpl.java
@@ -6,15 +6,19 @@
6 6 import ro.redeul.google.go.lang.psi.expressions.GoPrimaryExpression;
7 7 import ro.redeul.google.go.lang.psi.expressions.primary.GoIndexExpression;
8 8 import ro.redeul.google.go.lang.psi.impl.expressions.GoExpressionBase;
  9 +import ro.redeul.google.go.lang.psi.types.underlying.GoUnderlyingType;
  10 +import ro.redeul.google.go.lang.psi.types.underlying.GoUnderlyingTypeArray;
  11 +import ro.redeul.google.go.lang.psi.types.underlying.GoUnderlyingTypeMap;
  12 +import ro.redeul.google.go.lang.psi.types.underlying.GoUnderlyingTypeSlice;
9 13 import ro.redeul.google.go.lang.psi.typing.GoType;
10 14 import ro.redeul.google.go.lang.psi.typing.GoTypeArray;
11 15 import ro.redeul.google.go.lang.psi.typing.GoTypeMap;
12 16 import ro.redeul.google.go.lang.psi.typing.GoTypeSlice;
  17 +import ro.redeul.google.go.lang.psi.typing.GoTypes;
13 18 import ro.redeul.google.go.lang.psi.visitors.GoElementVisitor;
14 19
15 20 public class GoIndexExpressionImpl extends GoExpressionBase
16   - implements GoIndexExpression
17   -{
  21 + implements GoIndexExpression {
18 22 public GoIndexExpressionImpl(@NotNull ASTNode node) {
19 23 super(node);
20 24 }
@@ -27,19 +31,37 @@ public GoIndexExpressionImpl(@NotNull ASTNode node) {
27 31 return GoType.EMPTY_ARRAY;
28 32
29 33 GoType baseType = baseTypes[0];
30   - if (baseType instanceof GoTypeSlice) {
31   - GoTypeSlice slice = (GoTypeSlice) baseType;
32   - return new GoType[] { slice.getElementType() };
  34 + GoUnderlyingType underlyingType = baseType.getUnderlyingType();
  35 +
  36 + if (underlyingType instanceof GoUnderlyingTypeSlice) {
  37 + GoTypeSlice slice =
  38 + GoTypes.resolveTo(baseType, GoTypeSlice.class);
  39 +
  40 + if (slice == null)
  41 + return GoType.EMPTY_ARRAY;
  42 +
  43 + return new GoType[]{slice.getElementType()};
33 44 }
34 45
35   - if (baseType instanceof GoTypeArray) {
36   - GoTypeArray array = (GoTypeArray) baseType;
37   - return new GoType[] { array.getElementType() };
  46 + if (underlyingType instanceof GoUnderlyingTypeArray) {
  47 + GoTypeArray typeArray =
  48 + GoTypes.resolveTo(baseType, GoTypeArray.class);
  49 +
  50 + if (typeArray == null)
  51 + return GoType.EMPTY_ARRAY;
  52 +
  53 + return new GoType[]{typeArray.getElementType()};
38 54 }
39 55
40   - if (baseType instanceof GoTypeMap) {
41   - GoTypeMap map = (GoTypeMap) baseType;
42   - return new GoType[] { map.getElementType() };
  56 + if (underlyingType instanceof GoUnderlyingTypeMap) {
  57 + GoTypeMap map =
  58 + GoTypes.resolveTo(baseType, GoTypeMap.class);
  59 +
  60 + if (map == null) {
  61 + return GoType.EMPTY_ARRAY;
  62 + }
  63 +
  64 + return new GoType[]{map.getElementType()};
43 65 }
44 66
45 67 // TODO: implement the case when the base has type string.
19 src/ro/redeul/google/go/lang/psi/typing/GoTypeMap.java
... ... @@ -1,7 +1,6 @@
1 1 package ro.redeul.google.go.lang.psi.typing;
2 2
3 3 import ro.redeul.google.go.lang.psi.types.GoPsiTypeMap;
4   -import ro.redeul.google.go.lang.psi.types.underlying.GoUnderlyingType;
5 4 import ro.redeul.google.go.lang.psi.types.underlying.GoUnderlyingTypeMap;
6 5 import ro.redeul.google.go.lang.psi.types.underlying.GoUnderlyingTypes;
7 6
@@ -12,11 +11,19 @@
12 11 extends GoTypePsiBacked<GoPsiTypeMap, GoUnderlyingTypeMap>
13 12 implements GoType {
14 13
  14 + GoType keyType;
  15 + GoType elementType;
  16 +
15 17 public GoTypeMap(GoPsiTypeMap type) {
16 18 super(type);
  19 +
  20 + keyType = GoTypes.fromPsiType(type.getKeyType());
  21 + elementType = GoTypes.fromPsiType(type.getElementType());
  22 +
17 23 setUnderlyingType(
18   - GoUnderlyingTypes.getMap(GoUnderlyingType.Undefined,
19   - GoUnderlyingType.Undefined));
  24 + GoUnderlyingTypes.getMap(keyType.getUnderlyingType(),
  25 + elementType.getUnderlyingType()));
  26 +
20 27 }
21 28
22 29 @Override
@@ -24,7 +31,11 @@ public boolean isIdentical(GoType type) {
24 31 return false; //To change body of implemented methods use File | Settings | File Templates.
25 32 }
26 33
  34 + public GoType getKeyType() {
  35 + return keyType;
  36 + }
  37 +
27 38 public GoType getElementType() {
28   - return GoType.Unknown;
  39 + return elementType;
29 40 }
30 41 }
18 src/ro/redeul/google/go/lang/psi/typing/GoTypes.java
@@ -13,6 +13,7 @@
13 13 import ro.redeul.google.go.lang.psi.types.GoPsiTypeArray;
14 14 import ro.redeul.google.go.lang.psi.types.GoPsiTypeFunction;
15 15 import ro.redeul.google.go.lang.psi.types.GoPsiTypeInterface;
  16 +import ro.redeul.google.go.lang.psi.types.GoPsiTypeMap;
16 17 import ro.redeul.google.go.lang.psi.types.GoPsiTypeName;
17 18 import ro.redeul.google.go.lang.psi.types.GoPsiTypePointer;
18 19 import ro.redeul.google.go.lang.psi.types.GoPsiTypeSlice;
@@ -29,6 +30,18 @@
29 30 "float(32|64)|" +
30 31 "complex(64|128)");
31 32
  33 + public static <T extends GoType> T resolveTo(GoType type, Class<T> targetType) {
  34 + while ( type != null && type != GoType.Unknown && ! targetType.isAssignableFrom(type.getClass()) ) {
  35 + if ( type instanceof GoTypeName ) {
  36 + type = ((GoTypeName)type).getDefinition();
  37 + } else {
  38 + type = GoType.Unknown;
  39 + }
  40 + }
  41 +
  42 + return targetType.cast(type);
  43 + }
  44 +
32 45 public enum Builtin {
33 46 Bool, Byte, Complex64, Complex128, Error, Float32, Float64,
34 47 Int, Int8, Int16, Int32, Int64, Rune, String,
@@ -91,6 +104,11 @@ public void visitTypeName(GoPsiTypeName psiTypeName) {
91 104 }
92 105
93 106 @Override
  107 + public void visitMapType(GoPsiTypeMap type) {
  108 + data = new GoTypeMap(type);
  109 + }
  110 +
  111 + @Override
94 112 public void visitSliceType(GoPsiTypeSlice psiType) {
95 113 data = new GoTypeSlice(psiType);
96 114 }

No commit comments for this range

Something went wrong with that request. Please try again.