Skip to content

Commit 466254b

Browse files
authored
Merge pull request #70 from Tbusk/patch/attributes
patch: update parser for attributes to handle more complex usages
2 parents 10989b5 + 973c789 commit 466254b

File tree

10 files changed

+103
-22
lines changed

10 files changed

+103
-22
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ body:
3838
label: Version
3939
description: What version of the plugin are you using?
4040
options:
41-
- Latest
41+
- Latest (if not added)
42+
- 1.2.1-ALPHA
4243
- 1.2.0-ALPHA
4344
- 1.1.3-ALPHA
4445
- 1.1.2-ALPHA

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66

77
### What's Changed
88

9+
- Added keyword highlighting for delegate
10+
- Patched indentation for errordomain and attribute pairing.
11+
- Updated parser to permit multiple identifiers / arguments rather than
12+
a single one per attribute
13+
14+
## [1.2.0-ALPHA]
15+
16+
### What's Changed
917
- Added new Vala project wizard to Java-based IDEs
1018
- Added new Vala project wizard with Meson to Java-based IDEs
1119
- Added new Vala project wizard to non-Java-based IDEs

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pluginGroup = com.tbusk.vala_plugin
44
pluginName = Vala Language
55
pluginRepositoryUrl = https://github.com/Tbusk/vala-jetbrains-plugin
66
# SemVer format -> https://semver.org
7-
pluginVersion=1.2.0-ALPHA
7+
pluginVersion=1.2.1-ALPHA
88

99
# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
1010
pluginSinceBuild = 251

src/main/gen/com/tbusk/vala_plugin/ValaParser.java

Lines changed: 38 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/gen/com/tbusk/vala_plugin/psi/ValaAttribute.java

Lines changed: 1 addition & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/gen/com/tbusk/vala_plugin/psi/impl/ValaAttributeImpl.java

Lines changed: 2 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/java/com/tbusk/vala_plugin/ValaTokenSets.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ public interface ValaTokenSets {
125125
ValaTypes.PREPROCESSOR_ELIF,
126126
ValaTypes.PREPROCESSOR_ELSE,
127127
ValaTypes.PREPROCESSOR_ENDIF,
128-
ValaTypes.INLINE
128+
ValaTypes.INLINE,
129+
ValaTypes.DELEGATE
129130
);
130131
}

src/main/java/com/tbusk/vala_plugin/code_style/ValaBlock.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ private Indent calculateChildIndent(ASTNode child) {
9696
IElementType parentType = myNode.getElementType();
9797
IElementType childType = child.getElementType();
9898

99+
if ((parentType == ValaTypes.CLASS_MEMBER ||
100+
parentType == ValaTypes.NAMESPACE_MEMBER ||
101+
parentType == ValaTypes.INTERFACE_MEMBER ||
102+
parentType == ValaTypes.STRUCT_MEMBER) && (myNode.findChildByType(ValaTypes.ATTRIBUTES) != null || myNode.findChildByType(ValaTypes.ATTRIBUTE) != null)) {
103+
return Indent.getNoneIndent();
104+
}
105+
99106
if (parentType == ValaTypes.PREPROCESSOR_DIRECTIVE || childType == ValaTypes.PREPROCESSOR_DIRECTIVE) {
100107
return Indent.getAbsoluteNoneIndent();
101108
}
@@ -108,7 +115,7 @@ private Indent calculateChildIndent(ASTNode child) {
108115
return Indent.getNormalIndent();
109116
}
110117

111-
if (parentType == ValaTypes.ERRORDOMAIN_DECLARATION && (childType != ValaTypes.SEMICOLON && childType != ValaTypes.RBRACE)) {
118+
if (parentType == ValaTypes.ERRORDOMAIN_DECLARATION && (childType == ValaTypes.ERRORCODES || childType == ValaTypes.METHOD_DECLARATION)) {
112119
return Indent.getNormalIndent();
113120
}
114121

@@ -128,10 +135,6 @@ private Indent calculateChildIndent(ASTNode child) {
128135
return Indent.getNormalIndent();
129136
}
130137

131-
if ((parentType == ValaTypes.CLASS_MEMBER || parentType == ValaTypes.NAMESPACE_MEMBER || parentType == ValaTypes.INTERFACE_MEMBER) && myNode.findChildByType(ValaTypes.ATTRIBUTES) != null) {
132-
return Indent.getNoneIndent();
133-
}
134-
135138
if (parentType == ValaTypes.ENUM_DECLARATION &&
136139
(
137140
childType == ValaTypes.METHOD_DECLARATION ||

src/main/java/com/tbusk/vala_plugin/syntax/Vala.bnf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ namespace_member ::= [ attributes ]
114114

115115
attributes ::= attribute*
116116

117-
attribute ::= LBRACKET IDENTIFIER [ attribute_arguments ] RBRACKET
117+
attribute ::= LBRACKET IDENTIFIER [ attribute_arguments ] [ (COMMA IDENTIFIER [ attribute_arguments ])* ] RBRACKET
118118

119119
attribute_arguments ::= LPAREN attribute_argument [ (COMMA attribute_argument)* ] RPAREN
120120

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
[Flags, CCode (cname = "int", cprefix = "SDL_INIT_", has_type_id = false)]
2+
public enum InitFlags {
3+
AUDIO,
4+
VIDEO,
5+
JOYSTICK,
6+
HAPTIC,
7+
GAMEPAD,
8+
EVENTS,
9+
SENSOR,
10+
CAMERA
11+
}
12+
13+
[Diagnostics, SimpleType, CCode (cname = "cname_property", has_type_id = false)]
14+
public class BeforeNamespaceAttributeClass {
15+
16+
}
17+
18+
[CCode (cname = "cname_property", has_type_id = false), Diagnostics, SimpleType]
19+
public struct PropertiesID : uint32 {}
20+
21+
[Diagnostics, CCode (cname = "cname_property", has_type_id = false), SimpleType]
22+
public virtual delegate uint TestDelegate ();
23+
24+
[Diagnostics, PrintfFormat]
25+
public errordomain decl {
26+
ERROR;
27+
}
28+
29+
[Diagnostics, PrintfFormat]
30+
const uint CONSTANT = 1;
31+
32+
[SimpleType, CCode (cname = "SDL_PropertiesID", has_type_id = false)]
33+
public uint get_enums () {
34+
return 1u;
35+
}
36+
37+
[SimpleType, CCode (cname = "SDL_PropertiesID", has_type_id = false)]
38+
public interface TestInterface {
39+
40+
}

0 commit comments

Comments
 (0)