src/eric7/Utilities/ModuleParser.py

branch
eric7
changeset 9739
d527cfe919ae
parent 9733
c5c2a74e9382
child 9786
f94b530722af
equal deleted inserted replaced
9738:4ae976ee5339 9739:d527cfe919ae
19 import os 19 import os
20 import re 20 import re
21 import sys 21 import sys
22 22
23 from functools import reduce 23 from functools import reduce
24
25 from PyQt6.QtCore import QRegularExpression
26 24
27 from eric7 import Utilities 25 from eric7 import Utilities
28 26
29 __all__ = [ 27 __all__ = [
30 "Attribute", 28 "Attribute",
64 return TYPE_MAPPING[name] 62 return TYPE_MAPPING[name]
65 else: 63 else:
66 return -1 64 return -1
67 65
68 66
69 _py_getnext = QRegularExpression( 67 _py_getnext = re.compile(
70 r""" 68 r"""
71 (?P<Comment> 69 (?P<Comment>
72 \# .*? $ # ignore everything in comments 70 \# .*? $ # ignore everything in comments
73 ) 71 )
74 72
212 ^ 210 ^
213 (?P<ConditionalDefineIndent> [ \t]* ) 211 (?P<ConditionalDefineIndent> [ \t]* )
214 (?: (?: if | elif ) [ \t]+ [^:]* | else [ \t]* ) : 212 (?: (?: if | elif ) [ \t]+ [^:]* | else [ \t]* ) :
215 (?= \s* (?: async [ \t]+ )? def) 213 (?= \s* (?: async [ \t]+ )? def)
216 )""", 214 )""",
217 QRegularExpression.PatternOption.MultilineOption 215 re.VERBOSE | re.DOTALL | re.MULTILINE,
218 | QRegularExpression.PatternOption.DotMatchesEverythingOption 216 ).search
219 | QRegularExpression.PatternOption.ExtendedPatternSyntaxOption 217
220 | QRegularExpression.PatternOption.UseUnicodePropertiesOption, 218 _rb_getnext = re.compile(
221 ).match
222
223 _rb_getnext = QRegularExpression(
224 r""" 219 r"""
225 (?P<Docstring> 220 (?P<Docstring>
226 =begin [ \t]+ edoc (?P<DocstringContents> .*? ) =end 221 =begin [ \t]+ edoc (?P<DocstringContents> .*? ) =end
227 ) 222 )
228 223
353 end [ \t]* $ 348 end [ \t]* $
354 | 349 |
355 end \b [^_] 350 end \b [^_]
356 ) 351 )
357 )""", 352 )""",
358 QRegularExpression.PatternOption.MultilineOption 353 re.VERBOSE | re.DOTALL | re.MULTILINE,
359 | QRegularExpression.PatternOption.DotMatchesEverythingOption 354 ).search
360 | QRegularExpression.PatternOption.ExtendedPatternSyntaxOption
361 | QRegularExpression.PatternOption.UseUnicodePropertiesOption,
362 ).match
363 355
364 _hashsub = re.compile(r"""^([ \t]*)#[ \t]?""", re.MULTILINE).sub 356 _hashsub = re.compile(r"""^([ \t]*)#[ \t]?""", re.MULTILINE).sub
365 357
366 _commentsub = re.compile(r"""#[^\n]*\n|#[^\n]*$""").sub 358 _commentsub = re.compile(r"""#[^\n]*\n|#[^\n]*$""").sub
367 359
587 cur_obj = self 579 cur_obj = self
588 modifierType = Function.General 580 modifierType = Function.General
589 modifierIndent = -1 581 modifierIndent = -1
590 while True: 582 while True:
591 m = self._getnext(src, i) 583 m = self._getnext(src, i)
592 if not m.hasMatch(): 584 if not m:
593 break 585 break
594 start, i = m.capturedStart(), m.capturedEnd() 586 start, i = m.span()
595 587
596 if m.captured("MethodModifier"): 588 if m.start("MethodModifier") >= 0:
597 modifierIndent = _indent(m.captured("MethodModifierIndent")) 589 modifierIndent = _indent(m.group("MethodModifierIndent"))
598 modifierType = m.captured("MethodModifierType") 590 modifierType = m.group("MethodModifierType")
599 591
600 elif m.captured("Method"): 592 elif m.start("Method") >= 0:
601 # found a method definition or function 593 # found a method definition or function
602 thisindent = _indent(m.captured("MethodIndent")) 594 thisindent = _indent(m.group("MethodIndent"))
603 meth_name = m.captured("MethodName") 595 meth_name = m.group("MethodName")
604 meth_sig = m.captured("MethodSignature") 596 meth_sig = m.group("MethodSignature")
605 meth_sig = meth_sig.replace("\\\n", "") 597 meth_sig = meth_sig.replace("\\\n", "")
606 meth_ret = m.captured("MethodReturnAnnotation") 598 meth_ret = m.group("MethodReturnAnnotation")
607 meth_ret = meth_ret.replace("\\\n", "") 599 meth_ret = meth_ret.replace("\\\n", "")
608 if m.captured("MethodPyQtSignature"): 600 if m.group("MethodPyQtSignature") is not None:
609 meth_pyqtSig = ( 601 meth_pyqtSig = (
610 m.captured("MethodPyQtSignature") 602 m.group("MethodPyQtSignature")
611 .replace("\\\n", "") 603 .replace("\\\n", "")
612 .split("result")[0] 604 .split("result")[0]
613 .split("name")[0] 605 .split("name")[0]
614 .strip("\"', \t") 606 .strip("\"', \t")
615 ) 607 )
702 694
703 # reset the modifier settings 695 # reset the modifier settings
704 modifierType = Function.General 696 modifierType = Function.General
705 modifierIndent = -1 697 modifierIndent = -1
706 698
707 elif m.captured("Docstring"): 699 elif m.start("Docstring") >= 0:
708 contents = m.captured("DocstringContents3") 700 contents = m.group("DocstringContents3")
709 if contents: 701 if contents is not None:
710 contents = _hashsub(r"\1", contents) 702 contents = _hashsub(r"\1", contents)
711 else: 703 else:
712 if self.file.lower().endswith(".ptl"): 704 if self.file.lower().endswith(".ptl"):
713 contents = "" 705 contents = ""
714 else: 706 else:
715 contents = m.captured("DocstringContents1") or m.captured( 707 contents = m.group("DocstringContents1") or m.group(
716 "DocstringContents2" 708 "DocstringContents2"
717 ) 709 )
718 if cur_obj: 710 if cur_obj:
719 cur_obj.addDescription(contents) 711 cur_obj.addDescription(contents)
720 712
721 elif m.captured("String"): 713 elif m.start("String") >= 0:
722 if modulelevel and ( 714 if modulelevel and (
723 src[start - len("\r\n") : start] == "\r\n" 715 src[start - len("\r\n") : start] == "\r\n"
724 or src[start - len("\n") : start] == "\n" 716 or src[start - len("\n") : start] == "\n"
725 or src[start - len("\r") : start] == "\r" 717 or src[start - len("\r") : start] == "\r"
726 ): 718 ):
727 contents = m.captured("StringContents3") 719 contents = m.group("StringContents3")
728 if contents: 720 if contents is not None:
729 contents = _hashsub(r"\1", contents) 721 contents = _hashsub(r"\1", contents)
730 else: 722 else:
731 if self.file.lower().endswith(".ptl"): 723 if self.file.lower().endswith(".ptl"):
732 contents = "" 724 contents = ""
733 else: 725 else:
734 contents = m.captured("StringContents1") or m.captured( 726 contents = m.group("StringContents1") or m.group(
735 "StringContents2" 727 "StringContents2"
736 ) 728 )
737 if cur_obj: 729 if cur_obj:
738 cur_obj.addDescription(contents) 730 cur_obj.addDescription(contents)
739 731
740 elif m.captured("Class"): 732 elif m.start("Class") >= 0:
741 # we found a class definition 733 # we found a class definition
742 thisindent = _indent(m.captured("ClassIndent")) 734 thisindent = _indent(m.group("ClassIndent"))
743 lineno += src.count("\n", last_lineno_pos, start) 735 lineno += src.count("\n", last_lineno_pos, start)
744 last_lineno_pos = start 736 last_lineno_pos = start
745 # close all classes indented at least as much 737 # close all classes indented at least as much
746 while classstack and classstack[-1][1] >= thisindent: 738 while classstack and classstack[-1][1] >= thisindent:
747 del classstack[-1] 739 del classstack[-1]
748 class_name = m.captured("ClassName") 740 class_name = m.group("ClassName")
749 inherit = m.captured("ClassSupers") 741 inherit = m.group("ClassSupers")
750 if inherit: 742 if inherit:
751 # the class inherits from other classes 743 # the class inherits from other classes
752 inherit = inherit[1:-1].strip() 744 inherit = inherit[1:-1].strip()
753 inherit = _commentsub("", inherit) 745 inherit = _commentsub("", inherit)
754 names = [] 746 names = []
793 cur_obj = cur_class 785 cur_obj = cur_class
794 self.addClass(class_name, cur_class) 786 self.addClass(class_name, cur_class)
795 # add nested classes to the module 787 # add nested classes to the module
796 classstack.append((cur_class, thisindent)) 788 classstack.append((cur_class, thisindent))
797 789
798 elif m.captured("Attribute"): 790 elif m.start("Attribute") >= 0:
799 lineno += src.count("\n", last_lineno_pos, start) 791 lineno += src.count("\n", last_lineno_pos, start)
800 last_lineno_pos = start 792 last_lineno_pos = start
801 index = -1 793 index = -1
802 while index >= -len(classstack): 794 while index >= -len(classstack):
803 if classstack[index][0] is not None: 795 if classstack[index][0] is not None:
804 attrName = m.captured("AttributeName") 796 attrName = m.group("AttributeName")
805 attr = Attribute(self.name, attrName, self.file, lineno) 797 attr = Attribute(self.name, attrName, self.file, lineno)
806 self.__py_setVisibility(attr) 798 self.__py_setVisibility(attr)
807 classstack[index][0].addAttribute(attrName, attr) 799 classstack[index][0].addAttribute(attrName, attr)
808 break 800 break
809 else: 801 else:
810 index -= 1 802 index -= 1
811 803
812 elif m.captured("Main"): 804 elif m.start("Main") >= 0:
813 # 'main' part of the script, reset class stack 805 # 'main' part of the script, reset class stack
814 lineno += src.count("\n", last_lineno_pos, start) 806 lineno += src.count("\n", last_lineno_pos, start)
815 last_lineno_pos = start 807 last_lineno_pos = start
816 classstack = [] 808 classstack = []
817 809
818 elif m.captured("Variable"): 810 elif m.start("Variable") >= 0:
819 thisindent = _indent(m.captured("VariableIndent")) 811 thisindent = _indent(m.group("VariableIndent"))
820 variable_name = m.captured("VariableName") 812 variable_name = m.group("VariableName")
821 isSignal = m.captured("VariableSignal") != "" 813 isSignal = m.group("VariableSignal") != ""
822 lineno += src.count("\n", last_lineno_pos, start) 814 lineno += src.count("\n", last_lineno_pos, start)
823 last_lineno_pos = start 815 last_lineno_pos = start
824 if thisindent == 0: 816 if thisindent == 0:
825 # global variable 817 # global variable
826 attr = Attribute( 818 attr = Attribute(
846 ) 838 )
847 self.__py_setVisibility(attr) 839 self.__py_setVisibility(attr)
848 classstack[index][0].addGlobal(variable_name, attr) 840 classstack[index][0].addGlobal(variable_name, attr)
849 break 841 break
850 842
851 elif m.captured("Import"): 843 elif m.start("Import") >= 0:
852 # - import module 844 # - import module
853 names = [ 845 names = [
854 n.strip() 846 n.strip()
855 for n in "".join(m.captured("ImportList").splitlines()) 847 for n in "".join(m.group("ImportList").splitlines())
856 .replace("\\", "") 848 .replace("\\", "")
857 .split(",") 849 .split(",")
858 ] 850 ]
859 self.imports.extend( 851 self.imports.extend(
860 [name for name in names if name not in self.imports] 852 [name for name in names if name not in self.imports]
861 ) 853 )
862 854
863 elif m.captured("ImportFrom"): 855 elif m.start("ImportFrom") >= 0:
864 # - from module import stuff 856 # - from module import stuff
865 mod = m.captured("ImportFromPath") 857 mod = m.group("ImportFromPath")
866 namesLines = ( 858 namesLines = (
867 m.captured("ImportFromList") 859 m.group("ImportFromList")
868 .replace("(", "") 860 .replace("(", "")
869 .replace(")", "") 861 .replace(")", "")
870 .replace("\\", "") 862 .replace("\\", "")
871 .strip() 863 .strip()
872 .splitlines() 864 .splitlines()
877 self.from_imports[mod] = [] 869 self.from_imports[mod] = []
878 self.from_imports[mod].extend( 870 self.from_imports[mod].extend(
879 [name for name in names if name not in self.from_imports[mod]] 871 [name for name in names if name not in self.from_imports[mod]]
880 ) 872 )
881 873
882 elif m.captured("ConditionalDefine"): 874 elif m.start("ConditionalDefine") >= 0:
883 # a conditional function/method definition 875 # a conditional function/method definition
884 thisindent = _indent(m.captured("ConditionalDefineIndent")) 876 thisindent = _indent(m.group("ConditionalDefineIndent"))
885 while conditionalsstack and conditionalsstack[-1] >= thisindent: 877 while conditionalsstack and conditionalsstack[-1] >= thisindent:
886 del conditionalsstack[-1] 878 del conditionalsstack[-1]
887 if deltastack: 879 if deltastack:
888 del deltastack[-1] 880 del deltastack[-1]
889 conditionalsstack.append(thisindent) 881 conditionalsstack.append(thisindent)
890 deltaindentcalculated = 0 882 deltaindentcalculated = 0
891 883
892 elif m.captured("Comment") and modulelevel: 884 elif m.start("Comment") >= 0 and modulelevel:
893 continue 885 continue
894 886
895 modulelevel = False 887 modulelevel = False
896 888
897 def __rb_scan(self, src): 889 def __rb_scan(self, src):
909 i = 0 901 i = 0
910 cur_obj = self 902 cur_obj = self
911 lastGlobalEntry = None 903 lastGlobalEntry = None
912 while True: 904 while True:
913 m = self._getnext(src, i) 905 m = self._getnext(src, i)
914 if not m.hasMatch(): 906 if not m:
915 break 907 break
916 start, i = m.capturedStart(), m.capturedEnd() 908 start, i = m.span()
917 909
918 if m.captured("Method"): 910 if m.start("Method") >= 0:
919 # found a method definition or function 911 # found a method definition or function
920 thisindent = indent 912 thisindent = indent
921 indent += 1 913 indent += 1
922 meth_name = ( 914 meth_name = (
923 m.captured("MethodName") 915 m.group("MethodName")
924 or m.captured("MethodName2") 916 or m.group("MethodName2")
925 or m.captured("MethodName3") 917 or m.group("MethodName3")
926 ) 918 )
927 meth_sig = m.captured("MethodSignature") 919 meth_sig = m.group("MethodSignature")
928 meth_sig = meth_sig and meth_sig.replace("\\\n", "") or "" 920 meth_sig = meth_sig and meth_sig.replace("\\\n", "") or ""
929 lineno += src.count("\n", last_lineno_pos, start) 921 lineno += src.count("\n", last_lineno_pos, start)
930 last_lineno_pos = start 922 last_lineno_pos = start
931 if meth_name.startswith("self."): 923 if meth_name.startswith("self."):
932 meth_name = meth_name[5:] 924 meth_name = meth_name[5:]
980 if cur_obj and isinstance(cur_obj, Function): 972 if cur_obj and isinstance(cur_obj, Function):
981 cur_obj.setEndLine(lineno - 1) 973 cur_obj.setEndLine(lineno - 1)
982 cur_obj = f 974 cur_obj = f
983 classstack.append((None, thisindent)) # Marker for nested fns 975 classstack.append((None, thisindent)) # Marker for nested fns
984 976
985 elif m.captured("Docstring"): 977 elif m.start("Docstring") >= 0:
986 contents = m.captured("DocstringContents") 978 contents = m.group("DocstringContents")
987 if contents: 979 if contents is not None:
988 contents = _hashsub(r"\1", contents) 980 contents = _hashsub(r"\1", contents)
989 if cur_obj: 981 if cur_obj:
990 cur_obj.addDescription(contents) 982 cur_obj.addDescription(contents)
991 983
992 elif m.captured("Class"): 984 elif m.start("Class") >= 0:
993 # we found a class definition 985 # we found a class definition
994 thisindent = indent 986 thisindent = indent
995 indent += 1 987 indent += 1
996 lineno += src.count("\n", last_lineno_pos, start) 988 lineno += src.count("\n", last_lineno_pos, start)
997 last_lineno_pos = start 989 last_lineno_pos = start
1001 classstack[-1][0], (Class, Function, RbModule) 993 classstack[-1][0], (Class, Function, RbModule)
1002 ): 994 ):
1003 # record the end line of this class, function or module 995 # record the end line of this class, function or module
1004 classstack[-1][0].setEndLine(lineno - 1) 996 classstack[-1][0].setEndLine(lineno - 1)
1005 del classstack[-1] 997 del classstack[-1]
1006 class_name = m.captured("ClassName") or m.captured("ClassName2") 998 class_name = m.group("ClassName") or m.group("ClassName2")
1007 inherit = m.captured("ClassSupers") 999 inherit = m.group("ClassSupers")
1008 if inherit: 1000 if inherit:
1009 # the class inherits from other classes 1001 # the class inherits from other classes
1010 inherit = inherit[1:].strip() 1002 inherit = inherit[1:].strip()
1011 inherit = [_commentsub("", inherit)] 1003 inherit = [_commentsub("", inherit)]
1012 # remember this class 1004 # remember this class
1035 while acstack and acstack[-1][1] >= thisindent: 1027 while acstack and acstack[-1][1] >= thisindent:
1036 del acstack[-1] 1028 del acstack[-1]
1037 acstack.append(["public", thisindent]) 1029 acstack.append(["public", thisindent])
1038 # default access control is 'public' 1030 # default access control is 'public'
1039 1031
1040 elif m.captured("Module"): 1032 elif m.start("Module") >= 0:
1041 # we found a module definition 1033 # we found a module definition
1042 thisindent = indent 1034 thisindent = indent
1043 indent += 1 1035 indent += 1
1044 lineno += src.count("\n", last_lineno_pos, start) 1036 lineno += src.count("\n", last_lineno_pos, start)
1045 last_lineno_pos = start 1037 last_lineno_pos = start
1049 classstack[-1][0], (Class, Function, RbModule) 1041 classstack[-1][0], (Class, Function, RbModule)
1050 ): 1042 ):
1051 # record the end line of this class, function or module 1043 # record the end line of this class, function or module
1052 classstack[-1][0].setEndLine(lineno - 1) 1044 classstack[-1][0].setEndLine(lineno - 1)
1053 del classstack[-1] 1045 del classstack[-1]
1054 module_name = m.captured("ModuleName") 1046 module_name = m.group("ModuleName")
1055 # remember this class 1047 # remember this class
1056 cur_class = RbModule(self.name, module_name, self.file, lineno) 1048 cur_class = RbModule(self.name, module_name, self.file, lineno)
1057 # add nested Ruby modules to the file 1049 # add nested Ruby modules to the file
1058 if module_name in self.modules: 1050 if module_name in self.modules:
1059 cur_class = self.modules[module_name] 1051 cur_class = self.modules[module_name]
1068 while acstack and acstack[-1][1] >= thisindent: 1060 while acstack and acstack[-1][1] >= thisindent:
1069 del acstack[-1] 1061 del acstack[-1]
1070 acstack.append(["public", thisindent]) 1062 acstack.append(["public", thisindent])
1071 # default access control is 'public' 1063 # default access control is 'public'
1072 1064
1073 elif m.captured("AccessControl"): 1065 elif m.start("AccessControl") >= 0:
1074 aclist = m.captured("AccessControlList") 1066 aclist = m.group("AccessControlList")
1075 if not aclist: 1067 if aclist is None:
1076 index = -1 1068 index = -1
1077 while index >= -len(acstack): 1069 while index >= -len(acstack):
1078 if acstack[index][1] < indent: 1070 if acstack[index][1] < indent:
1079 actype = ( 1071 actype = (
1080 m.captured("AccessControlType") 1072 m.group("AccessControlType")
1081 or m.captured("AccessControlType2").split("_")[0] 1073 or m.group("AccessControlType2").split("_")[0]
1082 ) 1074 )
1083 acstack[index][0] = actype.lower() 1075 acstack[index][0] = actype.lower()
1084 break 1076 break
1085 else: 1077 else:
1086 index -= 1 1078 index -= 1
1092 and not isinstance(classstack[index][0], Function) 1084 and not isinstance(classstack[index][0], Function)
1093 and classstack[index][1] < indent 1085 and classstack[index][1] < indent
1094 ): 1086 ):
1095 parent = classstack[index][0] 1087 parent = classstack[index][0]
1096 actype = ( 1088 actype = (
1097 m.captured("AccessControlType") 1089 m.group("AccessControlType")
1098 or m.captured("AccessControlType2").split("_")[0] 1090 or m.group("AccessControlType2").split("_")[0]
1099 ) 1091 )
1100 actype = actype.lower() 1092 actype = actype.lower()
1101 for name in aclist.split(","): 1093 for name in aclist.split(","):
1102 # get rid of leading ':' 1094 # get rid of leading ':'
1103 name = name.strip()[1:] 1095 name = name.strip()[1:]
1112 acmeth.setPublic() 1104 acmeth.setPublic()
1113 break 1105 break
1114 else: 1106 else:
1115 index -= 1 1107 index -= 1
1116 1108
1117 elif m.captured("Attribute"): 1109 elif m.start("Attribute") >= 0:
1118 lineno += src.count("\n", last_lineno_pos, start) 1110 lineno += src.count("\n", last_lineno_pos, start)
1119 last_lineno_pos = start 1111 last_lineno_pos = start
1120 index = -1 1112 index = -1
1121 while index >= -len(classstack): 1113 while index >= -len(classstack):
1122 if ( 1114 if (
1123 classstack[index][0] is not None 1115 classstack[index][0] is not None
1124 and not isinstance(classstack[index][0], Function) 1116 and not isinstance(classstack[index][0], Function)
1125 and classstack[index][1] < indent 1117 and classstack[index][1] < indent
1126 ): 1118 ):
1127 attrName = m.captured("AttributeName") 1119 attrName = m.group("AttributeName")
1128 attr = Attribute(self.name, attrName, self.file, lineno) 1120 attr = Attribute(self.name, attrName, self.file, lineno)
1129 if attrName.startswith("@@") or attrName[0].isupper(): 1121 if attrName.startswith("@@") or attrName[0].isupper():
1130 classstack[index][0].addGlobal(attrName, attr) 1122 classstack[index][0].addGlobal(attrName, attr)
1131 else: 1123 else:
1132 classstack[index][0].addAttribute(attrName, attr) 1124 classstack[index][0].addAttribute(attrName, attr)
1133 break 1125 break
1134 else: 1126 else:
1135 index -= 1 1127 index -= 1
1136 else: 1128 else:
1137 attrName = m.captured("AttributeName") 1129 attrName = m.group("AttributeName")
1138 if attrName[0] != "@": 1130 if attrName[0] != "@":
1139 attr = Attribute(self.name, attrName, self.file, lineno) 1131 attr = Attribute(self.name, attrName, self.file, lineno)
1140 self.addGlobal(attrName, attr) 1132 self.addGlobal(attrName, attr)
1141 if lastGlobalEntry: 1133 if lastGlobalEntry:
1142 lastGlobalEntry.setEndLine(lineno - 1) 1134 lastGlobalEntry.setEndLine(lineno - 1)
1143 lastGlobalEntry = None 1135 lastGlobalEntry = None
1144 1136
1145 elif m.captured("Attr"): 1137 elif m.start("Attr") >= 0:
1146 lineno += src.count("\n", last_lineno_pos, start) 1138 lineno += src.count("\n", last_lineno_pos, start)
1147 last_lineno_pos = start 1139 last_lineno_pos = start
1148 index = -1 1140 index = -1
1149 while index >= -len(classstack): 1141 while index >= -len(classstack):
1150 if ( 1142 if (
1151 classstack[index][0] is not None 1143 classstack[index][0] is not None
1152 and not isinstance(classstack[index][0], Function) 1144 and not isinstance(classstack[index][0], Function)
1153 and classstack[index][1] < indent 1145 and classstack[index][1] < indent
1154 ): 1146 ):
1155 parent = classstack[index][0] 1147 parent = classstack[index][0]
1156 if not m.captured("AttrType"): 1148 if m.group("AttrType") is None:
1157 nv = m.captured("AttrList").split(",") 1149 nv = m.group("AttrList").split(",")
1158 if not nv: 1150 if not nv:
1159 break 1151 break
1160 # get rid of leading ':' 1152 # get rid of leading ':'
1161 name = nv[0].strip()[1:] 1153 name = nv[0].strip()[1:]
1162 attr = ( 1154 attr = (
1168 attr.setProtected() 1160 attr.setProtected()
1169 elif nv[1].strip() == "true": 1161 elif nv[1].strip() == "true":
1170 attr.setPublic() 1162 attr.setPublic()
1171 parent.addAttribute(attr.name, attr) 1163 parent.addAttribute(attr.name, attr)
1172 else: 1164 else:
1173 access = m.captured("AttrType") 1165 access = m.group("AttrType")
1174 for name in m.captured("AttrList").split(","): 1166 for name in m.group("AttrList").split(","):
1175 # get rid of leading ':' 1167 # get rid of leading ':'
1176 name = name.strip()[1:] 1168 name = name.strip()[1:]
1177 attr = ( 1169 attr = (
1178 parent.getAttribute("@" + name) 1170 parent.getAttribute("@" + name)
1179 or parent.getAttribute("@@" + name) 1171 or parent.getAttribute("@@" + name)
1191 parent.addAttribute(attr.name, attr) 1183 parent.addAttribute(attr.name, attr)
1192 break 1184 break
1193 else: 1185 else:
1194 index -= 1 1186 index -= 1
1195 1187
1196 elif m.captured("Begin"): 1188 elif m.start("Begin") >= 0:
1197 # a begin of a block we are not interested in 1189 # a begin of a block we are not interested in
1198 indent += 1 1190 indent += 1
1199 1191
1200 elif m.captured("End"): 1192 elif m.start("End") >= 0:
1201 # an end of a block 1193 # an end of a block
1202 indent -= 1 1194 indent -= 1
1203 if indent < 0: 1195 if indent < 0:
1204 # no negative indent allowed 1196 # no negative indent allowed
1205 if classstack: 1197 if classstack:
1207 indent = classstack[-1][1] 1199 indent = classstack[-1][1]
1208 else: 1200 else:
1209 indent = 0 1201 indent = 0
1210 1202
1211 elif ( 1203 elif (
1212 m.captured("String") 1204 m.start("String") >= 0
1213 or m.captured("Comment") 1205 or m.start("Comment") >= 0
1214 or m.captured("ClassIgnored") 1206 or m.start("ClassIgnored") >= 0
1215 or m.captured("BeginEnd") 1207 or m.start("BeginEnd") >= 0
1216 ): 1208 ):
1217 pass 1209 pass
1218 1210
1219 def createHierarchy(self): 1211 def createHierarchy(self):
1220 """ 1212 """

eric ide

mercurial