1117 if (code.trim().isEmpty()) { //TODO: comment handling |
1117 if (code.trim().isEmpty()) { //TODO: comment handling |
1118 code += ";"; |
1118 code += ";"; |
1119 } |
1119 } |
1120 |
1120 |
1121 if (guessKind(code) == Kind.IMPORT) |
1121 if (guessKind(code) == Kind.IMPORT) |
1122 return Collections.<Documentation>emptyList(); |
1122 return Collections.emptyList(); |
1123 |
1123 |
1124 OuterWrap codeWrap = proc.outerMap.wrapInTrialClass(Wrap.methodWrap(code)); |
1124 OuterWrap codeWrap = proc.outerMap.wrapInTrialClass(Wrap.methodWrap(code)); |
1125 AnalyzeTask at = proc.taskFactory.new AnalyzeTask(codeWrap, keepParameterNames); |
1125 AnalyzeTask at = proc.taskFactory.new AnalyzeTask(codeWrap, keepParameterNames); |
1126 SourcePositions sp = at.trees().getSourcePositions(); |
1126 SourcePositions sp = at.trees().getSourcePositions(); |
1127 CompilationUnitTree topLevel = at.firstCuTree(); |
1127 CompilationUnitTree topLevel = at.firstCuTree(); |
1128 TreePath tp = pathFor(topLevel, sp, codeWrap.snippetIndexToWrapIndex(cursor)); |
1128 TreePath tp = pathFor(topLevel, sp, codeWrap.snippetIndexToWrapIndex(cursor)); |
1129 |
1129 |
1130 if (tp == null) |
1130 if (tp == null) |
1131 return Collections.<Documentation>emptyList(); |
1131 return Collections.emptyList(); |
1132 |
1132 |
1133 TreePath prevPath = null; |
1133 TreePath prevPath = null; |
1134 while (tp != null && tp.getLeaf().getKind() != Kind.METHOD_INVOCATION && |
1134 while (tp != null && tp.getLeaf().getKind() != Kind.METHOD_INVOCATION && |
1135 tp.getLeaf().getKind() != Kind.NEW_CLASS && tp.getLeaf().getKind() != Kind.IDENTIFIER && |
1135 tp.getLeaf().getKind() != Kind.NEW_CLASS && tp.getLeaf().getKind() != Kind.IDENTIFIER && |
1136 tp.getLeaf().getKind() != Kind.MEMBER_SELECT) { |
1136 tp.getLeaf().getKind() != Kind.MEMBER_SELECT) { |
1137 prevPath = tp; |
1137 prevPath = tp; |
1138 tp = tp.getParentPath(); |
1138 tp = tp.getParentPath(); |
1139 } |
1139 } |
1140 |
1140 |
1141 if (tp == null) |
1141 if (tp == null) |
1142 return Collections.<Documentation>emptyList(); |
1142 return Collections.emptyList(); |
1143 |
1143 |
1144 Stream<Element> elements; |
1144 Stream<Element> elements; |
1145 Iterable<Pair<ExecutableElement, ExecutableType>> candidates; |
1145 Iterable<Pair<ExecutableElement, ExecutableType>> candidates; |
1146 List<? extends ExpressionTree> arguments; |
1146 List<? extends ExpressionTree> arguments; |
1147 |
1147 |
1173 |
1173 |
1174 if (el == null || |
1174 if (el == null || |
1175 el.asType().getKind() == TypeKind.ERROR || |
1175 el.asType().getKind() == TypeKind.ERROR || |
1176 (el.getKind() == ElementKind.PACKAGE && el.getEnclosedElements().isEmpty())) { |
1176 (el.getKind() == ElementKind.PACKAGE && el.getEnclosedElements().isEmpty())) { |
1177 //erroneous element: |
1177 //erroneous element: |
1178 return Collections.<Documentation>emptyList(); |
1178 return Collections.emptyList(); |
1179 } |
1179 } |
1180 |
1180 |
1181 elements = Stream.of(el); |
1181 elements = Stream.of(el); |
1182 } else { |
1182 } else { |
1183 return Collections.<Documentation>emptyList(); |
1183 return Collections.emptyList(); |
1184 } |
1184 } |
1185 |
1185 |
1186 List<Documentation> result = Collections.emptyList(); |
1186 List<Documentation> result = Collections.emptyList(); |
1187 |
1187 |
1188 try (JavadocHelper helper = JavadocHelper.create(at.task, findSources())) { |
1188 try (JavadocHelper helper = JavadocHelper.create(at.task, findSources())) { |