| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35,7 +35,7 @@ | |||
| 35 | 35 | public class CompletionCandidate implements Comparable<CompletionCandidate> { | |
| 36 | 36 | private final String elementName; | |
| 37 | 37 | private final String label; // the toString value | |
| 38 | - private final String completionString; | ||
| 38 | + private final String completion; | ||
| 39 | 39 | private final Object wrappedObject; | |
| 40 | 40 | private final int type; | |
| 41 | 41 | ||
@@ -48,60 +48,61 @@ public class CompletionCandidate implements Comparable<CompletionCandidate> { | |||
| 48 | 48 | static final int LOCAL_VAR = 6; | |
| 49 | 49 | ||
| 50 | 50 | ||
| 51 | - public CompletionCandidate(Method method) { | ||
| 51 | + CompletionCandidate(Method method) { | ||
| 52 | + // return value ignored? [fry 180326] | ||
| 52 | 53 | method.getDeclaringClass().getName(); | |
| 53 | 54 | elementName = method.getName(); | |
| 54 | - StringBuilder label = new StringBuilder("<html>"+method.getName() + "("); | ||
| 55 | - StringBuilder cstr = new StringBuilder(method.getName() + "("); | ||
| 56 | - for (int i = 0; i < method.getParameterTypes().length; i++) { | ||
| 57 | - label.append(method.getParameterTypes()[i].getSimpleName()); | ||
| 58 | - if (i < method.getParameterTypes().length - 1) { | ||
| 59 | - label.append(","); | ||
| 60 | - cstr.append(","); | ||
| 55 | + | ||
| 56 | + StringBuilder labelBuilder = new StringBuilder("<html>"+method.getName() + "("); | ||
| 57 | + StringBuilder compBuilder = new StringBuilder(method.getName() + "("); | ||
| 58 | + Class<?>[] types = method.getParameterTypes(); | ||
| 59 | + for (int i = 0; i < types.length; i++) { | ||
| 60 | + labelBuilder.append(types[i].getSimpleName()); | ||
| 61 | + if (i < types.length - 1) { | ||
| 62 | + labelBuilder.append(','); | ||
| 63 | + compBuilder.append(','); | ||
| 61 | 64 | } | |
| 62 | 65 | } | |
| 63 | - if(method.getParameterTypes().length == 1) { | ||
| 64 | - cstr.append(' '); | ||
| 66 | + if (types.length == 1) { | ||
| 67 | + compBuilder.append(' '); | ||
| 65 | 68 | } | |
| 66 | - label.append(")"); | ||
| 67 | - if(method.getReturnType() != null) | ||
| 68 | - label.append(" : " + method.getReturnType().getSimpleName()); | ||
| 69 | - label.append(" - <font color=#777777>" + method.getDeclaringClass().getSimpleName() + "</font></html>"); | ||
| 70 | - cstr.append(")"); | ||
| 71 | - this.label = label.toString(); | ||
| 72 | - this.completionString = cstr.toString(); | ||
| 69 | + labelBuilder.append(")"); | ||
| 70 | + | ||
| 71 | + if (method.getReturnType() != null) { | ||
| 72 | + labelBuilder.append(" : " + method.getReturnType().getSimpleName()); | ||
| 73 | + } | ||
| 74 | + labelBuilder.append(" - <font color=#777777>" + method.getDeclaringClass().getSimpleName() + "</font></html>"); | ||
| 75 | + | ||
| 76 | + compBuilder.append(")"); | ||
| 77 | + label = labelBuilder.toString(); | ||
| 78 | + completion = compBuilder.toString(); | ||
| 79 | + | ||
| 73 | 80 | type = PREDEF_METHOD; | |
| 74 | 81 | wrappedObject = method; | |
| 75 | 82 | } | |
| 76 | 83 | ||
| 77 | - public Object getWrappedObject() { | ||
| 78 | - return wrappedObject; | ||
| 79 | - } | ||
| 80 | 84 | ||
| 81 | - public CompletionCandidate(SingleVariableDeclaration svd) { | ||
| 82 | - completionString = svd.getName().toString(); | ||
| 85 | + CompletionCandidate(SingleVariableDeclaration svd) { | ||
| 86 | + completion = svd.getName().toString(); | ||
| 83 | 87 | elementName = svd.getName().toString(); | |
| 84 | - if(svd.getParent() instanceof FieldDeclaration) | ||
| 85 | - type = LOCAL_FIELD; | ||
| 86 | - else | ||
| 87 | - type = LOCAL_VAR; | ||
| 88 | + type = (svd.getParent() instanceof FieldDeclaration) ? | ||
| 89 | + LOCAL_FIELD : LOCAL_VAR; | ||
| 88 | 90 | label = svd.getName() + " : " + svd.getType(); | |
| 89 | 91 | wrappedObject = svd; | |
| 90 | 92 | } | |
| 91 | 93 | ||
| 92 | - public CompletionCandidate(VariableDeclarationFragment vdf) { | ||
| 93 | - completionString = vdf.getName().toString(); | ||
| 94 | + | ||
| 95 | + CompletionCandidate(VariableDeclarationFragment vdf) { | ||
| 96 | + completion = vdf.getName().toString(); | ||
| 94 | 97 | elementName = vdf.getName().toString(); | |
| 95 | - if(vdf.getParent() instanceof FieldDeclaration) | ||
| 96 | - type = LOCAL_FIELD; | ||
| 97 | - else | ||
| 98 | - type = LOCAL_VAR; | ||
| 98 | + type = (vdf.getParent() instanceof FieldDeclaration) ? | ||
| 99 | + LOCAL_FIELD : LOCAL_VAR; | ||
| 99 | 100 | label = vdf.getName() + " : " + CompletionGenerator.extracTypeInfo2(vdf); | |
| 100 | 101 | wrappedObject = vdf; | |
| 101 | 102 | } | |
| 102 | 103 | ||
| 103 | - public CompletionCandidate(MethodDeclaration method) { | ||
| 104 | - // log("ComCan " + method.getName()); | ||
| 104 | + | ||
| 105 | + CompletionCandidate(MethodDeclaration method) { | ||
| 105 | 106 | elementName = method.getName().toString(); | |
| 106 | 107 | type = LOCAL_METHOD; | |
| 107 | 108 | ||
@@ -126,176 +127,172 @@ public CompletionCandidate(MethodDeclaration method) { | |||
| 126 | 127 | label.append(" : " + method.getReturnType2()); | |
| 127 | 128 | cstr.append(")"); | |
| 128 | 129 | this.label = label.toString(); | |
| 129 | - this.completionString = cstr.toString(); | ||
| 130 | + this.completion = cstr.toString(); | ||
| 130 | 131 | wrappedObject = method; | |
| 131 | 132 | } | |
| 132 | 133 | ||
| 133 | - public CompletionCandidate(TypeDeclaration td){ | ||
| 134 | + | ||
| 135 | + CompletionCandidate(TypeDeclaration td) { | ||
| 134 | 136 | type = LOCAL_CLASS; | |
| 135 | 137 | elementName = td.getName().toString(); | |
| 136 | 138 | label = elementName; | |
| 137 | - completionString = elementName; | ||
| 139 | + completion = elementName; | ||
| 138 | 140 | wrappedObject = td; | |
| 139 | 141 | } | |
| 140 | 142 | ||
| 141 | - public CompletionCandidate(Field f) { | ||
| 143 | + | ||
| 144 | + CompletionCandidate(Field f) { | ||
| 142 | 145 | f.getDeclaringClass().getName(); | |
| 143 | 146 | elementName = f.getName(); | |
| 144 | 147 | type = PREDEF_FIELD; | |
| 145 | - // "<html>" | ||
| 146 | - // + matchedClass + " : " + "<font color=#777777>" | ||
| 147 | - // + matchedClass2.substring(0, d) + "</font>", matchedClass | ||
| 148 | - // + "</html>" | ||
| 149 | 148 | label = "<html>" + f.getName() + " : " + f.getType().getSimpleName() + | |
| 150 | 149 | " - <font color=#777777>" + f.getDeclaringClass().getSimpleName() + | |
| 151 | 150 | "</font></html>"; | |
| 152 | - completionString = elementName; | ||
| 151 | + completion = elementName; | ||
| 153 | 152 | wrappedObject = f; | |
| 154 | 153 | } | |
| 155 | 154 | ||
| 156 | - public CompletionCandidate(String name, String labelStr, String completionStr, int type) { | ||
| 157 | - elementName = name; | ||
| 158 | - label = labelStr; | ||
| 159 | - completionString = completionStr; | ||
| 160 | - this.type = type; | ||
| 161 | - wrappedObject = null; | ||
| 155 | + | ||
| 156 | + public CompletionCandidate(String name, String label, String completion, int type) { | ||
| 157 | + this(name, label, completion, type, null); | ||
| 162 | 158 | } | |
| 163 | 159 | ||
| 160 | + | ||
| 164 | 161 | public CompletionCandidate(String name, int type) { | |
| 165 | - elementName = name; | ||
| 166 | - label = name; | ||
| 167 | - completionString = name; | ||
| 168 | - this.type = type; | ||
| 169 | - wrappedObject = null; | ||
| 162 | + this(name, name, name, type, null); | ||
| 170 | 163 | } | |
| 171 | 164 | ||
| 165 | + | ||
| 172 | 166 | private CompletionCandidate(String elementName, String label, | |
| 173 | - String completionString, int type, | ||
| 167 | + String completion, int type, | ||
| 174 | 168 | Object wrappedObject) { | |
| 175 | 169 | this.elementName = elementName; | |
| 176 | 170 | this.label = label; | |
| 177 | - this.completionString = completionString; | ||
| 171 | + this.completion = completion; | ||
| 178 | 172 | this.type = type; | |
| 179 | 173 | this.wrappedObject = wrappedObject; | |
| 180 | 174 | } | |
| 181 | 175 | ||
| 176 | + | ||
| 177 | + Object getWrappedObject() { | ||
| 178 | + return wrappedObject; | ||
| 179 | + } | ||
| 180 | + | ||
| 181 | + | ||
| 182 | 182 | public String getElementName() { | |
| 183 | 183 | return elementName; | |
| 184 | 184 | } | |
| 185 | 185 | ||
| 186 | + | ||
| 186 | 187 | public String getCompletionString() { | |
| 187 | - return completionString; | ||
| 188 | + return completion; | ||
| 188 | 189 | } | |
| 189 | 190 | ||
| 191 | + | ||
| 190 | 192 | public String toString() { | |
| 191 | 193 | return label; | |
| 192 | 194 | } | |
| 193 | 195 | ||
| 196 | + | ||
| 194 | 197 | public int getType() { | |
| 195 | 198 | return type; | |
| 196 | 199 | } | |
| 197 | 200 | ||
| 201 | + | ||
| 198 | 202 | public String getLabel() { | |
| 199 | 203 | return label; | |
| 200 | 204 | } | |
| 201 | 205 | ||
| 206 | + | ||
| 202 | 207 | public String getNoHtmlLabel(){ | |
| 203 | - if(!label.contains("<html>")) { | ||
| 208 | + if (!label.contains("<html>")) { | ||
| 204 | 209 | return label; | |
| 205 | - } | ||
| 206 | - else { | ||
| 210 | + | ||
| 211 | + } else { | ||
| 212 | + // TODO this is gross [fry 180326] | ||
| 207 | 213 | StringBuilder ans = new StringBuilder(label); | |
| 208 | - while(ans.indexOf("<") > -1) { | ||
| 214 | + while (ans.indexOf("<") > -1) { | ||
| 209 | 215 | int a = ans.indexOf("<"), b = ans.indexOf(">"); | |
| 210 | - if(a > b) break; | ||
| 216 | + if (a > b) break; | ||
| 211 | 217 | ans.replace(a, b+1, ""); | |
| 212 | - // System.out.println(ans.replace(a, b+1, "")); | ||
| 213 | - // System.out.println(ans + "--"); | ||
| 214 | 218 | } | |
| 215 | 219 | return ans.toString(); | |
| 216 | 220 | } | |
| 217 | 221 | } | |
| 218 | 222 | ||
| 223 | + | ||
| 219 | 224 | public CompletionCandidate withLabelAndCompString(String label, | |
| 220 | - String completionString) { | ||
| 221 | - return new CompletionCandidate(this.elementName, label, completionString, | ||
| 225 | + String completion) { | ||
| 226 | + return new CompletionCandidate(this.elementName, label, completion, | ||
| 222 | 227 | this.type, this.wrappedObject); | |
| 223 | 228 | } | |
| 224 | 229 | ||
| 230 | + | ||
| 225 | 231 | @Override | |
| 226 | 232 | public int compareTo(CompletionCandidate cc) { | |
| 227 | - if(type != cc.getType()){ | ||
| 233 | + if (type != cc.getType()) { | ||
| 228 | 234 | return cc.getType() - type; | |
| 229 | 235 | } | |
| 230 | - return (elementName.compareTo(cc.getElementName())); | ||
| 236 | + return elementName.compareTo(cc.getElementName()); | ||
| 231 | 237 | } | |
| 232 | 238 | ||
| 239 | + | ||
| 233 | 240 | public CompletionCandidate withRegeneratedCompString() { | |
| 234 | 241 | if (wrappedObject instanceof MethodDeclaration) { | |
| 235 | 242 | MethodDeclaration method = (MethodDeclaration)wrappedObject; | |
| 236 | 243 | ||
| 237 | 244 | @SuppressWarnings("unchecked") | |
| 238 | 245 | List<ASTNode> params = (List<ASTNode>) | |
| 239 | - method.getStructuralProperty(MethodDeclaration.PARAMETERS_PROPERTY); | ||
| 246 | + method.getStructuralProperty(MethodDeclaration.PARAMETERS_PROPERTY); | ||
| 240 | 247 | ||
| 241 | - StringBuilder label = new StringBuilder(elementName + "("); | ||
| 242 | - StringBuilder cstr = new StringBuilder(method.getName() + "("); | ||
| 248 | + StringBuilder labelBuilder = new StringBuilder(elementName + "("); | ||
| 249 | + StringBuilder compBuilder = new StringBuilder(method.getName() + "("); | ||
| 243 | 250 | for (int i = 0; i < params.size(); i++) { | |
| 244 | - label.append(params.get(i).toString()); | ||
| 251 | + labelBuilder.append(params.get(i)); | ||
| 245 | 252 | if (i < params.size() - 1) { | |
| 246 | - label.append(","); | ||
| 247 | - cstr.append(","); | ||
| 253 | + labelBuilder.append(','); | ||
| 254 | + compBuilder.append(','); | ||
| 248 | 255 | } | |
| 249 | 256 | } | |
| 250 | 257 | if (params.size() == 1) { | |
| 251 | - cstr.append(' '); | ||
| 258 | + compBuilder.append(' '); | ||
| 252 | 259 | } | |
| 253 | - label.append(")"); | ||
| 254 | - if (method.getReturnType2() != null) | ||
| 255 | - label.append(" : " + method.getReturnType2()); | ||
| 256 | - cstr.append(")"); | ||
| 257 | - return this.withLabelAndCompString(label.toString(), cstr.toString()); | ||
| 258 | - } | ||
| 259 | - else if (wrappedObject instanceof Method) { | ||
| 260 | - Method method = (Method)wrappedObject; | ||
| 261 | - StringBuilder label = new StringBuilder("<html>" + method.getName() + "("); | ||
| 262 | - StringBuilder cstr = new StringBuilder(method.getName() + "("); | ||
| 263 | - for (int i = 0; i < method.getParameterTypes().length; i++) { | ||
| 264 | - label.append(method.getParameterTypes()[i].getSimpleName()); | ||
| 265 | - if (i < method.getParameterTypes().length - 1) { | ||
| 266 | - label.append(","); | ||
| 267 | - cstr.append(","); | ||
| 268 | - } | ||
| 269 | - } | ||
| 270 | - if(method.getParameterTypes().length == 1) { | ||
| 271 | - cstr.append(' '); | ||
| 272 | - } | ||
| 273 | - label.append(")"); | ||
| 274 | - if(method.getReturnType() != null) | ||
| 275 | - label.append(" : " + method.getReturnType().getSimpleName()); | ||
| 276 | - label.append(" - <font color=#777777>" + method.getDeclaringClass().getSimpleName() + "</font></html>"); | ||
| 277 | - cstr.append(")"); | ||
| 278 | - return this.withLabelAndCompString(label.toString(), cstr.toString()); | ||
| 279 | - /* | ||
| 280 | - * StringBuilder label = new StringBuilder("<html>"+method.getName() + "("); | ||
| 281 | - StringBuilder cstr = new StringBuilder(method.getName() + "("); | ||
| 282 | - for (int i = 0; i < method.getParameterTypes().length; i++) { | ||
| 283 | - label.append(method.getParameterTypes()[i].getSimpleName()); | ||
| 284 | - if (i < method.getParameterTypes().length - 1) { | ||
| 285 | - label.append(","); | ||
| 286 | - cstr.append(","); | ||
| 260 | + labelBuilder.append(')'); | ||
| 261 | + if (method.getReturnType2() != null) { | ||
| 262 | + labelBuilder.append(" : "); | ||
| 263 | + labelBuilder.append(method.getReturnType2()); | ||
| 287 | 264 | } | |
| 265 | + compBuilder.append(')'); | ||
| 266 | + return withLabelAndCompString(labelBuilder.toString(), compBuilder.toString()); | ||
| 267 | + | ||
| 268 | + } else if (wrappedObject instanceof Method) { | ||
| 269 | + Method method = (Method) wrappedObject; | ||
| 270 | + StringBuilder labelBuilder = new StringBuilder("<html>" + method.getName() + "("); | ||
| 271 | + StringBuilder compBuilder = new StringBuilder(method.getName() + "("); | ||
| 272 | + for (int i = 0; i < method.getParameterTypes().length; i++) { | ||
| 273 | + labelBuilder.append(method.getParameterTypes()[i].getSimpleName()); | ||
| 274 | + if (i < method.getParameterTypes().length - 1) { | ||
| 275 | + labelBuilder.append(','); | ||
| 276 | + compBuilder.append(','); | ||
| 277 | + } | ||
| 278 | + } | ||
| 279 | + if (method.getParameterTypes().length == 1) { | ||
| 280 | + compBuilder.append(' '); | ||
| 281 | + } | ||
| 282 | + compBuilder.append(')'); | ||
| 283 | + | ||
| 284 | + labelBuilder.append(')'); | ||
| 285 | + if (method.getReturnType() != null) { | ||
| 286 | + labelBuilder.append(" : " + method.getReturnType().getSimpleName()); | ||
| 287 | + } | ||
| 288 | + labelBuilder.append(" - <font color=#777777>"); | ||
| 289 | + labelBuilder.append(method.getDeclaringClass().getSimpleName()); | ||
| 290 | + labelBuilder.append("</font></html>"); | ||
| 291 | + | ||
| 292 | + return withLabelAndCompString(labelBuilder.toString(), compBuilder.toString()); | ||
| 288 | 293 | } | |
| 289 | - if(method.getParameterTypes().length == 1) { | ||
| 290 | - cstr.append(' '); | ||
| 291 | - } | ||
| 292 | - label.append(")"); | ||
| 293 | - if(method.getReturnType() != null) | ||
| 294 | - label.append(" : " + method.getReturnType().getSimpleName()); | ||
| 295 | - label.append(" - <font color=#777777>" + method.getDeclaringClass().getSimpleName() + "</font></html>"); | ||
| 296 | - * */ | ||
| 297 | - } | ||
| 294 | + | ||
| 295 | + // fall-through silently does nothing? [fry 180326] | ||
| 298 | 296 | return this; | |
| 299 | 297 | } | |
| 300 | - | ||
| 301 | 298 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,6 +13,7 @@ X add select/copy to the status bar | |||
| 13 | 13 | X https://github.com/processing/processing/issues/5271 | |
| 14 | 14 | o possible fix (just copies on click) | |
| 15 | 15 | o https://github.com/processing/processing/pull/5345 | |
| 16 | + _ in the docs: modify 'search.format=' in preferences.txt | ||
| 16 | 17 | ||
| 17 | 18 | contrib | |
| 18 | 19 | X updates to Japanese translation | |
| Back | FazBrowse Home | New Git URL |
0 commit comments