| 885 | | auto thisModule = (cast(LanguageD)lang).getCachedModule(this); |
|---|
| 886 | | |
|---|
| 887 | | if ( !thisModule ) |
|---|
| 888 | | { |
|---|
| 889 | | return; |
|---|
| 890 | | } |
|---|
| 891 | | String missing = getMissingReturn(thisModule); |
|---|
| 892 | | System.writefln("Missing return on: ", missing); |
|---|
| 893 | | |
|---|
| 894 | | |
|---|
| 895 | | } |
|---|
| 896 | | |
|---|
| 897 | | String getMissingReturn(Element element) |
|---|
| 898 | | { |
|---|
| 899 | | String miss = new String(); |
|---|
| 900 | | |
|---|
| 901 | | if ( cast(Function)element && element.getReturnType()!="void" ) |
|---|
| 902 | | { |
|---|
| 903 | | Function f = cast(Function)element; |
|---|
| 904 | | String code = f.getBody(); |
|---|
| 905 | | if ( code !is null && code.find("return") < 0 ) |
|---|
| 906 | | { |
|---|
| 907 | | markError(element.getLineInCode(), new String("Missing return"), 0x00FFFF); |
|---|
| 908 | | miss ~= f.getName(); |
|---|
| 909 | | miss ~= " "; |
|---|
| 910 | | } |
|---|
| 911 | | } |
|---|
| 912 | | if ( element.getElements() !is null ) |
|---|
| 913 | | { |
|---|
| 914 | | foreach ( Element child ; element.getElements() ) |
|---|
| 915 | | { |
|---|
| 916 | | miss ~= getMissingReturn(child); |
|---|
| 917 | | } |
|---|
| 918 | | } |
|---|
| 919 | | |
|---|
| 920 | | return miss; |
|---|
| 921 | | } |
|---|
| | 885 | String missing = lang.getMissingReturn(this); |
|---|
| | 886 | if (missing) { |
|---|
| | 887 | System.writefln("Missing return on: ", missing); |
|---|
| | 888 | } |
|---|
| | 889 | |
|---|
| | 890 | |
|---|
| | 891 | |
|---|
| | 892 | } |
|---|
| | 893 | |
|---|
| | 894 | |
|---|
| 1094 | | /** |
|---|
| 1095 | | * Gets the containeier and function for the line of the current buffer |
|---|
| 1096 | | * @param container the container to be populated |
|---|
| 1097 | | * @param funct the function to be populated |
|---|
| 1098 | | * @param lineNumber the lineNumber |
|---|
| 1099 | | * @return true if found the container and function |
|---|
| 1100 | | */ |
|---|
| 1101 | | bit findContainer(out Block container, out Function funct, in int lineNumber) |
|---|
| 1102 | | { |
|---|
| 1103 | | return findContainer( |
|---|
| 1104 | | codeEdit.getText(), |
|---|
| 1105 | | lineNumber, |
|---|
| 1106 | | Element.Attribute.NONE, |
|---|
| 1107 | | getLanguage(), |
|---|
| 1108 | | container, |
|---|
| 1109 | | funct); |
|---|
| 1110 | | } |
|---|
| 1111 | | |
|---|
| 1112 | | bit findContainer( String text, |
|---|
| 1113 | | int lineNumber, |
|---|
| 1114 | | Element.Attribute attributes, |
|---|
| 1115 | | Attributes.Language language, |
|---|
| 1116 | | out Block container, |
|---|
| 1117 | | out Function funct) |
|---|
| 1118 | | { |
|---|
| 1119 | | debug(autoComments) System.writefln("CodeView.findContainer 1"); |
|---|
| 1120 | | bit found = false; |
|---|
| 1121 | | Module mod = new Module(new String(), text, attributes, language); |
|---|
| 1122 | | container = cast(Block)mod.getContainerForLine(lineNumber); |
|---|
| 1123 | | debug(autoComments) System.writefln("CodeView.findContainer 3"); |
|---|
| 1124 | | if ( container !is null ) |
|---|
| 1125 | | { |
|---|
| 1126 | | debug(autoComments) System.writefln("CodeView.findContainer 4"); |
|---|
| 1127 | | funct = container.getFunction(lineNumber); |
|---|
| 1128 | | if ( funct !is null ) |
|---|
| 1129 | | { |
|---|
| 1130 | | debug(autoComments) System.writefln("CodeView.findContainer 5"); |
|---|
| 1131 | | found = true; |
|---|
| 1132 | | } |
|---|
| 1133 | | else |
|---|
| 1134 | | { |
|---|
| 1135 | | debug(autoComments) System.writefln("CodeView.findContainer 6"); |
|---|
| 1136 | | //codeEdit.insertText(insertPos, "What function?"); |
|---|
| 1137 | | } |
|---|
| 1138 | | } |
|---|
| 1139 | | else |
|---|
| 1140 | | { |
|---|
| 1141 | | debug(autoComments) System.writefln("CodeView.findContainer 7"); |
|---|
| 1142 | | //codeEdit.insertText(insertPos, "What container?"); |
|---|
| 1143 | | } |
|---|
| 1144 | | debug(autoComments) System.writefln("CodeView.findContainer exit found = ", found); |
|---|
| 1145 | | return found; |
|---|
| 1146 | | } |
|---|
| | 1067 | |
|---|
| 1211 | | Block container; |
|---|
| 1212 | | Function funct; |
|---|
| 1213 | | //Module mod = new Module("",codeEdit.getText(),Attribute.NONE,getLanguage()); |
|---|
| 1214 | | //Struct container = cast(Struct)mod.getContainerForLine(functionLine); |
|---|
| 1215 | | //if ( container !is null ) |
|---|
| 1216 | | debug(autoComments) System.writefln("CodeView.doAutoDocComments NOT emptyDocComments 1"); |
|---|
| 1217 | | |
|---|
| 1218 | | if ( findContainer(container, funct, functionLine) ) |
|---|
| 1219 | | { |
|---|
| 1220 | | debug(autoComments) System.writefln("CodeView.doAutoDocComments NOT emptyDocComments 2"); |
|---|
| 1221 | | insertPos = codeEdit.getLineEndPosition(currLine); |
|---|
| 1222 | | int count = 0; |
|---|
| 1223 | | foreach ( String par ; funct.getParametersList() ) |
|---|
| 1224 | | { |
|---|
| 1225 | | debug(autoComments) System.writefln("CodeView.doAutoDocComments NOT emptyDocComments 3"); |
|---|
| 1226 | | if ( Leds.leds.getPropValue("ddocComments", false) ) |
|---|
| 1227 | | { |
|---|
| 1228 | | if ( count == 0 ) |
|---|
| 1229 | | { |
|---|
| 1230 | | codeEdit.insertText(insertPos,"\n"~commStr~" Params:"); |
|---|
| 1231 | | doAutoIndent(++currLine); |
|---|
| 1232 | | insertPos = codeEdit.getLineEndPosition(currLine); |
|---|
| 1233 | | } |
|---|
| 1234 | | codeEdit.insertText(insertPos,"\n"~commStr~" \t" ~ par.toString() ~ " = \t"); |
|---|
| 1235 | | doAutoIndent(++currLine); |
|---|
| 1236 | | insertPos = codeEdit.getLineEndPosition(currLine); |
|---|
| 1237 | | } |
|---|
| 1238 | | else |
|---|
| 1239 | | { |
|---|
| 1240 | | codeEdit.insertText(insertPos,"\n"~commStr~" @param " ~ par.toString() ~ " "); |
|---|
| 1241 | | doAutoIndent(++currLine); |
|---|
| 1242 | | insertPos = codeEdit.getLineEndPosition(currLine); |
|---|
| 1243 | | } |
|---|
| 1244 | | ++count; |
|---|
| 1245 | | } |
|---|
| 1246 | | String retType = funct.getReturnType(); |
|---|
| 1247 | | if ( retType !is null && retType.length>0 && retType!="void" ) |
|---|
| 1248 | | { |
|---|
| 1249 | | debug(autoComments) System.writefln("CodeView.doAutoDocComments NOT emptyDocComments 4"); |
|---|
| 1250 | | if ( Leds.leds.getPropValue("ddocComments", false) ) |
|---|
| 1251 | | { |
|---|
| 1252 | | codeEdit.insertText(insertPos, "\n"~commStr~" Returns: "); |
|---|
| 1253 | | doAutoIndent(++currLine); |
|---|
| 1254 | | insertPos = codeEdit.getLineEndPosition(currLine); |
|---|
| 1255 | | } |
|---|
| 1256 | | else |
|---|
| 1257 | | { |
|---|
| 1258 | | codeEdit.insertText(insertPos, "\n"~commStr~" @return "); |
|---|
| 1259 | | doAutoIndent(++currLine); |
|---|
| 1260 | | insertPos = codeEdit.getLineEndPosition(currLine); |
|---|
| 1261 | | } |
|---|
| 1262 | | } |
|---|
| | 1134 | if (this.getLanguageHandler()) { |
|---|
| | 1135 | this.getLanguageHandler().addAutoDocComments(this,functionLine, commStr ); |
|---|
| | 1136 | |
|---|
| | 1137 | |
|---|
| 1886 | | Module sourceModule = new Module(new String(),getText(), Element.Attribute.NONE, Attributes.Language.D); |
|---|
| 1887 | | String iText = new String(); |
|---|
| 1888 | | iText ~= sourceModule.getInterfaceForm(); |
|---|
| 1889 | | |
|---|
| 1890 | | foreach ( Class clss ; sourceModule.getClasses() ) |
|---|
| 1891 | | { |
|---|
| 1892 | | |
|---|
| 1893 | | iText ~= "public interface "; |
|---|
| 1894 | | iText ~= clss.getName()~ "IF\n{\n"; |
|---|
| 1895 | | foreach(int count, Function element ; clss.getFunctions() ) |
|---|
| 1896 | | { |
|---|
| 1897 | | if ( element.getName() != "this" ) |
|---|
| 1898 | | { |
|---|
| 1899 | | iText ~= element.getInterfaceForm().dup.prepend("\n"); |
|---|
| 1900 | | } |
|---|
| 1901 | | } |
|---|
| 1902 | | |
|---|
| 1903 | | iText ~= "\n}\n"; |
|---|
| 1904 | | |
|---|
| 1905 | | } |
|---|
| 1906 | | |
|---|
| | 1769 | |
|---|
| | 1770 | if (!getLanguageHandler()) { |
|---|
| | 1771 | return; |
|---|
| | 1772 | } |
|---|
| | 1773 | String iText = getLanguageHandler().extractInterface(this); |
|---|
| | 1774 | if (!iText.length) { |
|---|
| | 1775 | return; |
|---|
| | 1776 | } |
|---|
| 2058 | | if ( language == Attributes.Language.JAVA ) |
|---|
| 2059 | | { |
|---|
| 2060 | | // need to add the class name |
|---|
| 2061 | | Module mod = new Module(new String(), codeEdit.getText(), Element.Attribute.PUBLIC, language); |
|---|
| 2062 | | foreach ( Class element ; mod.getClasses() ) |
|---|
| 2063 | | { |
|---|
| 2064 | | if ( element.getAttributes() & Element.Attribute.PUBLIC ) |
|---|
| 2065 | | { |
|---|
| 2066 | | modulePath ~= element.getName().prepend("."); |
|---|
| 2067 | | break; |
|---|
| 2068 | | } |
|---|
| 2069 | | } |
|---|
| | 1918 | if ( ( language == Language.LangType.JAVA ) && getLanguageHandler()) { |
|---|
| | 1919 | |
|---|
| | 1920 | modulePath ~= getLanguageHandler().getModulePath(this); |
|---|
| | 1921 | |
|---|