8201622: Reduce unnecessary Package.complete() calls in javadoc

Reviewed-by: jlahoda
This commit is contained in:
Jonathan Gibbons 2018-04-27 15:55:29 -07:00
parent 25a8a3ad66
commit 9037ee0ef1
2 changed files with 24 additions and 13 deletions

View File

@ -247,14 +247,15 @@ public class JavacElements implements Elements {
if (sym == null) if (sym == null)
sym = javaCompiler.resolveIdent(module, nameStr); sym = javaCompiler.resolveIdent(module, nameStr);
if (clazz.isInstance(sym)) {
sym.complete(); sym.complete();
if (sym.kind != ERR &&
return (sym.kind != ERR &&
sym.exists() && sym.exists() &&
clazz.isInstance(sym) && name.equals(sym.getQualifiedName())) {
name.equals(sym.getQualifiedName())) return clazz.cast(sym);
? clazz.cast(sym) }
: null; }
return null;
} catch (CompletionFailure cf) { } catch (CompletionFailure cf) {
cf.dcfh.handleAPICompletionFailure(cf); cf.dcfh.handleAPICompletionFailure(cf);
return null; return null;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -28,7 +28,6 @@ package jdk.javadoc.internal.doclets.toolkit;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -200,11 +199,16 @@ public class WorkArounds {
// TODO: needs to ported to jx.l.m. // TODO: needs to ported to jx.l.m.
public TypeElement searchClass(TypeElement klass, String className) { public TypeElement searchClass(TypeElement klass, String className) {
// search by qualified name first TypeElement te;
TypeElement te = configuration.docEnv.getElementUtils().getTypeElement(className);
// search by qualified name in current module first
ModuleElement me = utils.containingModule(klass);
if (me != null) {
te = configuration.docEnv.getElementUtils().getTypeElement(me, className);
if (te != null) { if (te != null) {
return te; return te;
} }
}
// search inner classes // search inner classes
for (TypeElement ite : utils.getClasses(klass)) { for (TypeElement ite : utils.getClasses(klass)) {
@ -251,6 +255,12 @@ public class WorkArounds {
} }
} }
// finally, search by qualified name in all modules
te = configuration.docEnv.getElementUtils().getTypeElement(className);
if (te != null) {
return te;
}
return null; // not found return null; // not found
} }