equal
deleted
inserted
replaced
80 return getSnippet(key.index()); |
80 return getSnippet(key.index()); |
81 } |
81 } |
82 |
82 |
83 Snippet getSnippet(int ki) { |
83 Snippet getSnippet(int ki) { |
84 Snippet sn = getSnippetDeadOrAlive(ki); |
84 Snippet sn = getSnippetDeadOrAlive(ki); |
85 return (sn != null && !sn.status().isActive) |
85 return (sn != null && !sn.status().isActive()) |
86 ? null |
86 ? null |
87 : sn; |
87 : sn; |
88 } |
88 } |
89 |
89 |
90 Snippet getSnippetDeadOrAlive(int ki) { |
90 Snippet getSnippetDeadOrAlive(int ki) { |
100 |
100 |
101 String packageAndImportsExcept(Set<Key> except, Collection<Snippet> plus) { |
101 String packageAndImportsExcept(Set<Key> except, Collection<Snippet> plus) { |
102 StringBuilder sb = new StringBuilder(); |
102 StringBuilder sb = new StringBuilder(); |
103 sb.append("package ").append(REPL_PACKAGE).append(";\n"); |
103 sb.append("package ").append(REPL_PACKAGE).append(";\n"); |
104 for (Snippet si : keyIndexToSnippet) { |
104 for (Snippet si : keyIndexToSnippet) { |
105 if (si != null && si.status().isDefined && (except == null || !except.contains(si.key()))) { |
105 if (si != null && si.status().isDefined() && (except == null || !except.contains(si.key()))) { |
106 sb.append(si.importLine(state)); |
106 sb.append(si.importLine(state)); |
107 } |
107 } |
108 } |
108 } |
109 if (plus != null) { |
109 if (plus != null) { |
110 plus.stream() |
110 plus.stream() |
112 } |
112 } |
113 return sb.toString(); |
113 return sb.toString(); |
114 } |
114 } |
115 |
115 |
116 List<Snippet> getDependents(Snippet snip) { |
116 List<Snippet> getDependents(Snippet snip) { |
117 if (!snip.kind().isPersistent) { |
117 if (!snip.kind().isPersistent()) { |
118 return Collections.emptyList(); |
118 return Collections.emptyList(); |
119 } |
119 } |
120 Set<Integer> depset; |
120 Set<Integer> depset; |
121 if (snip.unitName.equals("*")) { |
121 if (snip.unitName.equals("*")) { |
122 // star import |
122 // star import |
188 * @return a stream of the import needed |
188 * @return a stream of the import needed |
189 */ |
189 */ |
190 private Stream<ImportSnippet> importSnippets() { |
190 private Stream<ImportSnippet> importSnippets() { |
191 return state.keyMap.importKeys() |
191 return state.keyMap.importKeys() |
192 .map(key -> (ImportSnippet)getSnippet(key)) |
192 .map(key -> (ImportSnippet)getSnippet(key)) |
193 .filter(sn -> sn != null && state.status(sn).isDefined); |
193 .filter(sn -> sn != null && state.status(sn).isDefined()); |
194 } |
194 } |
195 } |
195 } |