diff --git a/gen/com/github/kornilova203/matlab/MatlabParser.java b/gen/com/github/kornilova203/matlab/MatlabParser.java index a6f4f8d..d01ec03 100644 --- a/gen/com/github/kornilova203/matlab/MatlabParser.java +++ b/gen/com/github/kornilova203/matlab/MatlabParser.java @@ -790,6 +790,17 @@ private static boolean class_declaration_9(PsiBuilder b, int l) { return true; } + /* ********************************************************** */ + // ref_expr + public static boolean class_name(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "class_name")) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, CLASS_NAME, ""); + r = ref_expr(b, l + 1); + exit_section_(b, l, m, r, false, null); + return r; + } + /* ********************************************************** */ // <>>> (br* ',' br* <>>>)* static boolean comma_list(PsiBuilder b, int l, Parser _item) { @@ -877,6 +888,30 @@ public static boolean condition(PsiBuilder b, int l) { return r; } + /* ********************************************************** */ + // expr + public static boolean default_value(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "default_value")) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, DEFAULT_VALUE, ""); + r = expr(b, l + 1, -1); + exit_section_(b, l, m, r, false, null); + return r; + } + + /* ********************************************************** */ + // INTEGER | ':' + public static boolean dimension(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "dimension")) return false; + if (!nextTokenIs(b, "", COLON, INTEGER)) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, DIMENSION, ""); + r = consumeToken(b, INTEGER); + if (!r) r = consumeToken(b, COLON); + exit_section_(b, l, m, r, false, null); + return r; + } + /* ********************************************************** */ // if_block // | switch_block @@ -1076,13 +1111,13 @@ private static boolean elseif_block_3(PsiBuilder b, int l) { /* ********************************************************** */ // ident arguments? - static boolean enum_item(PsiBuilder b, int l) { + public static boolean enum_item(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "enum_item")) return false; boolean r; - Marker m = enter_section_(b); + Marker m = enter_section_(b, l, _NONE_, ENUM_ITEM, ""); r = parseIdentifier(b, l + 1); r = r && enum_item_1(b, l + 1); - exit_section_(b, m, null, r); + exit_section_(b, l, m, r, false, null); return r; } @@ -1968,7 +2003,7 @@ private static boolean matrix_row_3(PsiBuilder b, int l) { /* ********************************************************** */ // methods_token br* attributes? NEWLINE* - // methods_block_body NEWLINE* + // methods_list NEWLINE* // end public static boolean methods_block(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "methods_block")) return false; @@ -1979,7 +2014,7 @@ public static boolean methods_block(PsiBuilder b, int l) { r = r && report_error_(b, methods_block_1(b, l + 1)); r = p && report_error_(b, methods_block_2(b, l + 1)) && r; r = p && report_error_(b, methods_block_3(b, l + 1)) && r; - r = p && report_error_(b, methods_block_body(b, l + 1)) && r; + r = p && report_error_(b, methods_list(b, l + 1)) && r; r = p && report_error_(b, methods_block_5(b, l + 1)) && r; r = p && consumeToken(b, END) && r; exit_section_(b, l, m, r, p, block_inside_class_recovery_parser_); @@ -2027,16 +2062,41 @@ private static boolean methods_block_5(PsiBuilder b, int l) { } /* ********************************************************** */ - // <> - static boolean methods_block_body(PsiBuilder b, int l) { - if (!recursion_guard_(b, l, "methods_block_body")) return false; + // (function_declaration NEWLINE*)* + public static boolean methods_list(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "methods_list")) return false; + Marker m = enter_section_(b, l, _NONE_, METHODS_LIST, ""); + while (true) { + int c = current_position_(b); + if (!methods_list_0(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "methods_list", c)) break; + } + exit_section_(b, l, m, true, false, block_inside_class_recovery_parser_); + return true; + } + + // function_declaration NEWLINE* + private static boolean methods_list_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "methods_list_0")) return false; boolean r; - Marker m = enter_section_(b, l, _NONE_); - r = block(b, l + 1, element_parser_); - exit_section_(b, l, m, r, false, block_inside_class_recovery_parser_); + Marker m = enter_section_(b); + r = function_declaration(b, l + 1); + r = r && methods_list_0_1(b, l + 1); + exit_section_(b, m, null, r); return r; } + // NEWLINE* + private static boolean methods_list_0_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "methods_list_0_1")) return false; + while (true) { + int c = current_position_(b); + if (!consumeToken(b, NEWLINE)) break; + if (!empty_element_parsed_guard_(b, "methods_list_0_1", c)) break; + } + return true; + } + /* ********************************************************** */ // <> static boolean methods_token(PsiBuilder b, int l) { @@ -2723,7 +2783,7 @@ private static boolean parfor_loop_range_0(PsiBuilder b, int l) { /* ********************************************************** */ // properties_token br* attributes? NEWLINE* - // properties_block_body NEWLINE* + // properties_list NEWLINE* // end public static boolean properties_block(PsiBuilder b, int l) { if (!recursion_guard_(b, l, "properties_block")) return false; @@ -2734,7 +2794,7 @@ public static boolean properties_block(PsiBuilder b, int l) { r = r && report_error_(b, properties_block_1(b, l + 1)); r = p && report_error_(b, properties_block_2(b, l + 1)) && r; r = p && report_error_(b, properties_block_3(b, l + 1)) && r; - r = p && report_error_(b, properties_block_body(b, l + 1)) && r; + r = p && report_error_(b, properties_list(b, l + 1)) && r; r = p && report_error_(b, properties_block_5(b, l + 1)) && r; r = p && consumeToken(b, END) && r; exit_section_(b, l, m, r, p, block_inside_class_recovery_parser_); @@ -2782,22 +2842,141 @@ private static boolean properties_block_5(PsiBuilder b, int l) { } /* ********************************************************** */ - // <> - static boolean properties_block_body(PsiBuilder b, int l) { - if (!recursion_guard_(b, l, "properties_block_body")) return false; + // (property NEWLINE*)* + public static boolean properties_list(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "properties_list")) return false; + Marker m = enter_section_(b, l, _NONE_, PROPERTIES_LIST, ""); + while (true) { + int c = current_position_(b); + if (!properties_list_0(b, l + 1)) break; + if (!empty_element_parsed_guard_(b, "properties_list", c)) break; + } + exit_section_(b, l, m, true, false, block_inside_class_recovery_parser_); + return true; + } + + // property NEWLINE* + private static boolean properties_list_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "properties_list_0")) return false; boolean r; - Marker m = enter_section_(b, l, _NONE_); - r = block(b, l + 1, element_parser_); - exit_section_(b, l, m, r, false, block_inside_class_recovery_parser_); + Marker m = enter_section_(b); + r = property(b, l + 1); + r = r && properties_list_0_1(b, l + 1); + exit_section_(b, m, null, r); return r; } + // NEWLINE* + private static boolean properties_list_0_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "properties_list_0_1")) return false; + while (true) { + int c = current_position_(b); + if (!consumeToken(b, NEWLINE)) break; + if (!empty_element_parsed_guard_(b, "properties_list_0_1", c)) break; + } + return true; + } + /* ********************************************************** */ // <> static boolean properties_token(PsiBuilder b, int l) { return parseIdentifierAsKeyword(b, l + 1, PROPERTIES); } + /* ********************************************************** */ + // ident property_size? class_name? property_validation_functions? ('=' default_value)? [ ';' ] + public static boolean property(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "property")) return false; + boolean r; + Marker m = enter_section_(b, l, _NONE_, PROPERTY, ""); + r = parseIdentifier(b, l + 1); + r = r && property_1(b, l + 1); + r = r && property_2(b, l + 1); + r = r && property_3(b, l + 1); + r = r && property_4(b, l + 1); + r = r && property_5(b, l + 1); + exit_section_(b, l, m, r, false, null); + return r; + } + + // property_size? + private static boolean property_1(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "property_1")) return false; + property_size(b, l + 1); + return true; + } + + // class_name? + private static boolean property_2(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "property_2")) return false; + class_name(b, l + 1); + return true; + } + + // property_validation_functions? + private static boolean property_3(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "property_3")) return false; + property_validation_functions(b, l + 1); + return true; + } + + // ('=' default_value)? + private static boolean property_4(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "property_4")) return false; + property_4_0(b, l + 1); + return true; + } + + // '=' default_value + private static boolean property_4_0(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "property_4_0")) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeToken(b, ASSIGN); + r = r && default_value(b, l + 1); + exit_section_(b, m, null, r); + return r; + } + + // [ ';' ] + private static boolean property_5(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "property_5")) return false; + consumeToken(b, SEMICOLON); + return true; + } + + /* ********************************************************** */ + // <> + public static boolean property_size(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "property_size")) return false; + if (!nextTokenIs(b, LPARENTH)) return false; + boolean r; + Marker m = enter_section_(b); + r = p_opt_list(b, l + 1, dimension_parser_); + exit_section_(b, m, PROPERTY_SIZE, r); + return r; + } + + /* ********************************************************** */ + // expr + static boolean property_validation_function(PsiBuilder b, int l) { + return expr(b, l + 1, -1); + } + + /* ********************************************************** */ + // '{' <> '}' + public static boolean property_validation_functions(PsiBuilder b, int l) { + if (!recursion_guard_(b, l, "property_validation_functions")) return false; + if (!nextTokenIs(b, LBRACE)) return false; + boolean r; + Marker m = enter_section_(b); + r = consumeToken(b, LBRACE); + r = r && comma_list(b, l + 1, property_validation_function_parser_); + r = r && consumeToken(b, RBRACE); + exit_section_(b, m, PROPERTY_VALIDATION_FUNCTIONS, r); + return r; + } + /* ********************************************************** */ // ident public static boolean ret_value(PsiBuilder b, int l) { @@ -4287,6 +4466,11 @@ public boolean parse(PsiBuilder b, int l) { return cell_array_row_recovery(b, l + 1); } }; + static final Parser dimension_parser_ = new Parser() { + public boolean parse(PsiBuilder b, int l) { + return dimension(b, l + 1); + } + }; static final Parser element_parser_ = new Parser() { public boolean parse(PsiBuilder b, int l) { return element(b, l + 1); @@ -4358,6 +4542,11 @@ public boolean parse(PsiBuilder b, int l) { return parameter(b, l + 1); } }; + static final Parser property_validation_function_parser_ = new Parser() { + public boolean parse(PsiBuilder b, int l) { + return property_validation_function(b, l + 1); + } + }; static final Parser ref_expr_parser_ = new Parser() { public boolean parse(PsiBuilder b, int l) { return ref_expr(b, l + 1); diff --git a/gen/com/github/kornilova203/matlab/psi/MatlabClassName.java b/gen/com/github/kornilova203/matlab/psi/MatlabClassName.java new file mode 100644 index 0000000..1da9767 --- /dev/null +++ b/gen/com/github/kornilova203/matlab/psi/MatlabClassName.java @@ -0,0 +1,13 @@ +// This is a generated file. Not intended for manual editing. +package com.github.kornilova203.matlab.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface MatlabClassName extends PsiElement { + + @NotNull + MatlabRefExpr getRefExpr(); + +} diff --git a/gen/com/github/kornilova203/matlab/psi/MatlabDefaultValue.java b/gen/com/github/kornilova203/matlab/psi/MatlabDefaultValue.java new file mode 100644 index 0000000..708160c --- /dev/null +++ b/gen/com/github/kornilova203/matlab/psi/MatlabDefaultValue.java @@ -0,0 +1,13 @@ +// This is a generated file. Not intended for manual editing. +package com.github.kornilova203.matlab.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface MatlabDefaultValue extends PsiElement { + + @NotNull + MatlabExpr getExpr(); + +} diff --git a/gen/com/github/kornilova203/matlab/psi/MatlabDimension.java b/gen/com/github/kornilova203/matlab/psi/MatlabDimension.java new file mode 100644 index 0000000..1b0b79b --- /dev/null +++ b/gen/com/github/kornilova203/matlab/psi/MatlabDimension.java @@ -0,0 +1,13 @@ +// This is a generated file. Not intended for manual editing. +package com.github.kornilova203.matlab.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface MatlabDimension extends PsiElement { + + @Nullable + PsiElement getInteger(); + +} diff --git a/gen/com/github/kornilova203/matlab/psi/MatlabEnumItem.java b/gen/com/github/kornilova203/matlab/psi/MatlabEnumItem.java new file mode 100644 index 0000000..540ab2f --- /dev/null +++ b/gen/com/github/kornilova203/matlab/psi/MatlabEnumItem.java @@ -0,0 +1,13 @@ +// This is a generated file. Not intended for manual editing. +package com.github.kornilova203.matlab.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface MatlabEnumItem extends PsiElement { + + @Nullable + MatlabArguments getArguments(); + +} diff --git a/gen/com/github/kornilova203/matlab/psi/MatlabEnumerationBlock.java b/gen/com/github/kornilova203/matlab/psi/MatlabEnumerationBlock.java index 3a58907..8863346 100644 --- a/gen/com/github/kornilova203/matlab/psi/MatlabEnumerationBlock.java +++ b/gen/com/github/kornilova203/matlab/psi/MatlabEnumerationBlock.java @@ -8,6 +8,6 @@ public interface MatlabEnumerationBlock extends PsiElement { @NotNull - List getArgumentsList(); + List getEnumItemList(); } diff --git a/gen/com/github/kornilova203/matlab/psi/MatlabMethodsBlock.java b/gen/com/github/kornilova203/matlab/psi/MatlabMethodsBlock.java index 5289583..ce88bf1 100644 --- a/gen/com/github/kornilova203/matlab/psi/MatlabMethodsBlock.java +++ b/gen/com/github/kornilova203/matlab/psi/MatlabMethodsBlock.java @@ -11,6 +11,6 @@ public interface MatlabMethodsBlock extends PsiElement { MatlabAttributes getAttributes(); @Nullable - MatlabBlock getBlock(); + MatlabMethodsList getMethodsList(); } diff --git a/gen/com/github/kornilova203/matlab/psi/MatlabMethodsList.java b/gen/com/github/kornilova203/matlab/psi/MatlabMethodsList.java new file mode 100644 index 0000000..85385e9 --- /dev/null +++ b/gen/com/github/kornilova203/matlab/psi/MatlabMethodsList.java @@ -0,0 +1,13 @@ +// This is a generated file. Not intended for manual editing. +package com.github.kornilova203.matlab.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface MatlabMethodsList extends PsiElement { + + @NotNull + List getFunctionDeclarationList(); + +} diff --git a/gen/com/github/kornilova203/matlab/psi/MatlabPropertiesBlock.java b/gen/com/github/kornilova203/matlab/psi/MatlabPropertiesBlock.java index e9a3b10..a5d1459 100644 --- a/gen/com/github/kornilova203/matlab/psi/MatlabPropertiesBlock.java +++ b/gen/com/github/kornilova203/matlab/psi/MatlabPropertiesBlock.java @@ -11,6 +11,6 @@ public interface MatlabPropertiesBlock extends PsiElement { MatlabAttributes getAttributes(); @Nullable - MatlabBlock getBlock(); + MatlabPropertiesList getPropertiesList(); } diff --git a/gen/com/github/kornilova203/matlab/psi/MatlabPropertiesList.java b/gen/com/github/kornilova203/matlab/psi/MatlabPropertiesList.java new file mode 100644 index 0000000..712856b --- /dev/null +++ b/gen/com/github/kornilova203/matlab/psi/MatlabPropertiesList.java @@ -0,0 +1,13 @@ +// This is a generated file. Not intended for manual editing. +package com.github.kornilova203.matlab.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface MatlabPropertiesList extends PsiElement { + + @NotNull + List getPropertyList(); + +} diff --git a/gen/com/github/kornilova203/matlab/psi/MatlabProperty.java b/gen/com/github/kornilova203/matlab/psi/MatlabProperty.java new file mode 100644 index 0000000..0d821fd --- /dev/null +++ b/gen/com/github/kornilova203/matlab/psi/MatlabProperty.java @@ -0,0 +1,22 @@ +// This is a generated file. Not intended for manual editing. +package com.github.kornilova203.matlab.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface MatlabProperty extends PsiElement { + + @Nullable + MatlabClassName getClassName(); + + @Nullable + MatlabDefaultValue getDefaultValue(); + + @Nullable + MatlabPropertySize getPropertySize(); + + @Nullable + MatlabPropertyValidationFunctions getPropertyValidationFunctions(); + +} diff --git a/gen/com/github/kornilova203/matlab/psi/MatlabPropertySize.java b/gen/com/github/kornilova203/matlab/psi/MatlabPropertySize.java new file mode 100644 index 0000000..fed567a --- /dev/null +++ b/gen/com/github/kornilova203/matlab/psi/MatlabPropertySize.java @@ -0,0 +1,13 @@ +// This is a generated file. Not intended for manual editing. +package com.github.kornilova203.matlab.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface MatlabPropertySize extends PsiElement { + + @NotNull + List getDimensionList(); + +} diff --git a/gen/com/github/kornilova203/matlab/psi/MatlabPropertyValidationFunctions.java b/gen/com/github/kornilova203/matlab/psi/MatlabPropertyValidationFunctions.java new file mode 100644 index 0000000..d96335f --- /dev/null +++ b/gen/com/github/kornilova203/matlab/psi/MatlabPropertyValidationFunctions.java @@ -0,0 +1,13 @@ +// This is a generated file. Not intended for manual editing. +package com.github.kornilova203.matlab.psi; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.psi.PsiElement; + +public interface MatlabPropertyValidationFunctions extends PsiElement { + + @NotNull + List getExprList(); + +} diff --git a/gen/com/github/kornilova203/matlab/psi/MatlabTypes.java b/gen/com/github/kornilova203/matlab/psi/MatlabTypes.java index 0491d5e..f606b14 100644 --- a/gen/com/github/kornilova203/matlab/psi/MatlabTypes.java +++ b/gen/com/github/kornilova203/matlab/psi/MatlabTypes.java @@ -26,9 +26,12 @@ public interface MatlabTypes { IElementType CELL_ARRAY_LITERAL = new MatlabElementType("CELL_ARRAY_LITERAL"); IElementType CELL_ARRAY_ROW = new MatlabElementType("CELL_ARRAY_ROW"); IElementType CLASS_DECLARATION = new MatlabClassDeclarationElementType("CLASS_DECLARATION"); + IElementType CLASS_NAME = new MatlabElementType("CLASS_NAME"); IElementType CONDITION = new MatlabElementType("CONDITION"); IElementType CONTROL_EXPR = new MatlabElementType("CONTROL_EXPR"); IElementType CTRANSPOSE_EXPR = new MatlabElementType("CTRANSPOSE_EXPR"); + IElementType DEFAULT_VALUE = new MatlabElementType("DEFAULT_VALUE"); + IElementType DIMENSION = new MatlabElementType("DIMENSION"); IElementType ELEMENT_WISE_LDIV_EXPR = new MatlabElementType("ELEMENT_WISE_LDIV_EXPR"); IElementType ELEMENT_WISE_MUL_EXPR = new MatlabElementType("ELEMENT_WISE_MUL_EXPR"); IElementType ELEMENT_WISE_POW_EXPR = new MatlabElementType("ELEMENT_WISE_POW_EXPR"); @@ -36,6 +39,7 @@ public interface MatlabTypes { IElementType ELSEIF_BLOCK = new MatlabElementType("ELSEIF_BLOCK"); IElementType ELSE_BLOCK = new MatlabElementType("ELSE_BLOCK"); IElementType ENUMERATION_BLOCK = new MatlabElementType("ENUMERATION_BLOCK"); + IElementType ENUM_ITEM = new MatlabElementType("ENUM_ITEM"); IElementType EQUAL_EXPR = new MatlabElementType("EQUAL_EXPR"); IElementType EVENTS_BLOCK = new MatlabElementType("EVENTS_BLOCK"); IElementType EVENTS_LIST = new MatlabElementType("EVENTS_LIST"); @@ -62,6 +66,7 @@ public interface MatlabTypes { IElementType MATRIX_ROW = new MatlabElementType("MATRIX_ROW"); IElementType META_CLASS_EXPR = new MatlabElementType("META_CLASS_EXPR"); IElementType METHODS_BLOCK = new MatlabElementType("METHODS_BLOCK"); + IElementType METHODS_LIST = new MatlabElementType("METHODS_LIST"); IElementType MINUS_EXPR = new MatlabElementType("MINUS_EXPR"); IElementType MORE_EXPR = new MatlabElementType("MORE_EXPR"); IElementType MORE_OR_EQUAL_EXPR = new MatlabElementType("MORE_OR_EQUAL_EXPR"); @@ -77,6 +82,10 @@ public interface MatlabTypes { IElementType PLUS_EXPR = new MatlabElementType("PLUS_EXPR"); IElementType POW_EXPR = new MatlabElementType("POW_EXPR"); IElementType PROPERTIES_BLOCK = new MatlabElementType("PROPERTIES_BLOCK"); + IElementType PROPERTIES_LIST = new MatlabElementType("PROPERTIES_LIST"); + IElementType PROPERTY = new MatlabElementType("PROPERTY"); + IElementType PROPERTY_SIZE = new MatlabElementType("PROPERTY_SIZE"); + IElementType PROPERTY_VALIDATION_FUNCTIONS = new MatlabElementType("PROPERTY_VALIDATION_FUNCTIONS"); IElementType QUALIFIED_EXPR = new MatlabElementType("QUALIFIED_EXPR"); IElementType RANGE_EXPR = new MatlabElementType("RANGE_EXPR"); IElementType RDIV_EXPR = new MatlabElementType("RDIV_EXPR"); @@ -222,6 +231,9 @@ else if (type == CELL_ARRAY_ROW) { else if (type == CLASS_DECLARATION) { return new MatlabClassDeclarationImpl(node); } + else if (type == CLASS_NAME) { + return new MatlabClassNameImpl(node); + } else if (type == CONDITION) { return new MatlabConditionImpl(node); } @@ -231,6 +243,12 @@ else if (type == CONTROL_EXPR) { else if (type == CTRANSPOSE_EXPR) { return new MatlabCtransposeExprImpl(node); } + else if (type == DEFAULT_VALUE) { + return new MatlabDefaultValueImpl(node); + } + else if (type == DIMENSION) { + return new MatlabDimensionImpl(node); + } else if (type == ELEMENT_WISE_LDIV_EXPR) { return new MatlabElementWiseLdivExprImpl(node); } @@ -252,6 +270,9 @@ else if (type == ELSE_BLOCK) { else if (type == ENUMERATION_BLOCK) { return new MatlabEnumerationBlockImpl(node); } + else if (type == ENUM_ITEM) { + return new MatlabEnumItemImpl(node); + } else if (type == EQUAL_EXPR) { return new MatlabEqualExprImpl(node); } @@ -327,6 +348,9 @@ else if (type == META_CLASS_EXPR) { else if (type == METHODS_BLOCK) { return new MatlabMethodsBlockImpl(node); } + else if (type == METHODS_LIST) { + return new MatlabMethodsListImpl(node); + } else if (type == MINUS_EXPR) { return new MatlabMinusExprImpl(node); } @@ -372,6 +396,18 @@ else if (type == POW_EXPR) { else if (type == PROPERTIES_BLOCK) { return new MatlabPropertiesBlockImpl(node); } + else if (type == PROPERTIES_LIST) { + return new MatlabPropertiesListImpl(node); + } + else if (type == PROPERTY) { + return new MatlabPropertyImpl(node); + } + else if (type == PROPERTY_SIZE) { + return new MatlabPropertySizeImpl(node); + } + else if (type == PROPERTY_VALIDATION_FUNCTIONS) { + return new MatlabPropertyValidationFunctionsImpl(node); + } else if (type == QUALIFIED_EXPR) { return new MatlabQualifiedExprImpl(node); } diff --git a/gen/com/github/kornilova203/matlab/psi/MatlabVisitor.java b/gen/com/github/kornilova203/matlab/psi/MatlabVisitor.java index e58e8d1..ba38d6a 100644 --- a/gen/com/github/kornilova203/matlab/psi/MatlabVisitor.java +++ b/gen/com/github/kornilova203/matlab/psi/MatlabVisitor.java @@ -71,6 +71,10 @@ public void visitClassDeclaration(@NotNull MatlabClassDeclaration o) { visitPsiElement(o); } + public void visitClassName(@NotNull MatlabClassName o) { + visitPsiElement(o); + } + public void visitCondition(@NotNull MatlabCondition o) { visitPsiElement(o); } @@ -83,6 +87,14 @@ public void visitCtransposeExpr(@NotNull MatlabCtransposeExpr o) { visitBinaryExpr(o); } + public void visitDefaultValue(@NotNull MatlabDefaultValue o) { + visitPsiElement(o); + } + + public void visitDimension(@NotNull MatlabDimension o) { + visitPsiElement(o); + } + public void visitElementWiseLdivExpr(@NotNull MatlabElementWiseLdivExpr o) { visitBinaryExpr(o); } @@ -107,6 +119,10 @@ public void visitElseifBlock(@NotNull MatlabElseifBlock o) { visitPsiElement(o); } + public void visitEnumItem(@NotNull MatlabEnumItem o) { + visitPsiElement(o); + } + public void visitEnumerationBlock(@NotNull MatlabEnumerationBlock o) { visitPsiElement(o); } @@ -215,6 +231,10 @@ public void visitMethodsBlock(@NotNull MatlabMethodsBlock o) { visitPsiElement(o); } + public void visitMethodsList(@NotNull MatlabMethodsList o) { + visitPsiElement(o); + } + public void visitMinusExpr(@NotNull MatlabMinusExpr o) { visitBinaryExpr(o); } @@ -279,6 +299,22 @@ public void visitPropertiesBlock(@NotNull MatlabPropertiesBlock o) { visitPsiElement(o); } + public void visitPropertiesList(@NotNull MatlabPropertiesList o) { + visitPsiElement(o); + } + + public void visitProperty(@NotNull MatlabProperty o) { + visitPsiElement(o); + } + + public void visitPropertySize(@NotNull MatlabPropertySize o) { + visitPsiElement(o); + } + + public void visitPropertyValidationFunctions(@NotNull MatlabPropertyValidationFunctions o) { + visitPsiElement(o); + } + public void visitQualifiedExpr(@NotNull MatlabQualifiedExpr o) { visitBinaryExpr(o); } diff --git a/gen/com/github/kornilova203/matlab/psi/impl/MatlabClassNameImpl.java b/gen/com/github/kornilova203/matlab/psi/impl/MatlabClassNameImpl.java new file mode 100644 index 0000000..6d86183 --- /dev/null +++ b/gen/com/github/kornilova203/matlab/psi/impl/MatlabClassNameImpl.java @@ -0,0 +1,35 @@ +// This is a generated file. Not intended for manual editing. +package com.github.kornilova203.matlab.psi.impl; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiElementVisitor; +import com.intellij.psi.util.PsiTreeUtil; +import static com.github.kornilova203.matlab.psi.MatlabTypes.*; +import com.github.kornilova203.matlab.psi.MatlabASTWrapperPsiElement; +import com.github.kornilova203.matlab.psi.*; + +public class MatlabClassNameImpl extends MatlabASTWrapperPsiElement implements MatlabClassName { + + public MatlabClassNameImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull MatlabVisitor visitor) { + visitor.visitClassName(this); + } + + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof MatlabVisitor) accept((MatlabVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public MatlabRefExpr getRefExpr() { + return findNotNullChildByClass(MatlabRefExpr.class); + } + +} diff --git a/gen/com/github/kornilova203/matlab/psi/impl/MatlabDefaultValueImpl.java b/gen/com/github/kornilova203/matlab/psi/impl/MatlabDefaultValueImpl.java new file mode 100644 index 0000000..bf63ee0 --- /dev/null +++ b/gen/com/github/kornilova203/matlab/psi/impl/MatlabDefaultValueImpl.java @@ -0,0 +1,35 @@ +// This is a generated file. Not intended for manual editing. +package com.github.kornilova203.matlab.psi.impl; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiElementVisitor; +import com.intellij.psi.util.PsiTreeUtil; +import static com.github.kornilova203.matlab.psi.MatlabTypes.*; +import com.github.kornilova203.matlab.psi.MatlabASTWrapperPsiElement; +import com.github.kornilova203.matlab.psi.*; + +public class MatlabDefaultValueImpl extends MatlabASTWrapperPsiElement implements MatlabDefaultValue { + + public MatlabDefaultValueImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull MatlabVisitor visitor) { + visitor.visitDefaultValue(this); + } + + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof MatlabVisitor) accept((MatlabVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public MatlabExpr getExpr() { + return findNotNullChildByClass(MatlabExpr.class); + } + +} diff --git a/gen/com/github/kornilova203/matlab/psi/impl/MatlabDimensionImpl.java b/gen/com/github/kornilova203/matlab/psi/impl/MatlabDimensionImpl.java new file mode 100644 index 0000000..fb68736 --- /dev/null +++ b/gen/com/github/kornilova203/matlab/psi/impl/MatlabDimensionImpl.java @@ -0,0 +1,35 @@ +// This is a generated file. Not intended for manual editing. +package com.github.kornilova203.matlab.psi.impl; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiElementVisitor; +import com.intellij.psi.util.PsiTreeUtil; +import static com.github.kornilova203.matlab.psi.MatlabTypes.*; +import com.github.kornilova203.matlab.psi.MatlabASTWrapperPsiElement; +import com.github.kornilova203.matlab.psi.*; + +public class MatlabDimensionImpl extends MatlabASTWrapperPsiElement implements MatlabDimension { + + public MatlabDimensionImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull MatlabVisitor visitor) { + visitor.visitDimension(this); + } + + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof MatlabVisitor) accept((MatlabVisitor)visitor); + else super.accept(visitor); + } + + @Override + @Nullable + public PsiElement getInteger() { + return findChildByType(INTEGER); + } + +} diff --git a/gen/com/github/kornilova203/matlab/psi/impl/MatlabEnumItemImpl.java b/gen/com/github/kornilova203/matlab/psi/impl/MatlabEnumItemImpl.java new file mode 100644 index 0000000..848971a --- /dev/null +++ b/gen/com/github/kornilova203/matlab/psi/impl/MatlabEnumItemImpl.java @@ -0,0 +1,35 @@ +// This is a generated file. Not intended for manual editing. +package com.github.kornilova203.matlab.psi.impl; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiElementVisitor; +import com.intellij.psi.util.PsiTreeUtil; +import static com.github.kornilova203.matlab.psi.MatlabTypes.*; +import com.github.kornilova203.matlab.psi.MatlabDeclarationBase; +import com.github.kornilova203.matlab.psi.*; + +public class MatlabEnumItemImpl extends MatlabDeclarationBase implements MatlabEnumItem { + + public MatlabEnumItemImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull MatlabVisitor visitor) { + visitor.visitEnumItem(this); + } + + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof MatlabVisitor) accept((MatlabVisitor)visitor); + else super.accept(visitor); + } + + @Override + @Nullable + public MatlabArguments getArguments() { + return findChildByClass(MatlabArguments.class); + } + +} diff --git a/gen/com/github/kornilova203/matlab/psi/impl/MatlabEnumerationBlockImpl.java b/gen/com/github/kornilova203/matlab/psi/impl/MatlabEnumerationBlockImpl.java index f6c8986..73517a8 100644 --- a/gen/com/github/kornilova203/matlab/psi/impl/MatlabEnumerationBlockImpl.java +++ b/gen/com/github/kornilova203/matlab/psi/impl/MatlabEnumerationBlockImpl.java @@ -28,8 +28,8 @@ public void accept(@NotNull PsiElementVisitor visitor) { @Override @NotNull - public List getArgumentsList() { - return PsiTreeUtil.getChildrenOfTypeAsList(this, MatlabArguments.class); + public List getEnumItemList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, MatlabEnumItem.class); } } diff --git a/gen/com/github/kornilova203/matlab/psi/impl/MatlabMethodsBlockImpl.java b/gen/com/github/kornilova203/matlab/psi/impl/MatlabMethodsBlockImpl.java index 82892d1..8e85b39 100644 --- a/gen/com/github/kornilova203/matlab/psi/impl/MatlabMethodsBlockImpl.java +++ b/gen/com/github/kornilova203/matlab/psi/impl/MatlabMethodsBlockImpl.java @@ -34,8 +34,8 @@ public MatlabAttributes getAttributes() { @Override @Nullable - public MatlabBlock getBlock() { - return findChildByClass(MatlabBlock.class); + public MatlabMethodsList getMethodsList() { + return findChildByClass(MatlabMethodsList.class); } } diff --git a/gen/com/github/kornilova203/matlab/psi/impl/MatlabMethodsListImpl.java b/gen/com/github/kornilova203/matlab/psi/impl/MatlabMethodsListImpl.java new file mode 100644 index 0000000..aac2cfc --- /dev/null +++ b/gen/com/github/kornilova203/matlab/psi/impl/MatlabMethodsListImpl.java @@ -0,0 +1,35 @@ +// This is a generated file. Not intended for manual editing. +package com.github.kornilova203.matlab.psi.impl; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiElementVisitor; +import com.intellij.psi.util.PsiTreeUtil; +import static com.github.kornilova203.matlab.psi.MatlabTypes.*; +import com.github.kornilova203.matlab.psi.MatlabASTWrapperPsiElement; +import com.github.kornilova203.matlab.psi.*; + +public class MatlabMethodsListImpl extends MatlabASTWrapperPsiElement implements MatlabMethodsList { + + public MatlabMethodsListImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull MatlabVisitor visitor) { + visitor.visitMethodsList(this); + } + + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof MatlabVisitor) accept((MatlabVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public List getFunctionDeclarationList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, MatlabFunctionDeclaration.class); + } + +} diff --git a/gen/com/github/kornilova203/matlab/psi/impl/MatlabParameterImpl.java b/gen/com/github/kornilova203/matlab/psi/impl/MatlabParameterImpl.java index 16f34dd..6f65bbe 100644 --- a/gen/com/github/kornilova203/matlab/psi/impl/MatlabParameterImpl.java +++ b/gen/com/github/kornilova203/matlab/psi/impl/MatlabParameterImpl.java @@ -8,10 +8,10 @@ import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.util.PsiTreeUtil; import static com.github.kornilova203.matlab.psi.MatlabTypes.*; -import com.github.kornilova203.matlab.psi.MatlabDeclarationBase; +import com.github.kornilova203.matlab.psi.MatlabParameterMixin; import com.github.kornilova203.matlab.psi.*; -public class MatlabParameterImpl extends MatlabDeclarationBase implements MatlabParameter { +public class MatlabParameterImpl extends MatlabParameterMixin implements MatlabParameter { public MatlabParameterImpl(@NotNull ASTNode node) { super(node); diff --git a/gen/com/github/kornilova203/matlab/psi/impl/MatlabPropertiesBlockImpl.java b/gen/com/github/kornilova203/matlab/psi/impl/MatlabPropertiesBlockImpl.java index 21b031b..a2bef1a 100644 --- a/gen/com/github/kornilova203/matlab/psi/impl/MatlabPropertiesBlockImpl.java +++ b/gen/com/github/kornilova203/matlab/psi/impl/MatlabPropertiesBlockImpl.java @@ -34,8 +34,8 @@ public MatlabAttributes getAttributes() { @Override @Nullable - public MatlabBlock getBlock() { - return findChildByClass(MatlabBlock.class); + public MatlabPropertiesList getPropertiesList() { + return findChildByClass(MatlabPropertiesList.class); } } diff --git a/gen/com/github/kornilova203/matlab/psi/impl/MatlabPropertiesListImpl.java b/gen/com/github/kornilova203/matlab/psi/impl/MatlabPropertiesListImpl.java new file mode 100644 index 0000000..b9518b1 --- /dev/null +++ b/gen/com/github/kornilova203/matlab/psi/impl/MatlabPropertiesListImpl.java @@ -0,0 +1,35 @@ +// This is a generated file. Not intended for manual editing. +package com.github.kornilova203.matlab.psi.impl; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiElementVisitor; +import com.intellij.psi.util.PsiTreeUtil; +import static com.github.kornilova203.matlab.psi.MatlabTypes.*; +import com.github.kornilova203.matlab.psi.MatlabASTWrapperPsiElement; +import com.github.kornilova203.matlab.psi.*; + +public class MatlabPropertiesListImpl extends MatlabASTWrapperPsiElement implements MatlabPropertiesList { + + public MatlabPropertiesListImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull MatlabVisitor visitor) { + visitor.visitPropertiesList(this); + } + + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof MatlabVisitor) accept((MatlabVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public List getPropertyList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, MatlabProperty.class); + } + +} diff --git a/gen/com/github/kornilova203/matlab/psi/impl/MatlabPropertyImpl.java b/gen/com/github/kornilova203/matlab/psi/impl/MatlabPropertyImpl.java new file mode 100644 index 0000000..1e5388e --- /dev/null +++ b/gen/com/github/kornilova203/matlab/psi/impl/MatlabPropertyImpl.java @@ -0,0 +1,53 @@ +// This is a generated file. Not intended for manual editing. +package com.github.kornilova203.matlab.psi.impl; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiElementVisitor; +import com.intellij.psi.util.PsiTreeUtil; +import static com.github.kornilova203.matlab.psi.MatlabTypes.*; +import com.github.kornilova203.matlab.psi.MatlabPropertyMixin; +import com.github.kornilova203.matlab.psi.*; + +public class MatlabPropertyImpl extends MatlabPropertyMixin implements MatlabProperty { + + public MatlabPropertyImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull MatlabVisitor visitor) { + visitor.visitProperty(this); + } + + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof MatlabVisitor) accept((MatlabVisitor)visitor); + else super.accept(visitor); + } + + @Override + @Nullable + public MatlabClassName getClassName() { + return findChildByClass(MatlabClassName.class); + } + + @Override + @Nullable + public MatlabDefaultValue getDefaultValue() { + return findChildByClass(MatlabDefaultValue.class); + } + + @Override + @Nullable + public MatlabPropertySize getPropertySize() { + return findChildByClass(MatlabPropertySize.class); + } + + @Override + @Nullable + public MatlabPropertyValidationFunctions getPropertyValidationFunctions() { + return findChildByClass(MatlabPropertyValidationFunctions.class); + } + +} diff --git a/gen/com/github/kornilova203/matlab/psi/impl/MatlabPropertySizeImpl.java b/gen/com/github/kornilova203/matlab/psi/impl/MatlabPropertySizeImpl.java new file mode 100644 index 0000000..b909f41 --- /dev/null +++ b/gen/com/github/kornilova203/matlab/psi/impl/MatlabPropertySizeImpl.java @@ -0,0 +1,35 @@ +// This is a generated file. Not intended for manual editing. +package com.github.kornilova203.matlab.psi.impl; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiElementVisitor; +import com.intellij.psi.util.PsiTreeUtil; +import static com.github.kornilova203.matlab.psi.MatlabTypes.*; +import com.github.kornilova203.matlab.psi.MatlabASTWrapperPsiElement; +import com.github.kornilova203.matlab.psi.*; + +public class MatlabPropertySizeImpl extends MatlabASTWrapperPsiElement implements MatlabPropertySize { + + public MatlabPropertySizeImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull MatlabVisitor visitor) { + visitor.visitPropertySize(this); + } + + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof MatlabVisitor) accept((MatlabVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public List getDimensionList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, MatlabDimension.class); + } + +} diff --git a/gen/com/github/kornilova203/matlab/psi/impl/MatlabPropertyValidationFunctionsImpl.java b/gen/com/github/kornilova203/matlab/psi/impl/MatlabPropertyValidationFunctionsImpl.java new file mode 100644 index 0000000..8a999be --- /dev/null +++ b/gen/com/github/kornilova203/matlab/psi/impl/MatlabPropertyValidationFunctionsImpl.java @@ -0,0 +1,35 @@ +// This is a generated file. Not intended for manual editing. +package com.github.kornilova203.matlab.psi.impl; + +import java.util.List; +import org.jetbrains.annotations.*; +import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; +import com.intellij.psi.PsiElementVisitor; +import com.intellij.psi.util.PsiTreeUtil; +import static com.github.kornilova203.matlab.psi.MatlabTypes.*; +import com.github.kornilova203.matlab.psi.MatlabASTWrapperPsiElement; +import com.github.kornilova203.matlab.psi.*; + +public class MatlabPropertyValidationFunctionsImpl extends MatlabASTWrapperPsiElement implements MatlabPropertyValidationFunctions { + + public MatlabPropertyValidationFunctionsImpl(@NotNull ASTNode node) { + super(node); + } + + public void accept(@NotNull MatlabVisitor visitor) { + visitor.visitPropertyValidationFunctions(this); + } + + public void accept(@NotNull PsiElementVisitor visitor) { + if (visitor instanceof MatlabVisitor) accept((MatlabVisitor)visitor); + else super.accept(visitor); + } + + @Override + @NotNull + public List getExprList() { + return PsiTreeUtil.getChildrenOfTypeAsList(this, MatlabExpr.class); + } + +} diff --git a/gen/com/github/kornilova203/matlab/psi/impl/MatlabQualifiedExprImpl.java b/gen/com/github/kornilova203/matlab/psi/impl/MatlabQualifiedExprImpl.java index 06304c2..fa6b93c 100644 --- a/gen/com/github/kornilova203/matlab/psi/impl/MatlabQualifiedExprImpl.java +++ b/gen/com/github/kornilova203/matlab/psi/impl/MatlabQualifiedExprImpl.java @@ -8,9 +8,10 @@ import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.util.PsiTreeUtil; import static com.github.kornilova203.matlab.psi.MatlabTypes.*; +import com.github.kornilova203.matlab.psi.MatlabQualifiedExprMixin; import com.github.kornilova203.matlab.psi.*; -public class MatlabQualifiedExprImpl extends MatlabBinaryExprImpl implements MatlabQualifiedExpr { +public class MatlabQualifiedExprImpl extends MatlabQualifiedExprMixin implements MatlabQualifiedExpr { public MatlabQualifiedExprImpl(@NotNull ASTNode node) { super(node); diff --git a/gen/com/github/kornilova203/matlab/psi/impl/MatlabRetValueImpl.java b/gen/com/github/kornilova203/matlab/psi/impl/MatlabRetValueImpl.java index e60e8df..2145bc6 100644 --- a/gen/com/github/kornilova203/matlab/psi/impl/MatlabRetValueImpl.java +++ b/gen/com/github/kornilova203/matlab/psi/impl/MatlabRetValueImpl.java @@ -8,10 +8,10 @@ import com.intellij.psi.PsiElementVisitor; import com.intellij.psi.util.PsiTreeUtil; import static com.github.kornilova203.matlab.psi.MatlabTypes.*; -import com.github.kornilova203.matlab.psi.MatlabDeclarationBase; +import com.github.kornilova203.matlab.psi.MatlabRetValueMixin; import com.github.kornilova203.matlab.psi.*; -public class MatlabRetValueImpl extends MatlabDeclarationBase implements MatlabRetValue { +public class MatlabRetValueImpl extends MatlabRetValueMixin implements MatlabRetValue { public MatlabRetValueImpl(@NotNull ASTNode node) { super(node); diff --git a/grammar/Matlab.bnf b/grammar/Matlab.bnf index 5ee5e8e..f30c4f9 100644 --- a/grammar/Matlab.bnf +++ b/grammar/Matlab.bnf @@ -81,8 +81,8 @@ mixin("class_declaration")="com.github.kornilova203.matlab.psi.MatlabStubbedClassDeclaration" mixin("catch_block")="com.github.kornilova203.matlab.psi.MatlabCatchBlockMixin" mixin("function_declaration")="com.github.kornilova203.matlab.psi.MatlabStubbedFunctionDeclaration" - mixin("parameter")="com.github.kornilova203.matlab.psi.MatlabDeclarationBase" - mixin("ret_value")="com.github.kornilova203.matlab.psi.MatlabDeclarationBase" + mixin("parameter")="com.github.kornilova203.matlab.psi.MatlabParameterMixin" + mixin("ret_value")="com.github.kornilova203.matlab.psi.MatlabRetValueMixin" mixin("block")="com.github.kornilova203.matlab.psi.MatlabBlockMixin" mixin("for_loop")="com.github.kornilova203.matlab.psi.MatlabForLoopMixin" mixin("parfor_loop")="com.github.kornilova203.matlab.psi.MatlabParforLoopMixin" @@ -92,6 +92,9 @@ mixin("binary_expr")="com.github.kornilova203.matlab.psi.MatlabBinaryExprMixin" mixin("function_expr")="com.github.kornilova203.matlab.psi.MatlabFunctionExprMixin" mixin("literal_expr")="com.github.kornilova203.matlab.psi.MatlabLiteralExprMixin" + mixin("qualified_expr")="com.github.kornilova203.matlab.psi.MatlabQualifiedExprMixin" + mixin("property")="com.github.kornilova203.matlab.psi.MatlabPropertyMixin" + mixin("enum_item")="com.github.kornilova203.matlab.psi.MatlabDeclarationBase" } root ::= NEWLINE * (element NEWLINE *) * end? @@ -213,19 +216,26 @@ private not_ampersand_or_super_class_or_properties_or_methods_or_end ::= !( br* | NEWLINE* end ) properties_block ::= properties_token br* attributes? NEWLINE* - properties_block_body NEWLINE* + properties_list NEWLINE* end { pin=1 recoverWhile=block_inside_class_recovery } private properties_token ::= <> attributes ::= <> attribute ::= [ '~' ] ref_expr [ sep '=' sep expr ] { pin(".*")=2 } -private properties_block_body ::= <> { recoverWhile=block_inside_class_recovery } +properties_list ::= (property NEWLINE*)* { recoverWhile=block_inside_class_recovery } +property ::= ident property_size? class_name? property_validation_functions? ('=' default_value)? [ ';' ] +property_size ::= <> +dimension ::= INTEGER | ':' +class_name ::= ref_expr +property_validation_functions ::= '{' <> '}' +default_value ::= expr +private property_validation_function ::= expr private block_inside_class_recovery ::= !( NEWLINE* ( end | methods_token | properties_token | events_token | enumeration_token ) ) methods_block ::= methods_token br* attributes? NEWLINE* - methods_block_body NEWLINE* + methods_list NEWLINE* end { pin=1 recoverWhile=block_inside_class_recovery } private methods_token ::= <> -private methods_block_body ::= <> { recoverWhile=block_inside_class_recovery } +methods_list ::= (function_declaration NEWLINE*)* { recoverWhile=block_inside_class_recovery } events_block ::= events_token br* attributes? NEWLINE* events_list NEWLINE* @@ -239,7 +249,7 @@ enumeration_block ::= enumeration_token NEWLINE* end { pin=1 recoverWhile=block_inside_class_recovery } private enumeration_token ::= <> -private enum_item ::= ident arguments? +enum_item ::= ident arguments? ;{ name(".*literal")='literal' diff --git a/src/com/github/kornilova203/matlab/MatlabControlFlowBuilder.kt b/src/com/github/kornilova203/matlab/MatlabControlFlowBuilder.kt index 2385990..78ff80a 100644 --- a/src/com/github/kornilova203/matlab/MatlabControlFlowBuilder.kt +++ b/src/com/github/kornilova203/matlab/MatlabControlFlowBuilder.kt @@ -181,7 +181,10 @@ class MatlabControlFlowBuilder : MatlabVisitor(), PsiRecursiveVisitor { builder.startNode(node) val methods = node.methodsBlockList for (method in methods) { - method.block?.accept(this) + val list = method.methodsList?.functionDeclarationList ?: emptyList() + for (function in list) { + function.accept(this) + } } } diff --git a/src/com/github/kornilova203/matlab/MatlabFoldingBuilder.kt b/src/com/github/kornilova203/matlab/MatlabFoldingBuilder.kt index e268b93..46df129 100644 --- a/src/com/github/kornilova203/matlab/MatlabFoldingBuilder.kt +++ b/src/com/github/kornilova203/matlab/MatlabFoldingBuilder.kt @@ -24,7 +24,8 @@ class MatlabFoldingBuilder : CustomFoldingBuilder() { val type = node.elementType val parentType = node.treeParent?.elementType if (type == MatlabTypes.BLOCK && parentType != MatlabTypes.CASE_BLOCK && parentType != MatlabTypes.OTHERWISE_BLOCK - || type == MatlabTypes.SWITCH_BLOCK || type == MatlabTypes.CLASS_DECLARATION || type == MatlabTypes.EVENTS_LIST ) { + || type == MatlabTypes.SWITCH_BLOCK || type == MatlabTypes.CLASS_DECLARATION || type == MatlabTypes.EVENTS_LIST + || type == MatlabTypes.PROPERTIES_LIST || type == MatlabTypes.METHODS_LIST) { val start = getStartOffset(node) val end = getEndOffset(node) if (end > start) { diff --git a/src/com/github/kornilova203/matlab/MatlabTypeProvider.kt b/src/com/github/kornilova203/matlab/MatlabTypeProvider.kt index a28c821..314519f 100644 --- a/src/com/github/kornilova203/matlab/MatlabTypeProvider.kt +++ b/src/com/github/kornilova203/matlab/MatlabTypeProvider.kt @@ -1,26 +1,24 @@ package com.github.kornilova203.matlab -import com.github.kornilova203.matlab.psi.MatlabAssignExpr -import com.github.kornilova203.matlab.psi.MatlabExpr -import com.github.kornilova203.matlab.psi.MatlabRefExpr -import com.github.kornilova203.matlab.psi.MatlabTypedExpr +import com.github.kornilova203.matlab.psi.* import com.github.kornilova203.matlab.psi.types.MatlabTypeUnknown import com.intellij.lang.ExpressionTypeProvider import com.intellij.psi.PsiElement import com.intellij.psi.PsiFile import com.intellij.psi.SyntaxTraverser -class MatlabTypeProvider : ExpressionTypeProvider() { - override fun getInformationHint(element: MatlabExpr): String { +class MatlabTypeProvider : ExpressionTypeProvider() { + override fun getInformationHint(element: PsiElement): String { val type = if (element is MatlabTypedExpr) element.getType() else MatlabTypeUnknown() return type.getName() } - - override fun getExpressionsAt(elementAt: PsiElement): MutableList { + + override fun getExpressionsAt(elementAt: PsiElement): MutableList { return SyntaxTraverser.psiApi() .parents(elementAt) .takeWhile { it !is PsiFile } - .filter(MatlabExpr::class.java) + .filter { it is MatlabTypedExpr && it !is MatlabAssignExpr && + !(it is MatlabRefExpr && it.parent is MatlabFunctionExpr) } .toList() } diff --git a/src/com/github/kornilova203/matlab/psi/MatlabFunctionExprMixin.kt b/src/com/github/kornilova203/matlab/psi/MatlabFunctionExprMixin.kt index bdfc64a..d4fe18c 100644 --- a/src/com/github/kornilova203/matlab/psi/MatlabFunctionExprMixin.kt +++ b/src/com/github/kornilova203/matlab/psi/MatlabFunctionExprMixin.kt @@ -1,12 +1,59 @@ package com.github.kornilova203.matlab.psi import com.github.kornilova203.matlab.psi.types.MatlabType +import com.github.kornilova203.matlab.psi.types.MatlabTypeClass +import com.github.kornilova203.matlab.psi.types.MatlabTypeFunction import com.github.kornilova203.matlab.psi.types.MatlabTypeUnknown import com.intellij.lang.ASTNode +import com.intellij.psi.PsiElement +import com.intellij.psi.ResolveState +import com.intellij.psi.scope.PsiScopeProcessor abstract class MatlabFunctionExprMixin(node: ASTNode) : MatlabASTWrapperPsiElement(node), MatlabFunctionExpr, MatlabTypedExpr { - override fun getType(): MatlabType { + override fun processDeclarations(processor: PsiScopeProcessor, state: ResolveState, lastParent: PsiElement?, place: PsiElement): Boolean { + if (this != place.parent) { + return true + } + val type = firstArgument()?.getType() + if (type !is MatlabTypeClass) { + return true + } + val classDeclaration = type.decl + val methods = classDeclaration.methodsBlockList + for (method in methods) { + val functionList = method.methodsList?.functionDeclarationList ?: return true + for (function in functionList) { + processor.execute(function, state) + } + } + return (processor as MatlabResolvingScopeProcessor).declaration == null + } + + override fun getType(): MatlabType { val expr = this.expr - return if (expr is MatlabTypedExpr) expr.getType() else MatlabTypeUnknown() + if (expr !is MatlabTypedExpr) { + return MatlabTypeUnknown() + } + val type = expr.getType() + if (type is MatlabTypeFunction) { + return type.getReturnType() + } + if (type is MatlabClassDeclaration) { + if (this.parent !is MatlabQualifiedExpr) { + if (firstArgument()?.getType()?.getName() == type.getName()) { + return type + } + return MatlabTypeUnknown() + } + } + return type + } + + fun firstArgument(): MatlabTypedExpr? { + val children = arguments.children + if (children.isNotEmpty()) { + return children[0] as MatlabTypedExpr + } + return null } } \ No newline at end of file diff --git a/src/com/github/kornilova203/matlab/psi/MatlabParameterMixin.kt b/src/com/github/kornilova203/matlab/psi/MatlabParameterMixin.kt new file mode 100644 index 0000000..6836e36 --- /dev/null +++ b/src/com/github/kornilova203/matlab/psi/MatlabParameterMixin.kt @@ -0,0 +1,29 @@ +package com.github.kornilova203.matlab.psi + +import com.github.kornilova203.matlab.psi.types.MatlabType +import com.github.kornilova203.matlab.psi.types.MatlabTypeClass +import com.github.kornilova203.matlab.psi.types.MatlabTypeFunction +import com.github.kornilova203.matlab.psi.types.MatlabTypeUnknown +import com.intellij.lang.ASTNode +import com.intellij.psi.PsiElement +import com.intellij.psi.util.parentOfTypes + +abstract class MatlabParameterMixin(node: ASTNode) : MatlabASTWrapperPsiElement(node), MatlabParameter, MatlabDeclaration, MatlabTypedExpr { + override val visibleOutsideFunction = true + + override fun getNameIdentifier(): PsiElement? = getChildOfType(MatlabTypes.IDENTIFIER) + + override fun getName(): String? = nameIdentifier?.text + + override fun setName(name: String): PsiElement { + nameIdentifier?.replace(createIdentifierFromText(project, name)) + return this + } + + override fun getTextOffset(): Int = nameIdentifier?.node?.startOffset ?: super.getTextOffset() + + override fun getType(): MatlabType { + val type = this.parentOfTypes(MatlabStubbedFunctionDeclaration::class)?.getType() + return if (type is MatlabTypeFunction) type.getReturnType() else MatlabTypeUnknown() + } +} \ No newline at end of file diff --git a/src/com/github/kornilova203/matlab/psi/MatlabPropertyMixin.kt b/src/com/github/kornilova203/matlab/psi/MatlabPropertyMixin.kt new file mode 100644 index 0000000..3fabdf7 --- /dev/null +++ b/src/com/github/kornilova203/matlab/psi/MatlabPropertyMixin.kt @@ -0,0 +1,28 @@ +package com.github.kornilova203.matlab.psi + +import com.github.kornilova203.matlab.psi.types.MatlabType +import com.github.kornilova203.matlab.psi.types.MatlabTypeUnknown +import com.intellij.lang.ASTNode +import com.intellij.psi.PsiElement +import com.intellij.psi.ResolveState +import com.intellij.psi.scope.PsiScopeProcessor + +abstract class MatlabPropertyMixin(node: ASTNode): MatlabASTWrapperPsiElement(node), MatlabProperty, MatlabDeclaration, MatlabTypedExpr { + override val visibleOutsideFunction = true + + override fun getNameIdentifier(): PsiElement? = getChildOfType(MatlabTypes.IDENTIFIER) + + override fun getName(): String? = nameIdentifier?.text + + override fun setName(name: String): PsiElement { + nameIdentifier?.replace(createIdentifierFromText(project, name)) + return this + } + + override fun getTextOffset(): Int = nameIdentifier?.node?.startOffset ?: super.getTextOffset() + + override fun getType(): MatlabType { + val expr = className?.refExpr + return if (expr is MatlabTypedExpr) expr.getType() else MatlabTypeUnknown() + } +} \ No newline at end of file diff --git a/src/com/github/kornilova203/matlab/psi/MatlabQualifiedExprMixin.kt b/src/com/github/kornilova203/matlab/psi/MatlabQualifiedExprMixin.kt new file mode 100644 index 0000000..29015fa --- /dev/null +++ b/src/com/github/kornilova203/matlab/psi/MatlabQualifiedExprMixin.kt @@ -0,0 +1,35 @@ +package com.github.kornilova203.matlab.psi + +import com.github.kornilova203.matlab.processDeclarationsInClass +import com.github.kornilova203.matlab.psi.impl.MatlabBinaryExprImpl +import com.github.kornilova203.matlab.psi.types.MatlabType +import com.github.kornilova203.matlab.psi.types.MatlabTypeClass +import com.github.kornilova203.matlab.psi.types.MatlabTypeUnknown +import com.intellij.lang.ASTNode +import com.intellij.psi.PsiElement +import com.intellij.psi.ResolveState +import com.intellij.psi.scope.PsiScopeProcessor +import com.intellij.psi.util.PsiTreeUtil +import com.intellij.psi.util.parentOfTypes + +abstract class MatlabQualifiedExprMixin(node: ASTNode) : MatlabBinaryExprImpl(node), MatlabQualifiedExpr, MatlabTypedExpr { + override fun processDeclarations(processor: PsiScopeProcessor, state: ResolveState, lastParent: PsiElement?, place: PsiElement): Boolean { + if (lastParent != this.right) { + return true + } + val element = this.firstChild + if (element !is MatlabTypedExpr) { + return true + } + val type = element.getType() + if (type !is MatlabTypeClass) { + return true + } + return processDeclarationsInClass(processor, state, type) + } + + override fun getType(): MatlabType { + val expr = lastChild + return if (expr is MatlabTypedExpr) expr.getType() else MatlabTypeUnknown() + } +} \ No newline at end of file diff --git a/src/com/github/kornilova203/matlab/psi/MatlabRefExprMixin.kt b/src/com/github/kornilova203/matlab/psi/MatlabRefExprMixin.kt index b87b440..7abbf03 100644 --- a/src/com/github/kornilova203/matlab/psi/MatlabRefExprMixin.kt +++ b/src/com/github/kornilova203/matlab/psi/MatlabRefExprMixin.kt @@ -18,20 +18,16 @@ abstract class MatlabRefExprMixin(node: ASTNode) : MatlabASTWrapperPsiElement(no return if (assign is MatlabTypedExpr) assign.getType() else MatlabTypeUnknown() } - val declaration = this.reference.resolve() - - if (declaration == null) { - if (this.text == "true" || this.text == "false") { - return MatlabTypeBool() - } - if (this.text == "struct") { - return MatlabTypeStruct() + return when(val declaration = this.reference.resolve()) { + null -> { + when(this.text) { + "true", "false" -> MatlabTypeBool() + "struct" -> MatlabTypeStruct() + else -> MatlabTypeUnknown() + } } - return MatlabTypeUnknown() - } - if (declaration !is MatlabTypedExpr || (this.parent is MatlabFunctionExpr && declaration !is MatlabClassDeclaration)) { - return MatlabTypeUnknown() + !is MatlabTypedExpr -> MatlabTypeUnknown() + else -> declaration.getType() } - return declaration.getType() } } diff --git a/src/com/github/kornilova203/matlab/psi/MatlabRetValueMixin.kt b/src/com/github/kornilova203/matlab/psi/MatlabRetValueMixin.kt new file mode 100644 index 0000000..119ea62 --- /dev/null +++ b/src/com/github/kornilova203/matlab/psi/MatlabRetValueMixin.kt @@ -0,0 +1,37 @@ +package com.github.kornilova203.matlab.psi + +import com.github.kornilova203.matlab.psi.types.MatlabType +import com.github.kornilova203.matlab.psi.types.MatlabTypeClass +import com.github.kornilova203.matlab.psi.types.MatlabTypeUnknown +import com.intellij.lang.ASTNode +import com.intellij.psi.PsiElement +import com.intellij.psi.util.parentOfTypes + +abstract class MatlabRetValueMixin(node: ASTNode) : MatlabASTWrapperPsiElement(node), MatlabRetValue, MatlabDeclaration, MatlabTypedExpr { + override val visibleOutsideFunction = true + + override fun getNameIdentifier(): PsiElement? = getChildOfType(MatlabTypes.IDENTIFIER) + + override fun getName(): String? = nameIdentifier?.text + + override fun setName(name: String): PsiElement { + nameIdentifier?.replace(createIdentifierFromText(project, name)) + return this + } + + override fun getTextOffset(): Int = nameIdentifier?.node?.startOffset ?: super.getTextOffset() + + override fun getType(): MatlabType { + val cl = isEqualFirstParameter() + return if (cl != null) MatlabTypeClass(cl) else MatlabTypeUnknown() + } + + private fun isEqualFirstParameter(): MatlabClassDeclaration? { + val function = parentOfTypes(MatlabFunctionDeclaration::class) ?: return null + val list = function.parameters?.parameterList ?: return null + if (list.isEmpty() || list[0].text != text) { + return null + } + return this.parentOfTypes(MatlabClassDeclaration::class) + } +} \ No newline at end of file diff --git a/src/com/github/kornilova203/matlab/psi/MatlabStubbedFunctionDeclaration.kt b/src/com/github/kornilova203/matlab/psi/MatlabStubbedFunctionDeclaration.kt index 04b2ce2..fc7208b 100644 --- a/src/com/github/kornilova203/matlab/psi/MatlabStubbedFunctionDeclaration.kt +++ b/src/com/github/kornilova203/matlab/psi/MatlabStubbedFunctionDeclaration.kt @@ -12,12 +12,14 @@ import com.intellij.psi.StubBasedPsiElement import com.intellij.psi.scope.PsiScopeProcessor import com.intellij.psi.stubs.IStubElementType import com.intellij.psi.tree.IElementType +import com.intellij.psi.util.parentOfTypes abstract class MatlabStubbedFunctionDeclaration : StubBasedPsiElementBase, StubBasedPsiElement, MatlabDeclaration, MatlabFunctionDeclaration, MatlabTypedExpr { constructor(stub: MatlabFunctionDeclarationStub, nodeType: IStubElementType<*, *>) : super(stub, nodeType) constructor(node: ASTNode) : super(node) constructor(stub: MatlabFunctionDeclarationStub?, nodeType: IElementType?, node: ASTNode?) : super(stub, nodeType, node) + override val visibleOutsideFunction = true override val visibleBeforeDeclaration = true @@ -54,7 +56,6 @@ abstract class MatlabStubbedFunctionDeclaration : StubBasedPsiElementBase Boolean): Boolean { var el: PsiElement? = this.prevSibling @@ -56,4 +56,19 @@ fun processDeclarations(parent: PsiElement, processor: PsiScopeProcessor, state: if (res == false) return false return lastParent?.forEachSiblingForward { it.findDeclaration(processor, state, inCurrentScope, false) } ?: true +} + +fun processDeclarationsInClass(processor: PsiScopeProcessor, state: ResolveState, type: MatlabTypeClass): Boolean { + val classDeclaration = type.decl + val declarations = PsiTreeUtil.findChildrenOfAnyType(classDeclaration, false, + MatlabProperty::class.java, + MatlabFunctionDeclaration::class.java, + MatlabEnumItem::class.java) + + for (declaration in declarations) { + if (!processor.execute(declaration, state)) { + break + } + } + return false } \ No newline at end of file diff --git a/testData/parser/ClassDeclaration.m b/testData/parser/ClassDeclaration.m index c04945f..cdcd1b7 100644 --- a/testData/parser/ClassDeclaration.m +++ b/testData/parser/ClassDeclaration.m @@ -81,3 +81,13 @@ end end end + +classdef ClassName + properties + Prop1 + Prop2 = 'some text' + Prop3 = sin(pi/12) + Prop5 (1,1) double {mustBePositive, someElse} = 1 + Prop6(1,:) char {mustBeMember(Label,{'High','Medium','Low'})} = 'Low' + end +end diff --git a/testData/parser/ClassDeclaration.txt b/testData/parser/ClassDeclaration.txt index 30c1187..2f7d5dd 100644 --- a/testData/parser/ClassDeclaration.txt +++ b/testData/parser/ClassDeclaration.txt @@ -54,8 +54,8 @@ Matlab File PsiElement())(')') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') - MatlabBlockImpl(BLOCK) - MatlabRefExprImpl(REF_EXPR) + MatlabPropertiesListImpl(PROPERTIES_LIST) + MatlabPropertyImpl(PROPERTY) PsiElement(IDENTIFIER)('value') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') @@ -78,7 +78,7 @@ Matlab File PsiElement())(')') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') - MatlabBlockImpl(BLOCK) + MatlabMethodsListImpl(METHODS_LIST) MatlabFunctionDeclarationImpl(FUNCTION_DECLARATION) PsiElement(function)('function') PsiWhiteSpace(' ') @@ -182,12 +182,13 @@ Matlab File MatlabPropertiesBlockImpl(PROPERTIES_BLOCK) PsiElement(properties)('properties') PsiWhiteSpace(' ') - MatlabBlockImpl(BLOCK) - MatlabRefExprImpl(REF_EXPR) + MatlabPropertiesListImpl(PROPERTIES_LIST) + MatlabPropertyImpl(PROPERTY) PsiElement(IDENTIFIER)('Value1') - PsiWhiteSpace(' ') - MatlabRefExprImpl(REF_EXPR) - PsiElement(IDENTIFIER)('Value2') + PsiWhiteSpace(' ') + MatlabClassNameImpl(CLASS_NAME) + MatlabRefExprImpl(REF_EXPR) + PsiElement(IDENTIFIER)('Value2') PsiWhiteSpace(' ') PsiElement(end)('end') PsiWhiteSpace(' ') @@ -204,7 +205,7 @@ Matlab File PsiElement(methods)('methods') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') - MatlabBlockImpl(BLOCK) + MatlabMethodsListImpl(METHODS_LIST) MatlabFunctionDeclarationImpl(FUNCTION_DECLARATION) PsiElement(function)('function') PsiWhiteSpace(' ') @@ -305,8 +306,8 @@ Matlab File PsiElement())(')') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') - MatlabBlockImpl(BLOCK) - MatlabRefExprImpl(REF_EXPR) + MatlabPropertiesListImpl(PROPERTIES_LIST) + MatlabPropertyImpl(PROPERTY) PsiElement(IDENTIFIER)('Value') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') @@ -350,7 +351,7 @@ Matlab File PsiComment(COMMENT)('% empty') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') - MatlabBlockImpl(BLOCK) + MatlabPropertiesListImpl(PROPERTIES_LIST) PsiElement(end)('end') PsiElement(NEWLINE)('\n') @@ -398,7 +399,7 @@ Matlab File PsiComment(COMMENT)('% empty') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') - MatlabBlockImpl(BLOCK) + MatlabPropertiesListImpl(PROPERTIES_LIST) PsiElement(end)('end') PsiElement(NEWLINE)('\n') @@ -415,12 +416,12 @@ Matlab File PsiElement(properties)('properties') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') - MatlabBlockImpl(BLOCK) - MatlabRefExprImpl(REF_EXPR) + MatlabPropertiesListImpl(PROPERTIES_LIST) + MatlabPropertyImpl(PROPERTY) PsiElement(IDENTIFIER)('Width') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') - MatlabRefExprImpl(REF_EXPR) + MatlabPropertyImpl(PROPERTY) PsiElement(IDENTIFIER)('Height') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') @@ -438,8 +439,8 @@ Matlab File PsiElement())(')') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') - MatlabBlockImpl(BLOCK) - MatlabRefExprImpl(REF_EXPR) + MatlabPropertiesListImpl(PROPERTIES_LIST) + MatlabPropertyImpl(PROPERTY) PsiElement(IDENTIFIER)('Area') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') @@ -450,7 +451,7 @@ Matlab File PsiElement(methods)('methods') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') - MatlabBlockImpl(BLOCK) + MatlabMethodsListImpl(METHODS_LIST) MatlabFunctionDeclarationImpl(FUNCTION_DECLARATION) PsiElement(function)('function') PsiWhiteSpace(' ') @@ -515,8 +516,8 @@ Matlab File PsiElement(properties)('properties') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') - MatlabBlockImpl(BLOCK) - MatlabRefExprImpl(REF_EXPR) + MatlabPropertiesListImpl(PROPERTIES_LIST) + MatlabPropertyImpl(PROPERTY) PsiElement(IDENTIFIER)('Prop1') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') @@ -527,7 +528,7 @@ Matlab File PsiElement(methods)('methods') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') - MatlabBlockImpl(BLOCK) + MatlabMethodsListImpl(METHODS_LIST) MatlabFunctionDeclarationImpl(FUNCTION_DECLARATION) PsiElement(function)('function') PsiWhiteSpace(' ') @@ -685,4 +686,139 @@ Matlab File PsiWhiteSpace(' ') PsiElement(end)('end') PsiElement(NEWLINE)('\n') + PsiElement(end)('end') + PsiElement(NEWLINE)('\n') + PsiElement(NEWLINE)('\n') + MatlabClassDeclarationImpl(CLASS_DECLARATION) + PsiElement(classdef)('classdef') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('ClassName') + PsiElement(NEWLINE)('\n') + PsiWhiteSpace(' ') + MatlabPropertiesBlockImpl(PROPERTIES_BLOCK) + PsiElement(properties)('properties') + PsiElement(NEWLINE)('\n') + PsiWhiteSpace(' ') + MatlabPropertiesListImpl(PROPERTIES_LIST) + MatlabPropertyImpl(PROPERTY) + PsiElement(IDENTIFIER)('Prop1') + PsiElement(NEWLINE)('\n') + PsiWhiteSpace(' ') + MatlabPropertyImpl(PROPERTY) + PsiElement(IDENTIFIER)('Prop2') + PsiWhiteSpace(' ') + PsiElement(=)('=') + PsiWhiteSpace(' ') + MatlabDefaultValueImpl(DEFAULT_VALUE) + MatlabLiteralExprImpl(LITERAL_EXPR) + PsiElement(SINGLE_QUOTE_STRING)(''some text'') + PsiElement(NEWLINE)('\n') + PsiWhiteSpace(' ') + MatlabPropertyImpl(PROPERTY) + PsiElement(IDENTIFIER)('Prop3') + PsiWhiteSpace(' ') + PsiElement(=)('=') + PsiWhiteSpace(' ') + MatlabDefaultValueImpl(DEFAULT_VALUE) + MatlabFunctionExprImpl(FUNCTION_EXPR) + MatlabRefExprImpl(REF_EXPR) + PsiElement(IDENTIFIER)('sin') + MatlabArgumentsImpl(ARGUMENTS) + PsiElement(()('(') + MatlabRdivExprImpl(RDIV_EXPR) + MatlabRefExprImpl(REF_EXPR) + PsiElement(IDENTIFIER)('pi') + PsiElement(/)('/') + MatlabLiteralExprImpl(LITERAL_EXPR) + PsiElement(INTEGER)('12') + PsiElement())(')') + PsiWhiteSpace(' ') + PsiElement(NEWLINE)('\n') + PsiWhiteSpace(' ') + MatlabPropertyImpl(PROPERTY) + PsiElement(IDENTIFIER)('Prop5') + PsiWhiteSpace(' ') + MatlabPropertySizeImpl(PROPERTY_SIZE) + PsiElement(()('(') + MatlabDimensionImpl(DIMENSION) + PsiElement(INTEGER)('1') + PsiElement(,)(',') + MatlabDimensionImpl(DIMENSION) + PsiElement(INTEGER)('1') + PsiElement())(')') + PsiWhiteSpace(' ') + MatlabClassNameImpl(CLASS_NAME) + MatlabRefExprImpl(REF_EXPR) + PsiElement(IDENTIFIER)('double') + PsiWhiteSpace(' ') + MatlabPropertyValidationFunctionsImpl(PROPERTY_VALIDATION_FUNCTIONS) + PsiElement({)('{') + MatlabRefExprImpl(REF_EXPR) + PsiElement(IDENTIFIER)('mustBePositive') + PsiElement(,)(',') + PsiWhiteSpace(' ') + MatlabRefExprImpl(REF_EXPR) + PsiElement(IDENTIFIER)('someElse') + PsiElement(})('}') + PsiWhiteSpace(' ') + PsiElement(=)('=') + PsiWhiteSpace(' ') + MatlabDefaultValueImpl(DEFAULT_VALUE) + MatlabLiteralExprImpl(LITERAL_EXPR) + PsiElement(INTEGER)('1') + PsiElement(NEWLINE)('\n') + PsiWhiteSpace(' ') + MatlabPropertyImpl(PROPERTY) + PsiElement(IDENTIFIER)('Prop6') + MatlabPropertySizeImpl(PROPERTY_SIZE) + PsiElement(()('(') + MatlabDimensionImpl(DIMENSION) + PsiElement(INTEGER)('1') + PsiElement(,)(',') + MatlabDimensionImpl(DIMENSION) + PsiElement(:)(':') + PsiElement())(')') + PsiWhiteSpace(' ') + MatlabClassNameImpl(CLASS_NAME) + MatlabRefExprImpl(REF_EXPR) + PsiElement(IDENTIFIER)('char') + PsiWhiteSpace(' ') + MatlabPropertyValidationFunctionsImpl(PROPERTY_VALIDATION_FUNCTIONS) + PsiElement({)('{') + MatlabFunctionExprImpl(FUNCTION_EXPR) + MatlabRefExprImpl(REF_EXPR) + PsiElement(IDENTIFIER)('mustBeMember') + MatlabArgumentsImpl(ARGUMENTS) + PsiElement(()('(') + MatlabRefExprImpl(REF_EXPR) + PsiElement(IDENTIFIER)('Label') + PsiElement(,)(',') + MatlabLiteralExprImpl(LITERAL_EXPR) + MatlabCellArrayLiteralImpl(CELL_ARRAY_LITERAL) + PsiElement({)('{') + MatlabCellArrayRowImpl(CELL_ARRAY_ROW) + MatlabCellArrayItemImpl(CELL_ARRAY_ITEM) + MatlabLiteralExprImpl(LITERAL_EXPR) + PsiElement(SINGLE_QUOTE_STRING)(''High'') + PsiElement(,)(',') + MatlabCellArrayItemImpl(CELL_ARRAY_ITEM) + MatlabLiteralExprImpl(LITERAL_EXPR) + PsiElement(SINGLE_QUOTE_STRING)(''Medium'') + PsiElement(,)(',') + MatlabCellArrayItemImpl(CELL_ARRAY_ITEM) + MatlabLiteralExprImpl(LITERAL_EXPR) + PsiElement(SINGLE_QUOTE_STRING)(''Low'') + PsiElement(})('}') + PsiElement())(')') + PsiElement(})('}') + PsiWhiteSpace(' ') + PsiElement(=)('=') + PsiWhiteSpace(' ') + MatlabDefaultValueImpl(DEFAULT_VALUE) + MatlabLiteralExprImpl(LITERAL_EXPR) + PsiElement(SINGLE_QUOTE_STRING)(''Low'') + PsiElement(NEWLINE)('\n') + PsiWhiteSpace(' ') + PsiElement(end)('end') + PsiElement(NEWLINE)('\n') PsiElement(end)('end') \ No newline at end of file diff --git a/testData/parser/Enumeration.txt b/testData/parser/Enumeration.txt index c0dde95..fa8cca9 100644 --- a/testData/parser/Enumeration.txt +++ b/testData/parser/Enumeration.txt @@ -21,72 +21,59 @@ Matlab File PsiElement(enumeration)('enumeration') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('millisecond') + MatlabEnumItemImpl(ENUM_ITEM) + PsiElement(IDENTIFIER)('millisecond') + PsiWhiteSpace(' ') + MatlabArgumentsImpl(ARGUMENTS) + PsiElement(()('(') + MatlabRdivExprImpl(RDIV_EXPR) + MatlabLiteralExprImpl(LITERAL_EXPR) + PsiElement(INTEGER)('1') + PsiElement(/)('/') + MatlabLiteralExprImpl(LITERAL_EXPR) + PsiElement(INTEGER)('1000') + PsiElement())(')') + PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') - MatlabArgumentsImpl(ARGUMENTS) - PsiElement(()('(') - MatlabRdivExprImpl(RDIV_EXPR) + MatlabEnumItemImpl(ENUM_ITEM) + PsiElement(IDENTIFIER)('second') + PsiWhiteSpace(' ') + MatlabArgumentsImpl(ARGUMENTS) + PsiElement(()('(') MatlabLiteralExprImpl(LITERAL_EXPR) PsiElement(INTEGER)('1') - PsiElement(/)('/') - MatlabLiteralExprImpl(LITERAL_EXPR) - PsiElement(INTEGER)('1000') - PsiElement())(')') - PsiElement(NEWLINE)('\n') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('second') - PsiWhiteSpace(' ') - MatlabArgumentsImpl(ARGUMENTS) - PsiElement(()('(') - MatlabLiteralExprImpl(LITERAL_EXPR) - PsiElement(INTEGER)('1') - PsiElement())(')') - PsiElement(NEWLINE)('\n') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('minute') - PsiWhiteSpace(' ') - MatlabArgumentsImpl(ARGUMENTS) - PsiElement(()('(') - MatlabLiteralExprImpl(LITERAL_EXPR) - PsiElement(INTEGER)('60') - PsiElement())(')') + PsiElement())(')') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('hour') - PsiWhiteSpace(' ') - MatlabArgumentsImpl(ARGUMENTS) - PsiElement(()('(') - MatlabMulExprImpl(MUL_EXPR) - MatlabLiteralExprImpl(LITERAL_EXPR) - PsiElement(INTEGER)('60') - PsiElement(*)('*') + MatlabEnumItemImpl(ENUM_ITEM) + PsiElement(IDENTIFIER)('minute') + PsiWhiteSpace(' ') + MatlabArgumentsImpl(ARGUMENTS) + PsiElement(()('(') MatlabLiteralExprImpl(LITERAL_EXPR) PsiElement(INTEGER)('60') - PsiElement())(')') + PsiElement())(')') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('day') - PsiWhiteSpace(' ') - MatlabArgumentsImpl(ARGUMENTS) - PsiElement(()('(') - MatlabMulExprImpl(MUL_EXPR) + MatlabEnumItemImpl(ENUM_ITEM) + PsiElement(IDENTIFIER)('hour') + PsiWhiteSpace(' ') + MatlabArgumentsImpl(ARGUMENTS) + PsiElement(()('(') MatlabMulExprImpl(MUL_EXPR) MatlabLiteralExprImpl(LITERAL_EXPR) PsiElement(INTEGER)('60') PsiElement(*)('*') MatlabLiteralExprImpl(LITERAL_EXPR) PsiElement(INTEGER)('60') - PsiElement(*)('*') - MatlabLiteralExprImpl(LITERAL_EXPR) - PsiElement(INTEGER)('24') - PsiElement())(')') + PsiElement())(')') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('week') - PsiWhiteSpace(' ') - MatlabArgumentsImpl(ARGUMENTS) - PsiElement(()('(') - MatlabMulExprImpl(MUL_EXPR) + MatlabEnumItemImpl(ENUM_ITEM) + PsiElement(IDENTIFIER)('day') + PsiWhiteSpace(' ') + MatlabArgumentsImpl(ARGUMENTS) + PsiElement(()('(') MatlabMulExprImpl(MUL_EXPR) MatlabMulExprImpl(MUL_EXPR) MatlabLiteralExprImpl(LITERAL_EXPR) @@ -97,10 +84,29 @@ Matlab File PsiElement(*)('*') MatlabLiteralExprImpl(LITERAL_EXPR) PsiElement(INTEGER)('24') - PsiElement(*)('*') - MatlabLiteralExprImpl(LITERAL_EXPR) - PsiElement(INTEGER)('7') - PsiElement())(')') + PsiElement())(')') + PsiElement(NEWLINE)('\n') + PsiWhiteSpace(' ') + MatlabEnumItemImpl(ENUM_ITEM) + PsiElement(IDENTIFIER)('week') + PsiWhiteSpace(' ') + MatlabArgumentsImpl(ARGUMENTS) + PsiElement(()('(') + MatlabMulExprImpl(MUL_EXPR) + MatlabMulExprImpl(MUL_EXPR) + MatlabMulExprImpl(MUL_EXPR) + MatlabLiteralExprImpl(LITERAL_EXPR) + PsiElement(INTEGER)('60') + PsiElement(*)('*') + MatlabLiteralExprImpl(LITERAL_EXPR) + PsiElement(INTEGER)('60') + PsiElement(*)('*') + MatlabLiteralExprImpl(LITERAL_EXPR) + PsiElement(INTEGER)('24') + PsiElement(*)('*') + MatlabLiteralExprImpl(LITERAL_EXPR) + PsiElement(INTEGER)('7') + PsiElement())(')') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') PsiElement(end)('end') @@ -111,7 +117,7 @@ Matlab File PsiElement(methods)('methods') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') - MatlabBlockImpl(BLOCK) + MatlabMethodsListImpl(METHODS_LIST) MatlabFunctionDeclarationImpl(FUNCTION_DECLARATION) PsiElement(function)('function') PsiWhiteSpace(' ') @@ -168,19 +174,24 @@ Matlab File PsiElement(enumeration)('enumeration') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('Monday') + MatlabEnumItemImpl(ENUM_ITEM) + PsiElement(IDENTIFIER)('Monday') PsiElement(,)(',') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('Tuesday') + MatlabEnumItemImpl(ENUM_ITEM) + PsiElement(IDENTIFIER)('Tuesday') PsiElement(,)(',') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('Wednesday') + MatlabEnumItemImpl(ENUM_ITEM) + PsiElement(IDENTIFIER)('Wednesday') PsiElement(,)(',') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('Thursday') + MatlabEnumItemImpl(ENUM_ITEM) + PsiElement(IDENTIFIER)('Thursday') PsiElement(,)(',') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('Friday') + MatlabEnumItemImpl(ENUM_ITEM) + PsiElement(IDENTIFIER)('Friday') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') PsiElement(end)('end') @@ -219,40 +230,44 @@ Matlab File PsiElement(enumeration)('enumeration') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('North') - PsiWhiteSpace(' ') - MatlabArgumentsImpl(ARGUMENTS) - PsiElement(()('(') - MatlabLiteralExprImpl(LITERAL_EXPR) - PsiElement(INTEGER)('0') - PsiElement())(')') + MatlabEnumItemImpl(ENUM_ITEM) + PsiElement(IDENTIFIER)('North') + PsiWhiteSpace(' ') + MatlabArgumentsImpl(ARGUMENTS) + PsiElement(()('(') + MatlabLiteralExprImpl(LITERAL_EXPR) + PsiElement(INTEGER)('0') + PsiElement())(')') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('East') - PsiWhiteSpace(' ') - MatlabArgumentsImpl(ARGUMENTS) - PsiElement(()('(') - MatlabLiteralExprImpl(LITERAL_EXPR) - PsiElement(INTEGER)('90') - PsiElement())(')') + MatlabEnumItemImpl(ENUM_ITEM) + PsiElement(IDENTIFIER)('East') + PsiWhiteSpace(' ') + MatlabArgumentsImpl(ARGUMENTS) + PsiElement(()('(') + MatlabLiteralExprImpl(LITERAL_EXPR) + PsiElement(INTEGER)('90') + PsiElement())(')') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('South') - PsiWhiteSpace(' ') - MatlabArgumentsImpl(ARGUMENTS) - PsiElement(()('(') - MatlabLiteralExprImpl(LITERAL_EXPR) - PsiElement(INTEGER)('180') - PsiElement())(')') + MatlabEnumItemImpl(ENUM_ITEM) + PsiElement(IDENTIFIER)('South') + PsiWhiteSpace(' ') + MatlabArgumentsImpl(ARGUMENTS) + PsiElement(()('(') + MatlabLiteralExprImpl(LITERAL_EXPR) + PsiElement(INTEGER)('180') + PsiElement())(')') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('West') - PsiWhiteSpace(' ') - MatlabArgumentsImpl(ARGUMENTS) - PsiElement(()('(') - MatlabLiteralExprImpl(LITERAL_EXPR) - PsiElement(INTEGER)('270') - PsiElement())(')') + MatlabEnumItemImpl(ENUM_ITEM) + PsiElement(IDENTIFIER)('West') + PsiWhiteSpace(' ') + MatlabArgumentsImpl(ARGUMENTS) + PsiElement(()('(') + MatlabLiteralExprImpl(LITERAL_EXPR) + PsiElement(INTEGER)('270') + PsiElement())(')') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') PsiElement(end)('end') @@ -270,19 +285,24 @@ Matlab File PsiElement(enumeration)('enumeration') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('Monday') + MatlabEnumItemImpl(ENUM_ITEM) + PsiElement(IDENTIFIER)('Monday') PsiElement(,)(',') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('Tuesday') + MatlabEnumItemImpl(ENUM_ITEM) + PsiElement(IDENTIFIER)('Tuesday') PsiElement(,)(',') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('Wednesday') + MatlabEnumItemImpl(ENUM_ITEM) + PsiElement(IDENTIFIER)('Wednesday') PsiElement(,)(',') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('Thursday') + MatlabEnumItemImpl(ENUM_ITEM) + PsiElement(IDENTIFIER)('Thursday') PsiElement(,)(',') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('Friday') + MatlabEnumItemImpl(ENUM_ITEM) + PsiElement(IDENTIFIER)('Friday') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') PsiElement(end)('end') @@ -292,7 +312,7 @@ Matlab File PsiElement(methods)('methods') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') - MatlabBlockImpl(BLOCK) + MatlabMethodsListImpl(METHODS_LIST) MatlabFunctionDeclarationImpl(FUNCTION_DECLARATION) PsiElement(function)('function') PsiWhiteSpace(' ') @@ -355,16 +375,16 @@ Matlab File PsiElement(properties)('properties') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') - MatlabBlockImpl(BLOCK) - MatlabRefExprImpl(REF_EXPR) + MatlabPropertiesListImpl(PROPERTIES_LIST) + MatlabPropertyImpl(PROPERTY) PsiElement(IDENTIFIER)('R') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') - MatlabRefExprImpl(REF_EXPR) + MatlabPropertyImpl(PROPERTY) PsiElement(IDENTIFIER)('G') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') - MatlabRefExprImpl(REF_EXPR) + MatlabPropertyImpl(PROPERTY) PsiElement(IDENTIFIER)('B') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') @@ -375,7 +395,7 @@ Matlab File PsiElement(methods)('methods') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') - MatlabBlockImpl(BLOCK) + MatlabMethodsListImpl(METHODS_LIST) MatlabFunctionDeclarationImpl(FUNCTION_DECLARATION) PsiElement(function)('function') PsiWhiteSpace(' ') @@ -455,72 +475,76 @@ Matlab File PsiElement(enumeration)('enumeration') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('Error') - PsiWhiteSpace(' ') - MatlabArgumentsImpl(ARGUMENTS) - PsiElement(()('(') - MatlabLiteralExprImpl(LITERAL_EXPR) - PsiElement(INTEGER)('1') - PsiElement(,)(',') - PsiWhiteSpace(' ') - MatlabLiteralExprImpl(LITERAL_EXPR) - PsiElement(INTEGER)('0') - PsiElement(,)(',') - PsiWhiteSpace(' ') - MatlabLiteralExprImpl(LITERAL_EXPR) - PsiElement(INTEGER)('0') - PsiElement())(')') + MatlabEnumItemImpl(ENUM_ITEM) + PsiElement(IDENTIFIER)('Error') + PsiWhiteSpace(' ') + MatlabArgumentsImpl(ARGUMENTS) + PsiElement(()('(') + MatlabLiteralExprImpl(LITERAL_EXPR) + PsiElement(INTEGER)('1') + PsiElement(,)(',') + PsiWhiteSpace(' ') + MatlabLiteralExprImpl(LITERAL_EXPR) + PsiElement(INTEGER)('0') + PsiElement(,)(',') + PsiWhiteSpace(' ') + MatlabLiteralExprImpl(LITERAL_EXPR) + PsiElement(INTEGER)('0') + PsiElement())(')') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('Comment') - PsiWhiteSpace(' ') - MatlabArgumentsImpl(ARGUMENTS) - PsiElement(()('(') - MatlabLiteralExprImpl(LITERAL_EXPR) - PsiElement(INTEGER)('0') - PsiElement(,)(',') - PsiWhiteSpace(' ') - MatlabLiteralExprImpl(LITERAL_EXPR) - PsiElement(INTEGER)('1') - PsiElement(,)(',') + MatlabEnumItemImpl(ENUM_ITEM) + PsiElement(IDENTIFIER)('Comment') PsiWhiteSpace(' ') - MatlabLiteralExprImpl(LITERAL_EXPR) - PsiElement(INTEGER)('0') - PsiElement())(')') + MatlabArgumentsImpl(ARGUMENTS) + PsiElement(()('(') + MatlabLiteralExprImpl(LITERAL_EXPR) + PsiElement(INTEGER)('0') + PsiElement(,)(',') + PsiWhiteSpace(' ') + MatlabLiteralExprImpl(LITERAL_EXPR) + PsiElement(INTEGER)('1') + PsiElement(,)(',') + PsiWhiteSpace(' ') + MatlabLiteralExprImpl(LITERAL_EXPR) + PsiElement(INTEGER)('0') + PsiElement())(')') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('Keyword') - PsiWhiteSpace(' ') - MatlabArgumentsImpl(ARGUMENTS) - PsiElement(()('(') - MatlabLiteralExprImpl(LITERAL_EXPR) - PsiElement(INTEGER)('0') - PsiElement(,)(',') + MatlabEnumItemImpl(ENUM_ITEM) + PsiElement(IDENTIFIER)('Keyword') PsiWhiteSpace(' ') - MatlabLiteralExprImpl(LITERAL_EXPR) - PsiElement(INTEGER)('0') - PsiElement(,)(',') - PsiWhiteSpace(' ') - MatlabLiteralExprImpl(LITERAL_EXPR) - PsiElement(INTEGER)('1') - PsiElement())(')') + MatlabArgumentsImpl(ARGUMENTS) + PsiElement(()('(') + MatlabLiteralExprImpl(LITERAL_EXPR) + PsiElement(INTEGER)('0') + PsiElement(,)(',') + PsiWhiteSpace(' ') + MatlabLiteralExprImpl(LITERAL_EXPR) + PsiElement(INTEGER)('0') + PsiElement(,)(',') + PsiWhiteSpace(' ') + MatlabLiteralExprImpl(LITERAL_EXPR) + PsiElement(INTEGER)('1') + PsiElement())(')') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('String') - PsiWhiteSpace(' ') - MatlabArgumentsImpl(ARGUMENTS) - PsiElement(()('(') - MatlabLiteralExprImpl(LITERAL_EXPR) - PsiElement(INTEGER)('1') - PsiElement(,)(',') - PsiWhiteSpace(' ') - MatlabLiteralExprImpl(LITERAL_EXPR) - PsiElement(INTEGER)('0') - PsiElement(,)(',') - PsiWhiteSpace(' ') - MatlabLiteralExprImpl(LITERAL_EXPR) - PsiElement(INTEGER)('1') - PsiElement())(')') + MatlabEnumItemImpl(ENUM_ITEM) + PsiElement(IDENTIFIER)('String') + PsiWhiteSpace(' ') + MatlabArgumentsImpl(ARGUMENTS) + PsiElement(()('(') + MatlabLiteralExprImpl(LITERAL_EXPR) + PsiElement(INTEGER)('1') + PsiElement(,)(',') + PsiWhiteSpace(' ') + MatlabLiteralExprImpl(LITERAL_EXPR) + PsiElement(INTEGER)('0') + PsiElement(,)(',') + PsiWhiteSpace(' ') + MatlabLiteralExprImpl(LITERAL_EXPR) + PsiElement(INTEGER)('1') + PsiElement())(')') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') PsiElement(end)('end') @@ -544,22 +568,24 @@ Matlab File PsiElement(enumeration)('enumeration') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('No') - PsiWhiteSpace(' ') - MatlabArgumentsImpl(ARGUMENTS) - PsiElement(()('(') - MatlabLiteralExprImpl(LITERAL_EXPR) - PsiElement(INTEGER)('0') - PsiElement())(')') + MatlabEnumItemImpl(ENUM_ITEM) + PsiElement(IDENTIFIER)('No') + PsiWhiteSpace(' ') + MatlabArgumentsImpl(ARGUMENTS) + PsiElement(()('(') + MatlabLiteralExprImpl(LITERAL_EXPR) + PsiElement(INTEGER)('0') + PsiElement())(')') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('Yes') - PsiWhiteSpace(' ') - MatlabArgumentsImpl(ARGUMENTS) - PsiElement(()('(') - MatlabLiteralExprImpl(LITERAL_EXPR) - PsiElement(INTEGER)('1') - PsiElement())(')') + MatlabEnumItemImpl(ENUM_ITEM) + PsiElement(IDENTIFIER)('Yes') + PsiWhiteSpace(' ') + MatlabArgumentsImpl(ARGUMENTS) + PsiElement(()('(') + MatlabLiteralExprImpl(LITERAL_EXPR) + PsiElement(INTEGER)('1') + PsiElement())(')') PsiElement(NEWLINE)('\n') PsiWhiteSpace(' ') PsiElement(end)('end') diff --git a/testData/resolve/ClassInside.m b/testData/resolve/ClassInside.m new file mode 100644 index 0000000..745207d --- /dev/null +++ b/testData/resolve/ClassInside.m @@ -0,0 +1,10 @@ +classdef ClassInside + properties + Prop + end + methods + function obj = foo(obj) + obj.Prop + end + end +end \ No newline at end of file diff --git a/testData/resolve/multifile/Constructor.m b/testData/resolve/multifile/Constructor.m new file mode 100644 index 0000000..d5fc589 --- /dev/null +++ b/testData/resolve/multifile/Constructor.m @@ -0,0 +1,2 @@ +a = ConstructorDeclaration(1) +a.Prop \ No newline at end of file diff --git a/testData/resolve/multifile/ConstructorDeclaration.m b/testData/resolve/multifile/ConstructorDeclaration.m new file mode 100644 index 0000000..585156f --- /dev/null +++ b/testData/resolve/multifile/ConstructorDeclaration.m @@ -0,0 +1,10 @@ +classdef ConstructorDeclaration + properties + Prop + end + methods + function obj = ConstructorDeclaration(x) + obj.Prop = x; + end + end +end \ No newline at end of file diff --git a/testData/resolve/multifile/FindClassInAssign.m b/testData/resolve/multifile/FindClassInAssign.m new file mode 100644 index 0000000..6c4896c --- /dev/null +++ b/testData/resolve/multifile/FindClassInAssign.m @@ -0,0 +1,3 @@ +a = FindClassInAssignDeclaration() +b = a +b.Prop \ No newline at end of file diff --git a/testData/resolve/multifile/FindClassInAssignDeclaration.m b/testData/resolve/multifile/FindClassInAssignDeclaration.m new file mode 100644 index 0000000..801bd4b --- /dev/null +++ b/testData/resolve/multifile/FindClassInAssignDeclaration.m @@ -0,0 +1,5 @@ +classdef FindClassInAssignDeclaration + properties + Prop + end +end \ No newline at end of file diff --git a/testData/resolve/multifile/FindClassInMethod.m b/testData/resolve/multifile/FindClassInMethod.m new file mode 100644 index 0000000..7f00965 --- /dev/null +++ b/testData/resolve/multifile/FindClassInMethod.m @@ -0,0 +1,2 @@ +a = FindClassInMethodDeclaration().withX(1) +a.Prop \ No newline at end of file diff --git a/testData/resolve/multifile/FindClassInMethodDeclaration.m b/testData/resolve/multifile/FindClassInMethodDeclaration.m new file mode 100644 index 0000000..98a90ec --- /dev/null +++ b/testData/resolve/multifile/FindClassInMethodDeclaration.m @@ -0,0 +1,10 @@ +classdef FindClassInMethodDeclaration + properties + Prop + end + methods + function obj = withX(obj, x) + obj.Prop = x + end + end +end \ No newline at end of file diff --git a/testData/resolve/multifile/FindClassInProp.m b/testData/resolve/multifile/FindClassInProp.m new file mode 100644 index 0000000..0971e06 --- /dev/null +++ b/testData/resolve/multifile/FindClassInProp.m @@ -0,0 +1,3 @@ +a = FindClassInPropAdd() +b = a.Prop +b.Prop \ No newline at end of file diff --git a/testData/resolve/multifile/FindClassInPropAdd.m b/testData/resolve/multifile/FindClassInPropAdd.m new file mode 100644 index 0000000..d495356 --- /dev/null +++ b/testData/resolve/multifile/FindClassInPropAdd.m @@ -0,0 +1,5 @@ +classdef FindClassInPropAdd + properties + Prop FindClassInPropDeclaration + end +end \ No newline at end of file diff --git a/testData/resolve/multifile/FindClassInPropDeclaration.m b/testData/resolve/multifile/FindClassInPropDeclaration.m new file mode 100644 index 0000000..f221be2 --- /dev/null +++ b/testData/resolve/multifile/FindClassInPropDeclaration.m @@ -0,0 +1,5 @@ +classdef FindClassInPropDeclaration + properties + Prop + end +end \ No newline at end of file diff --git a/testData/resolve/multifile/Method.m b/testData/resolve/multifile/Method.m new file mode 100644 index 0000000..9e019ba --- /dev/null +++ b/testData/resolve/multifile/Method.m @@ -0,0 +1,2 @@ +a = MethodDeclaration() +foo(a) \ No newline at end of file diff --git a/testData/resolve/multifile/MethodDeclaration.m b/testData/resolve/multifile/MethodDeclaration.m new file mode 100644 index 0000000..09afbf5 --- /dev/null +++ b/testData/resolve/multifile/MethodDeclaration.m @@ -0,0 +1,6 @@ +classdef MethodDeclaration + methods + function obj = foo(obj) + end + end +end \ No newline at end of file diff --git a/testData/resolve/multifile/MethodDotNotation.m b/testData/resolve/multifile/MethodDotNotation.m new file mode 100644 index 0000000..62c55cd --- /dev/null +++ b/testData/resolve/multifile/MethodDotNotation.m @@ -0,0 +1 @@ +MethodDotNotationDeclaration.foo() \ No newline at end of file diff --git a/testData/resolve/multifile/MethodDotNotationDeclaration.m b/testData/resolve/multifile/MethodDotNotationDeclaration.m new file mode 100644 index 0000000..ff1983b --- /dev/null +++ b/testData/resolve/multifile/MethodDotNotationDeclaration.m @@ -0,0 +1,6 @@ +classdef MethodDotNotationDeclaration + methods + function foo() + end + end +end \ No newline at end of file diff --git a/testData/resolve/multifile/NestedQualified.m b/testData/resolve/multifile/NestedQualified.m new file mode 100644 index 0000000..ceda386 --- /dev/null +++ b/testData/resolve/multifile/NestedQualified.m @@ -0,0 +1 @@ +a = NestedQualifiedAdd().withX().Prop.Prop \ No newline at end of file diff --git a/testData/resolve/multifile/NestedQualifiedAdd.m b/testData/resolve/multifile/NestedQualifiedAdd.m new file mode 100644 index 0000000..f18efba --- /dev/null +++ b/testData/resolve/multifile/NestedQualifiedAdd.m @@ -0,0 +1,10 @@ +classdef NestedQualifiedAdd + properties + Prop NestedQualifiedDeclaration + end + methods + function obj = withX(obj, x) + obj.Prop = x + end + end +end \ No newline at end of file diff --git a/testData/resolve/multifile/NestedQualifiedDeclaration.m b/testData/resolve/multifile/NestedQualifiedDeclaration.m new file mode 100644 index 0000000..baf7f8f --- /dev/null +++ b/testData/resolve/multifile/NestedQualifiedDeclaration.m @@ -0,0 +1,5 @@ +classdef NestedQualifiedDeclaration + properties + Prop + end +end \ No newline at end of file diff --git a/testData/resolve/multifile/Property.m b/testData/resolve/multifile/Property.m new file mode 100644 index 0000000..0464a0b --- /dev/null +++ b/testData/resolve/multifile/Property.m @@ -0,0 +1 @@ +PropertyDeclaration.Prop \ No newline at end of file diff --git a/testData/resolve/multifile/PropertyDeclaration.m b/testData/resolve/multifile/PropertyDeclaration.m new file mode 100644 index 0000000..505c10a --- /dev/null +++ b/testData/resolve/multifile/PropertyDeclaration.m @@ -0,0 +1,5 @@ +classdef PropertyDeclaration + properties + Prop + end +end \ No newline at end of file diff --git a/tests/com/github/kornilova203/matlab/resolve/MultifileResolveTest.kt b/tests/com/github/kornilova203/matlab/resolve/MultifileResolveTest.kt index ca513c6..d1e10c3 100644 --- a/tests/com/github/kornilova203/matlab/resolve/MultifileResolveTest.kt +++ b/tests/com/github/kornilova203/matlab/resolve/MultifileResolveTest.kt @@ -5,7 +5,6 @@ import com.github.kornilova203.matlab.psi.MatlabDeclaration import com.intellij.testFramework.fixtures.BasePlatformTestCase import junit.framework.TestCase import java.io.File -import kotlin.test.assertNotEquals private const val DECL_MARKER = "" private const val REF_MARKER = "" @@ -19,6 +18,14 @@ class MultifileResolveTest : BasePlatformTestCase() { fun testVariableUnresolved() = doTestUnresolved("a") fun testGlobal() = doTestMulti("a", 2) fun testGlobalUnresolved() = doTestUnresolved("a") + fun testProperty() = doTest("Prop") + fun testMethodDotNotation() = doTest("foo") + fun testConstructor() = doTest("Prop") + fun testFindClassInAssign() = doTest("Prop") + fun testFindClassInMethod() = doTest("Prop") + fun testFindClassInProp() = doTestWithAdditionalFile("Prop") + fun testNestedQualified() = doTestWithAdditionalFile("Prop") + fun testMethod() = doTest("foo") private fun doTest(name: String, shouldBeResolved: Boolean = true) { val testName = testDataPath + getTestName(false) @@ -51,6 +58,11 @@ class MultifileResolveTest : BasePlatformTestCase() { assertEquals(name, element.nameIdentifier?.text) } } + + private fun doTestWithAdditionalFile(name: String) { + myFixture.configureByFile(getTestName(false) + "Add.m") + doTest(name) + } private fun getExpectedDeclaration(refFileOriginal: File, declFileOriginal: File): Pair { val refFileText = refFileOriginal.readText() diff --git a/tests/com/github/kornilova203/matlab/resolve/ResolveTest.kt b/tests/com/github/kornilova203/matlab/resolve/ResolveTest.kt index 17f1d78..1d6319a 100644 --- a/tests/com/github/kornilova203/matlab/resolve/ResolveTest.kt +++ b/tests/com/github/kornilova203/matlab/resolve/ResolveTest.kt @@ -36,6 +36,7 @@ class ResolveTest : BasePlatformTestCase() { fun testGlobal() = doTest("b") fun testGlobalInBlock() = doTest("a") fun testNotFunctionCall() = doTest("foo") + fun testClassInside() = doTest("Prop") private fun doTest(name: String, shouldBeResolved: Boolean = true) { val file = File(testDataPath + getTestName(false) + ".m") @@ -53,7 +54,8 @@ class ResolveTest : BasePlatformTestCase() { private fun doTestUnresolved() = doTest(name, false) - private fun getExpectedDeclaration(fileText: String): Pair { + private fun getExpectedDeclaration(fileTex: String): Pair { + val fileText = fileTex.replace("\r", "") var declOffset = fileText.indexOf(DECL_MARKER) var refOffset = fileText.indexOf(REF_MARKER) val clearText: String = when {