Skip to content
Permalink
Browse files

8239243: Create index structures only if required

Reviewed-by: hannesw, jjg
  • Loading branch information
pavelrappo committed Feb 19, 2020
1 parent 7b24bd6 commit 9fdcdf4a3ee280f7ba3be01bd726d427621ff888
@@ -70,7 +70,7 @@
/**
* The index of all the members with unicode character.
*/
protected IndexBuilder indexbuilder;
protected IndexBuilder indexBuilder;

protected Navigation navBar;

@@ -80,13 +80,13 @@
*
* @param configuration The current configuration
* @param path Path to the file which is getting generated.
* @param indexbuilder Unicode based Index from {@link IndexBuilder}
* @param indexBuilder Unicode based Index from {@link IndexBuilder}
*/
protected AbstractIndexWriter(HtmlConfiguration configuration,
DocPath path,
IndexBuilder indexbuilder) {
IndexBuilder indexBuilder) {
super(configuration, path);
this.indexbuilder = indexbuilder;
this.indexBuilder = indexBuilder;
this.navBar = new Navigation(null, configuration, PageMode.INDEX, path);
}

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -54,20 +54,20 @@
/**
* Index of all the classes.
*/
protected IndexBuilder indexbuilder;
protected IndexBuilder indexBuilder;

/**
* Construct AllClassesIndexWriter object. Also initializes the indexbuilder variable in this
* Construct AllClassesIndexWriter object. Also initializes the indexBuilder variable in this
* class.
*
* @param configuration The current configuration
* @param filename Path to the file which is getting generated.
* @param indexbuilder Unicode based Index from {@link IndexBuilder}
* @param indexBuilder Unicode based Index from {@link IndexBuilder}
*/
public AllClassesIndexWriter(HtmlConfiguration configuration,
DocPath filename, IndexBuilder indexbuilder) {
DocPath filename, IndexBuilder indexBuilder) {
super(configuration, filename);
this.indexbuilder = indexbuilder;
this.indexBuilder = indexBuilder;
}

/**
@@ -134,8 +134,8 @@ protected void addContents(Content content) {
.addTab(resources.errorSummary, e -> utils.isError((TypeElement)e))
.addTab(resources.annotationTypeSummary, utils::isAnnotationType)
.setTabScript(i -> "show(" + i + ");");
for (Character unicode : indexbuilder.index()) {
for (Element element : indexbuilder.getMemberList(unicode)) {
for (Character unicode : indexBuilder.keys()) {
for (Element element : indexBuilder.getMemberList(unicode)) {
TypeElement typeElement = (TypeElement) element;
if (!utils.isCoreClass(typeElement)) {
continue;
@@ -150,7 +150,6 @@ protected void generateOtherFiles(DocletEnvironment docEnv, ClassTree classtree)
if (options.classUse()) {
ClassUseWriter.generate(configuration, classtree);
}
IndexBuilder indexbuilder = new IndexBuilder(configuration, nodeprecated);

if (options.createTree()) {
TreeWriter.generate(configuration, classtree);
@@ -169,11 +168,12 @@ protected void generateOtherFiles(DocletEnvironment docEnv, ClassTree classtree)
}

if (options.createIndex()) {
IndexBuilder indexBuilder = new IndexBuilder(configuration, nodeprecated);
configuration.buildSearchTagIndex();
if (options.splitIndex()) {
SplitIndexWriter.generate(configuration, indexbuilder);
SplitIndexWriter.generate(configuration, indexBuilder);
} else {
SingleIndexWriter.generate(configuration, indexbuilder);
SingleIndexWriter.generate(configuration, indexBuilder);
}
AllClassesIndexWriter.generate(configuration,
new IndexBuilder(configuration, nodeprecated, true));
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -64,26 +64,26 @@
*
* @param configuration the configuration for this doclet
* @param filename Name of the index file to be generated.
* @param indexbuilder Unicode based Index from {@link IndexBuilder}
* @param indexBuilder Unicode based Index from {@link IndexBuilder}
*/
public SingleIndexWriter(HtmlConfiguration configuration,
DocPath filename,
IndexBuilder indexbuilder) {
super(configuration, filename, indexbuilder);
IndexBuilder indexBuilder) {
super(configuration, filename, indexBuilder);
}

/**
* Generate single index file, for all Unicode characters.
*
* @param configuration the configuration for this doclet
* @param indexbuilder IndexBuilder built by {@link IndexBuilder}
* @param indexBuilder IndexBuilder built by {@link IndexBuilder}
* @throws DocFileIOException if there is a problem generating the index
*/
public static void generate(HtmlConfiguration configuration,
IndexBuilder indexbuilder) throws DocFileIOException {
IndexBuilder indexBuilder) throws DocFileIOException {
DocPath filename = DocPaths.INDEX_ALL;
SingleIndexWriter indexgen = new SingleIndexWriter(configuration,
filename, indexbuilder);
filename, indexBuilder);
indexgen.generateIndexFile();
}

@@ -101,17 +101,17 @@ protected void generateIndexFile() throws DocFileIOException {
headerContent.add(navBar.getContent(true));
HtmlTree divTree = new HtmlTree(HtmlTag.DIV);
divTree.setStyle(HtmlStyle.contentContainer);
elements = new TreeSet<>(indexbuilder.getIndexMap().keySet());
elements = new TreeSet<>(indexBuilder.asMap().keySet());
elements.addAll(configuration.tagSearchIndexKeys);
addLinksForIndexes(divTree);
for (Character unicode : elements) {
if (configuration.tagSearchIndexMap.get(unicode) == null) {
addContents(unicode, indexbuilder.getMemberList(unicode), divTree);
} else if (indexbuilder.getMemberList(unicode) == null) {
addContents(unicode, indexBuilder.getMemberList(unicode), divTree);
} else if (indexBuilder.getMemberList(unicode) == null) {
addSearchContents(unicode, configuration.tagSearchIndexMap.get(unicode), divTree);
} else {
addContents(unicode, indexbuilder.getMemberList(unicode),
configuration.tagSearchIndexMap.get(unicode), divTree);
addContents(unicode, indexBuilder.getMemberList(unicode),
configuration.tagSearchIndexMap.get(unicode), divTree);
}
}
addLinksForIndexes(divTree);
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -68,14 +68,14 @@
*
* @param configuration the configuration for this doclet
* @param path Path to the file which is getting generated.
* @param indexbuilder Unicode based Index from {@link IndexBuilder}
* @param indexBuilder Unicode based Index from {@link IndexBuilder}
* @param elements the collection of characters for which to generate index files
*/
public SplitIndexWriter(HtmlConfiguration configuration,
DocPath path,
IndexBuilder indexbuilder,
IndexBuilder indexBuilder,
Collection<Character> elements) {
super(configuration, path, indexbuilder);
super(configuration, path, indexBuilder);
this.indexElements = new ArrayList<>(elements);
}

@@ -84,13 +84,13 @@ public SplitIndexWriter(HtmlConfiguration configuration,
* the members starting with the particular unicode character.
*
* @param configuration the configuration for this doclet
* @param indexbuilder IndexBuilder built by {@link IndexBuilder}
* @param indexBuilder IndexBuilder built by {@link IndexBuilder}
* @throws DocFileIOException if there is a problem generating the index files
*/
public static void generate(HtmlConfiguration configuration,
IndexBuilder indexbuilder) throws DocFileIOException {
IndexBuilder indexBuilder) throws DocFileIOException {
DocPath path = DocPaths.INDEX_FILES;
Set<Character> keys = new TreeSet<>(indexbuilder.getIndexMap().keySet());
Set<Character> keys = new TreeSet<>(indexBuilder.asMap().keySet());
keys.addAll(configuration.tagSearchIndexKeys);
ListIterator<Character> li = new ArrayList<>(keys).listIterator();
int prev;
@@ -102,7 +102,7 @@ public static void generate(HtmlConfiguration configuration,
DocPath filename = DocPaths.indexN(li.nextIndex());
SplitIndexWriter indexgen = new SplitIndexWriter(configuration,
path.resolve(filename),
indexbuilder, keys);
indexBuilder, keys);
indexgen.generateIndexFile((Character) ch);
if (!li.hasNext()) {
indexgen.createSearchIndexFiles();
@@ -134,11 +134,11 @@ protected void generateIndexFile(Character unicode) throws DocFileIOException {
divTree.setStyle(HtmlStyle.contentContainer);
addLinksForIndexes(divTree);
if (configuration.tagSearchIndexMap.get(unicode) == null) {
addContents(unicode, indexbuilder.getMemberList(unicode), divTree);
} else if (indexbuilder.getMemberList(unicode) == null) {
addContents(unicode, indexBuilder.getMemberList(unicode), divTree);
} else if (indexBuilder.getMemberList(unicode) == null) {
addSearchContents(unicode, configuration.tagSearchIndexMap.get(unicode), divTree);
} else {
addContents(unicode, indexbuilder.getMemberList(unicode),
addContents(unicode, indexBuilder.getMemberList(unicode),
configuration.tagSearchIndexMap.get(unicode), divTree);
}
addLinksForIndexes(divTree);

0 comments on commit 9fdcdf4

Please sign in to comment.