Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 127647 Details for
Bug 237241
Content assist does not scale with javadoc on type with many members
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix
bug237241d_011.txt (text/plain), 35.07 KB, created by
David Audel
on 2009-03-05 08:25:43 EST
(
hide
)
Description:
Proposed fix
Filename:
MIME Type:
Creator:
David Audel
Created:
2009-03-05 08:25:43 EST
Size:
35.07 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: model/org/eclipse/jdt/internal/core/JavadocConstants.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavadocConstants.java,v >retrieving revision 1.7 >diff -u -r1.7 JavadocConstants.java >--- model/org/eclipse/jdt/internal/core/JavadocConstants.java 10 May 2006 18:03:47 -0000 1.7 >+++ model/org/eclipse/jdt/internal/core/JavadocConstants.java 5 Mar 2009 13:23:25 -0000 >@@ -14,10 +14,12 @@ > > String ANCHOR_PREFIX_END = "\""; //$NON-NLS-1$ > String ANCHOR_PREFIX_START = "<A NAME=\""; //$NON-NLS-1$ >+ int ANCHOR_PREFIX_START_LENGHT = ANCHOR_PREFIX_START.length(); > String ANCHOR_SUFFIX = "</A>"; //$NON-NLS-1$ > int ANCHOR_SUFFIX_LENGTH = JavadocConstants.ANCHOR_SUFFIX.length(); > String CONSTRUCTOR_DETAIL = "<!-- ========= CONSTRUCTOR DETAIL ======== -->"; //$NON-NLS-1$ > String CONSTRUCTOR_SUMMARY = "<!-- ======== CONSTRUCTOR SUMMARY ======== -->"; //$NON-NLS-1$ >+ String FIELD_DETAIL= "<!-- ============ FIELD DETAIL =========== -->"; //$NON-NLS-1$ > String FIELD_SUMMARY = "<!-- =========== FIELD SUMMARY =========== -->"; //$NON-NLS-1$ > String ENUM_CONSTANT_SUMMARY = "<!-- =========== ENUM CONSTANT SUMMARY =========== -->"; //$NON-NLS-1$ > String ANNOTATION_TYPE_REQUIRED_MEMBER_SUMMARY = "<!-- =========== ANNOTATION TYPE REQUIRED MEMBER SUMMARY =========== -->"; //$NON-NLS-1$ >@@ -29,6 +31,7 @@ > String METHOD_SUMMARY = "<!-- ========== METHOD SUMMARY =========== -->"; //$NON-NLS-1$ > String NESTED_CLASS_SUMMARY = "<!-- ======== NESTED CLASS SUMMARY ======== -->"; //$NON-NLS-1$ > String PACKAGE_FILE_NAME = "package-summary.html"; //$NON-NLS-1$ >+ String SEPARATOR_START = "<!-- ="; //$NON-NLS-1$ > String START_OF_CLASS_DATA = "<!-- ======== START OF CLASS DATA ======== -->"; //$NON-NLS-1$ > int START_OF_CLASS_DATA_LENGTH = JavadocConstants.START_OF_CLASS_DATA.length(); > } >Index: model/org/eclipse/jdt/internal/core/BinaryField.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryField.java,v >retrieving revision 1.39 >diff -u -r1.39 BinaryField.java >--- model/org/eclipse/jdt/internal/core/BinaryField.java 23 Oct 2008 13:56:41 -0000 1.39 >+++ model/org/eclipse/jdt/internal/core/BinaryField.java 5 Mar 2009 13:23:25 -0000 >@@ -14,7 +14,6 @@ > import org.eclipse.jdt.core.Flags; > import org.eclipse.jdt.core.IAnnotation; > import org.eclipse.jdt.core.IField; >-import org.eclipse.jdt.core.IJavaModelStatusConstants; > import org.eclipse.jdt.core.JavaModelException; > import org.eclipse.jdt.core.Signature; > import org.eclipse.jdt.internal.compiler.env.IBinaryAnnotation; >@@ -115,26 +114,8 @@ > } > } > public String getAttachedJavadoc(IProgressMonitor monitor) throws JavaModelException { >- String contents = ((BinaryType) getDeclaringType()).getJavadocContents(monitor); >- if (contents == null) return null; >- int indexAnchor = contents.indexOf( >- JavadocConstants.ANCHOR_PREFIX_START + getElementName() + JavadocConstants.ANCHOR_PREFIX_END); >- if (indexAnchor == -1) { >- // this might be the case for a private field that has no javadoc entry >- return null; >- } >- int indexOfEndLink = contents.indexOf(JavadocConstants.ANCHOR_SUFFIX, indexAnchor); >- if (indexOfEndLink == -1) throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.UNKNOWN_JAVADOC_FORMAT, this)); >- int indexOfNextField = contents.indexOf(JavadocConstants.ANCHOR_PREFIX_START, indexOfEndLink); >- int indexOfBottom = contents.indexOf(JavadocConstants.CONSTRUCTOR_DETAIL, indexOfEndLink); >- if (indexOfBottom == -1) { >- indexOfBottom = contents.indexOf(JavadocConstants.METHOD_DETAIL, indexOfEndLink); >- if (indexOfBottom == -1) { >- indexOfBottom = contents.indexOf(JavadocConstants.END_OF_CLASS_DATA, indexOfEndLink); >- } >- } >- indexOfNextField= Math.min(indexOfNextField, indexOfBottom); >- if (indexOfNextField == -1) throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.UNKNOWN_JAVADOC_FORMAT, this)); >- return contents.substring(indexOfEndLink + JavadocConstants.ANCHOR_SUFFIX_LENGTH, indexOfNextField); >+ JavadocContents javadocContents = ((BinaryType) this.getDeclaringType()).getJavadocContents(monitor); >+ if (javadocContents == null) return null; >+ return javadocContents.getFieldDoc(this); > } > } >Index: model/org/eclipse/jdt/internal/core/BinaryMethod.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java,v >retrieving revision 1.103 >diff -u -r1.103 BinaryMethod.java >--- model/org/eclipse/jdt/internal/core/BinaryMethod.java 10 Jan 2009 01:30:45 -0000 1.103 >+++ model/org/eclipse/jdt/internal/core/BinaryMethod.java 5 Mar 2009 13:23:25 -0000 >@@ -188,15 +188,17 @@ > if ((modifiers & ClassFileConstants.AccSynthetic) != 0) { > return this.parameterNames = getRawParameterNames(paramCount); > } >- String javadocContents = null; >+ JavadocContents javadocContents = null; > IType declaringType = getDeclaringType(); > PerProjectInfo projectInfo = JavaModelManager.getJavaModelManager().getPerProjectInfoCheckExistence(getJavaProject().getProject()); > synchronized (projectInfo.javadocCache) { >- javadocContents = (String) projectInfo.javadocCache.get(declaringType); >+ javadocContents = (JavadocContents) projectInfo.javadocCache.get(declaringType); > if (javadocContents == null) { > projectInfo.javadocCache.put(declaringType, BinaryType.EMPTY_JAVADOC); > } > } >+ >+ String methodDoc = null; > if (javadocContents == null) { > long timeOut = 50; // default value > try { >@@ -245,23 +247,23 @@ > // ignore > } > } >- javadocContents = nameCollector.getJavadoc(); >+ methodDoc = nameCollector.getJavadoc(); > } else if (javadocContents != BinaryType.EMPTY_JAVADOC){ > // need to extract the part relative to the binary method since javadoc contains the javadoc for the declaring type > try { >- javadocContents = extractJavadoc(declaringType, javadocContents); >+ methodDoc = javadocContents.getMethodDoc(this); > } catch(JavaModelException e) { > javadocContents = null; > } > } >- if (javadocContents != null && javadocContents != BinaryType.EMPTY_JAVADOC) { >- final int indexOfOpenParen = javadocContents.indexOf('('); >+ if (methodDoc != null) { >+ final int indexOfOpenParen = methodDoc.indexOf('('); > if (indexOfOpenParen != -1) { >- final int indexOfClosingParen = javadocContents.indexOf(')', indexOfOpenParen); >+ final int indexOfClosingParen = methodDoc.indexOf(')', indexOfOpenParen); > if (indexOfClosingParen != -1) { > final char[] paramsSource = > CharOperation.replace( >- javadocContents.substring(indexOfOpenParen + 1, indexOfClosingParen).toCharArray(), >+ methodDoc.substring(indexOfOpenParen + 1, indexOfClosingParen).toCharArray(), > " ".toCharArray(), //$NON-NLS-1$ > new char[] {' '}); > final char[][] params = splitParameters(paramsSource, paramCount); >@@ -553,76 +555,8 @@ > } > } > public String getAttachedJavadoc(IProgressMonitor monitor) throws JavaModelException { >- IType declaringType = getDeclaringType(); >- >- String contents = ((BinaryType) declaringType).getJavadocContents(monitor); >- return extractJavadoc(declaringType, contents); >-} >-private String extractJavadoc(IType declaringType, String contents) throws JavaModelException { >- if (contents == null) return null; >- >- String typeQualifiedName = null; >- final boolean declaringTypeIsMember = declaringType.isMember(); >- if (declaringTypeIsMember) { >- IType currentType = declaringType; >- StringBuffer buffer = new StringBuffer(); >- while (currentType != null) { >- buffer.insert(0, currentType.getElementName()); >- currentType = currentType.getDeclaringType(); >- if (currentType != null) { >- buffer.insert(0, '.'); >- } >- } >- typeQualifiedName = new String(buffer.toString()); >- } else { >- typeQualifiedName = declaringType.getElementName(); >- } >- String methodName = getElementName(); >- if (isConstructor()) { >- methodName = typeQualifiedName; >- } >- IBinaryMethod info = (IBinaryMethod) getElementInfo(); >- char[] genericSignature = info.getGenericSignature(); >- String anchor = null; >- if (genericSignature != null) { >- genericSignature = CharOperation.replaceOnCopy(genericSignature, '/', '.'); >- anchor = Util.toAnchor(0, genericSignature, methodName, Flags.isVarargs(getFlags())); >- if (anchor == null) throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.UNKNOWN_JAVADOC_FORMAT, this)); >- } else { >- anchor = Signature.toString(getSignature().replace('/', '.'), methodName, null, true, false, Flags.isVarargs(getFlags())); >- } >- if (declaringTypeIsMember && !Flags.isStatic(declaringType.getFlags())) { >- int indexOfOpeningParen = anchor.indexOf('('); >- if (indexOfOpeningParen == -1) return null; >- int index = indexOfOpeningParen +1; >- indexOfOpeningParen++; >- int indexOfComma = anchor.indexOf(',', index); >- if (indexOfComma != -1) { >- index = indexOfComma + 2; >- } else { >- index = anchor.indexOf(')', index); >- } >- anchor = anchor.substring(0, indexOfOpeningParen) + anchor.substring(index); >- } >- int indexAnchor = contents.indexOf(JavadocConstants.ANCHOR_PREFIX_START + anchor + JavadocConstants.ANCHOR_PREFIX_END); >- if (indexAnchor == -1) { >- return null; // method without javadoc >- } >- int indexOfEndLink = contents.indexOf(JavadocConstants.ANCHOR_SUFFIX, indexAnchor); >- if (indexOfEndLink == -1) throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.UNKNOWN_JAVADOC_FORMAT, this)); >- int indexOfNextMethod = contents.indexOf(JavadocConstants.ANCHOR_PREFIX_START, indexOfEndLink); >- // find bottom >- int indexOfBottom = -1; >- if (isConstructor()) { >- indexOfBottom = contents.indexOf(JavadocConstants.METHOD_DETAIL, indexOfEndLink); >- if (indexOfBottom == -1) { >- indexOfBottom = contents.indexOf(JavadocConstants.END_OF_CLASS_DATA, indexOfEndLink); >- } >- } else { >- indexOfBottom = contents.indexOf(JavadocConstants.END_OF_CLASS_DATA, indexOfEndLink); >- } >- if (indexOfBottom == -1) throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.UNKNOWN_JAVADOC_FORMAT, this)); >- indexOfNextMethod = indexOfNextMethod == -1 ? indexOfBottom : Math.min(indexOfNextMethod, indexOfBottom); >- return contents.substring(indexOfEndLink + JavadocConstants.ANCHOR_SUFFIX_LENGTH, indexOfNextMethod); >+ JavadocContents javadocContents = ((BinaryType) this.getDeclaringType()).getJavadocContents(monitor); >+ if (javadocContents == null) return null; >+ return javadocContents.getMethodDoc(this); > } > } >Index: model/org/eclipse/jdt/internal/core/BinaryType.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryType.java,v >retrieving revision 1.162 >diff -u -r1.162 BinaryType.java >--- model/org/eclipse/jdt/internal/core/BinaryType.java 25 Nov 2008 18:08:53 -0000 1.162 >+++ model/org/eclipse/jdt/internal/core/BinaryType.java 5 Mar 2009 13:23:25 -0000 >@@ -45,7 +45,7 @@ > private static final IMethod[] NO_METHODS = new IMethod[0]; > private static final IType[] NO_TYPES = new IType[0]; > private static final IInitializer[] NO_INITIALIZERS = new IInitializer[0]; >- public static final String EMPTY_JAVADOC = org.eclipse.jdt.internal.compiler.util.Util.EMPTY_STRING; >+ public static final JavadocContents EMPTY_JAVADOC = new JavadocContents(null, org.eclipse.jdt.internal.compiler.util.Util.EMPTY_STRING); > > protected BinaryType(JavaElement parent, String name) { > super(parent, name); >@@ -991,62 +991,17 @@ > buffer.append("<anonymous>"); //$NON-NLS-1$ > } > public String getAttachedJavadoc(IProgressMonitor monitor) throws JavaModelException { >- final String contents = getJavadocContents(monitor); >- if (contents == null) return null; >- final int indexOfStartOfClassData = contents.indexOf(JavadocConstants.START_OF_CLASS_DATA); >- if (indexOfStartOfClassData == -1) throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.UNKNOWN_JAVADOC_FORMAT, this)); >- int indexOfNextSummary = contents.indexOf(JavadocConstants.NESTED_CLASS_SUMMARY); >- if (isEnum() && indexOfNextSummary == -1) { >- // try to find enum constant summary start >- indexOfNextSummary = contents.indexOf(JavadocConstants.ENUM_CONSTANT_SUMMARY); >- } >- if (isAnnotation() && indexOfNextSummary == -1) { >- // try to find required enum constant summary start >- indexOfNextSummary = contents.indexOf(JavadocConstants.ANNOTATION_TYPE_REQUIRED_MEMBER_SUMMARY); >- if (indexOfNextSummary == -1) { >- // try to find optional enum constant summary start >- indexOfNextSummary = contents.indexOf(JavadocConstants.ANNOTATION_TYPE_OPTIONAL_MEMBER_SUMMARY); >- } >- } >- if (indexOfNextSummary == -1) { >- // try to find field summary start >- indexOfNextSummary = contents.indexOf(JavadocConstants.FIELD_SUMMARY); >- } >- if (indexOfNextSummary == -1) { >- // try to find constructor summary start >- indexOfNextSummary = contents.indexOf(JavadocConstants.CONSTRUCTOR_SUMMARY); >- } >- if (indexOfNextSummary == -1) { >- // try to find method summary start >- indexOfNextSummary = contents.indexOf(JavadocConstants.METHOD_SUMMARY); >- } >- if (indexOfNextSummary == -1) { >- // we take the end of class data >- indexOfNextSummary = contents.indexOf(JavadocConstants.END_OF_CLASS_DATA); >- } >- if (indexOfNextSummary == -1) { >- throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.UNKNOWN_JAVADOC_FORMAT, this)); >- } >- /* >- * Check out to cut off the hierarchy see 119844 >- * We remove what the contents between the start of class data and the first <P> >- */ >- int start = indexOfStartOfClassData + JavadocConstants.START_OF_CLASS_DATA_LENGTH; >- int indexOfFirstParagraph = contents.indexOf("<P>", start); //$NON-NLS-1$ >- if (indexOfFirstParagraph == -1) { >- indexOfFirstParagraph = contents.indexOf("<p>", start); //$NON-NLS-1$ >- } >- if (indexOfFirstParagraph != -1 && indexOfFirstParagraph < indexOfNextSummary) { >- start = indexOfFirstParagraph; >- } >- return contents.substring(start, indexOfNextSummary); >+ JavadocContents javadocContents = getJavadocContents(monitor); >+ if (javadocContents == null) return null; >+ return javadocContents.getTypeDoc(); > } >-public String getJavadocContents(IProgressMonitor monitor) throws JavaModelException { >+public JavadocContents getJavadocContents(IProgressMonitor monitor) throws JavaModelException { > PerProjectInfo projectInfo = JavaModelManager.getJavaModelManager().getPerProjectInfoCheckExistence(getJavaProject().getProject()); >- String cachedJavadoc = null; >+ JavadocContents cachedJavadoc = null; > synchronized (projectInfo.javadocCache) { >- cachedJavadoc = (String) projectInfo.javadocCache.get(this); >+ cachedJavadoc = (JavadocContents) projectInfo.javadocCache.get(this); > } >+ > if (cachedJavadoc != null && cachedJavadoc != EMPTY_JAVADOC) { > return cachedJavadoc; > } >@@ -1077,12 +1032,12 @@ > } > > pathBuffer.append(pack.getElementName().replace('.', '/')).append('/').append(typeQualifiedName).append(JavadocConstants.HTML_EXTENSION); >- > if (monitor != null && monitor.isCanceled()) throw new OperationCanceledException(); > final String contents = getURLContents(String.valueOf(pathBuffer)); >+ JavadocContents javadocContents = new JavadocContents(this, contents); > synchronized (projectInfo.javadocCache) { >- projectInfo.javadocCache.put(this, contents); >+ projectInfo.javadocCache.put(this, javadocContents); > } >- return contents; >+ return javadocContents; > } > } >Index: model/org/eclipse/jdt/internal/core/JavadocContents.java >=================================================================== >RCS file: model/org/eclipse/jdt/internal/core/JavadocContents.java >diff -N model/org/eclipse/jdt/internal/core/JavadocContents.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ model/org/eclipse/jdt/internal/core/JavadocContents.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,497 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.internal.core; >+ >+import org.eclipse.jdt.core.Flags; >+import org.eclipse.jdt.core.IField; >+import org.eclipse.jdt.core.IJavaElement; >+import org.eclipse.jdt.core.IJavaModelStatusConstants; >+import org.eclipse.jdt.core.IJavaProject; >+import org.eclipse.jdt.core.IMethod; >+import org.eclipse.jdt.core.IType; >+import org.eclipse.jdt.core.JavaModelException; >+import org.eclipse.jdt.core.Signature; >+import org.eclipse.jdt.core.compiler.CharOperation; >+import org.eclipse.jdt.internal.compiler.env.IBinaryMethod; >+import org.eclipse.jdt.internal.compiler.util.HashtableOfObjectToIntArray; >+import org.eclipse.jdt.internal.core.util.Util; >+ >+public class JavadocContents { >+ private static final int[] UNKNOWN_FORMAT = new int[0]; >+ >+ private BinaryType type; >+ private String content; >+ >+ private int childrenStart; >+ >+ private boolean hasComputedChildrenSections = false; >+ private int indexOfFieldDetails; >+ private int indexOfConstructorDetails; >+ private int indexOfMethodDetails; >+ private int indexOfEndOfClassData; >+ >+ private int indexOfFieldsBottom; >+ private int indexOfConstructorsBottom; >+ private int indexOfMethodsBottom; >+ private int indexOfAllMethodsTop; >+ private int indexOfAllMethodsBottom; >+ >+ private int[] typeDocRange; >+ private HashtableOfObjectToIntArray fieldDocRanges; >+ private HashtableOfObjectToIntArray methodDocRanges; >+ >+ private int[] fieldAnchorIndexes; >+ private int fieldAnchorIndexesCount; >+ private int fieldLastAnchorFoundIndex; >+ private int[] methodAnchorIndexes; >+ private int methodAnchorIndexesCount; >+ private int methodLastAnchorFoundIndex; >+ private int[] unknownFormatAnchorIndexes; >+ private int unknownFormatAnchorIndexesCount; >+ private int unknownFormatLastAnchorFoundIndex; >+ private int[] tempAnchorIndexes; >+ private int tempAnchorIndexesCount; >+ private int tempLastAnchorFoundIndex; >+ >+ public JavadocContents(BinaryType type, String content) { >+ this.type = type; >+ this.content = content; >+ } >+ >+ /* >+ * Return the full content of the javadoc >+ */ >+ public String getContent() { >+ return this.content; >+ } >+ >+ /* >+ * Returns the part of the javadoc that describe the type >+ */ >+ public String getTypeDoc() throws JavaModelException { >+ if (this.content == null) return null; >+ >+ synchronized (this) { >+ if (this.typeDocRange == null) { >+ computeTypeRange(); >+ } >+ } >+ >+ if (this.typeDocRange != null) { >+ if (this.typeDocRange == UNKNOWN_FORMAT) throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.UNKNOWN_JAVADOC_FORMAT, this.type)); >+ return this.content.substring(this.typeDocRange[0], this.typeDocRange[1]); >+ } >+ return null; >+ } >+ >+ /* >+ * Returns the part of the javadoc that describe a field of the type >+ */ >+ public String getFieldDoc(IField child) throws JavaModelException { >+ if (this.content == null) return null; >+ >+ int[] range = null; >+ synchronized (this) { >+ if (this.fieldDocRanges == null) { >+ this.fieldDocRanges = new HashtableOfObjectToIntArray(); >+ } else { >+ range = this.fieldDocRanges.get(child); >+ } >+ >+ if (range == null) { >+ range = computeFieldRange(child); >+ this.fieldDocRanges.put(child, range); >+ } >+ } >+ >+ if (range != null) { >+ if (range == UNKNOWN_FORMAT) throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.UNKNOWN_JAVADOC_FORMAT, child)); >+ return this.content.substring(range[0], range[1]); >+ } >+ return null; >+ } >+ >+ /* >+ * Returns the part of the javadoc that describe a method of the type >+ */ >+ public String getMethodDoc(IMethod child) throws JavaModelException { >+ if (this.content == null) return null; >+ >+ int[] range = null; >+ synchronized (this) { >+ if (this.methodDocRanges == null) { >+ this.methodDocRanges = new HashtableOfObjectToIntArray(); >+ } else { >+ range = this.methodDocRanges.get(child); >+ } >+ >+ if (range == null) { >+ range = computeMethodRange(child); >+ this.methodDocRanges.put(child, range); >+ } >+ } >+ >+ if (range != null) { >+ if (range == UNKNOWN_FORMAT) throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.UNKNOWN_JAVADOC_FORMAT, child)); >+ return this.content.substring(range[0], range[1]); >+ } >+ return null; >+ } >+ >+ /* >+ * Compute the ranges of the parts of the javadoc that describe each method of the type >+ */ >+ private int[] computeChildRange(String anchor, int indexOfSectionBottom) throws JavaModelException { >+ >+ // checks each known anchor locations >+ if (this.tempAnchorIndexesCount > 0) { >+ for (int i = 0; i < this.tempAnchorIndexesCount; i++) { >+ int anchorEndStart = this.tempAnchorIndexes[i]; >+ >+ if (anchorEndStart != -1 && this.content.startsWith(anchor, anchorEndStart)) { >+ >+ this.tempAnchorIndexes[i] = -1; >+ >+ return computeChildRange(anchorEndStart, anchor, indexOfSectionBottom); >+ } >+ } >+ } >+ >+ int fromIndex = this.tempLastAnchorFoundIndex; >+ int index; >+ >+ // check each next unknown anchor locations >+ while ((index = this.content.indexOf(JavadocConstants.ANCHOR_PREFIX_START, fromIndex)) != -1 && (index < indexOfSectionBottom || indexOfSectionBottom == -1)) { >+ fromIndex = index + 1; >+ >+ int anchorEndStart = index + JavadocConstants.ANCHOR_PREFIX_START_LENGHT; >+ >+ this.tempLastAnchorFoundIndex = anchorEndStart; >+ >+ if (this.content.startsWith(anchor, anchorEndStart)) { >+ >+ return computeChildRange(anchorEndStart, anchor, indexOfSectionBottom); >+ } else { >+ if (this.tempAnchorIndexes.length == this.tempAnchorIndexesCount) { >+ System.arraycopy(this.tempAnchorIndexes, 0, this.tempAnchorIndexes = new int[this.tempAnchorIndexesCount + 20], 0, this.tempAnchorIndexesCount); >+ } >+ >+ this.tempAnchorIndexes[this.tempAnchorIndexesCount++] = anchorEndStart; >+ } >+ } >+ >+ return null; >+ } >+ >+ private int[] computeChildRange(int anchorEndStart, String anchor, int indexOfBottom) { >+ int[] range = null; >+ >+ // try to find the bottom of the section >+ if (indexOfBottom != -1) { >+ // try to find the end of the anchor >+ int indexOfEndLink = this.content.indexOf(JavadocConstants.ANCHOR_SUFFIX, anchorEndStart + anchor.length()); >+ if (indexOfEndLink != -1) { >+ // try to find the next anchor >+ int indexOfNextElement = this.content.indexOf(JavadocConstants.ANCHOR_PREFIX_START, indexOfEndLink); >+ >+ int javadocStart = indexOfEndLink + JavadocConstants.ANCHOR_SUFFIX_LENGTH; >+ int javadocEnd = indexOfNextElement == -1 ? indexOfBottom : Math.min(indexOfNextElement, indexOfBottom); >+ range = new int[]{javadocStart, javadocEnd}; >+ } else { >+ // the anchor has no suffix >+ range = UNKNOWN_FORMAT; >+ } >+ } else { >+ // the detail section has no bottom >+ range = UNKNOWN_FORMAT; >+ } >+ >+ return range; >+ } >+ >+ private void computeChildrenSections() { >+ // try to find the next separator part >+ int lastIndex = this.content.indexOf(JavadocConstants.SEPARATOR_START, this.childrenStart); >+ >+ // try to find field detail start >+ this.indexOfFieldDetails = this.content.indexOf(JavadocConstants.FIELD_DETAIL, lastIndex); >+ lastIndex = this.indexOfFieldDetails == -1 ? lastIndex : this.indexOfFieldDetails; >+ >+ // try to find constructor detail start >+ this.indexOfConstructorDetails = this.content.indexOf(JavadocConstants.CONSTRUCTOR_DETAIL, lastIndex); >+ lastIndex = this.indexOfConstructorDetails == -1 ? lastIndex : this.indexOfConstructorDetails; >+ >+ // try to find method detail start >+ this.indexOfMethodDetails = this.content.indexOf(JavadocConstants.METHOD_DETAIL, lastIndex); >+ lastIndex = this.indexOfMethodDetails == -1 ? lastIndex : this.indexOfMethodDetails; >+ >+ // we take the end of class data >+ this.indexOfEndOfClassData = this.content.indexOf(JavadocConstants.END_OF_CLASS_DATA, lastIndex); >+ >+ // try to find the field detail end >+ this.indexOfFieldsBottom = >+ this.indexOfConstructorDetails != -1 ? this.indexOfConstructorDetails : >+ this.indexOfMethodDetails != -1 ? this.indexOfMethodDetails: >+ this.indexOfEndOfClassData; >+ >+ // try to find the constructor detail end >+ this.indexOfConstructorsBottom = >+ this.indexOfMethodDetails != -1 ? this.indexOfMethodDetails: >+ this.indexOfEndOfClassData; >+ >+ // try to find the method detail end >+ this.indexOfMethodsBottom = this.indexOfEndOfClassData; >+ >+ this.indexOfAllMethodsTop = >+ this.indexOfConstructorDetails != -1 ? >+ this.indexOfConstructorDetails : >+ this.indexOfMethodDetails; >+ >+ this.indexOfAllMethodsBottom = this.indexOfMethodsBottom; >+ >+ this.hasComputedChildrenSections = true; >+ } >+ >+ /* >+ * Compute the ranges of the parts of the javadoc that describe each child of the type (fields, methods) >+ */ >+ private int[] computeFieldRange(IField field) throws JavaModelException { >+ if (!this.hasComputedChildrenSections) { >+ computeChildrenSections(); >+ } >+ >+ String anchor = field.getElementName() + JavadocConstants.ANCHOR_PREFIX_END; >+ >+ int[] range = null; >+ >+ if (this.indexOfFieldDetails == -1 || this.indexOfFieldsBottom == -1) { >+ // the detail section has no top or bottom, so the doc has an unknown format >+ if (this.unknownFormatAnchorIndexes == null) { >+ this.unknownFormatAnchorIndexes = new int[this.type.getChildren().length]; >+ this.unknownFormatAnchorIndexesCount = 0; >+ this.unknownFormatLastAnchorFoundIndex = this.childrenStart; >+ } >+ >+ this.tempAnchorIndexes = this.unknownFormatAnchorIndexes; >+ this.tempAnchorIndexesCount = this.unknownFormatAnchorIndexesCount; >+ this.tempLastAnchorFoundIndex = this.unknownFormatLastAnchorFoundIndex; >+ >+ range = computeChildRange(anchor, this.indexOfFieldsBottom); >+ >+ this.unknownFormatLastAnchorFoundIndex = this.tempLastAnchorFoundIndex; >+ this.unknownFormatAnchorIndexesCount = this.tempAnchorIndexesCount; >+ this.unknownFormatAnchorIndexes = this.tempAnchorIndexes; >+ } else { >+ if (this.fieldAnchorIndexes == null) { >+ this.fieldAnchorIndexes = new int[this.type.getFields().length]; >+ this.fieldAnchorIndexesCount = 0; >+ this.fieldLastAnchorFoundIndex = this.indexOfFieldDetails; >+ } >+ >+ this.tempAnchorIndexes = this.fieldAnchorIndexes; >+ this.tempAnchorIndexesCount = this.fieldAnchorIndexesCount; >+ this.tempLastAnchorFoundIndex = this.fieldLastAnchorFoundIndex; >+ >+ range = computeChildRange(anchor, this.indexOfFieldsBottom); >+ >+ this.fieldLastAnchorFoundIndex = this.tempLastAnchorFoundIndex; >+ this.fieldAnchorIndexesCount = this.tempAnchorIndexesCount; >+ this.fieldAnchorIndexes = this.tempAnchorIndexes; >+ } >+ >+ return range; >+ } >+ >+ /* >+ * Compute the ranges of the parts of the javadoc that describe each method of the type >+ */ >+ private int[] computeMethodRange(IMethod method) throws JavaModelException { >+ if (!this.hasComputedChildrenSections) { >+ computeChildrenSections(); >+ } >+ >+ String anchor = computeMethodAnchorPrefixEnd((BinaryMethod)method); >+ >+ int[] range = null; >+ >+ if (this.indexOfAllMethodsTop == -1 || this.indexOfAllMethodsBottom == -1) { >+ // the detail section has no top or bottom, so the doc has an unknown format >+ if (this.unknownFormatAnchorIndexes == null) { >+ this.unknownFormatAnchorIndexes = new int[this.type.getChildren().length]; >+ this.unknownFormatAnchorIndexesCount = 0; >+ this.unknownFormatLastAnchorFoundIndex = this.childrenStart; >+ } >+ >+ this.tempAnchorIndexes = this.unknownFormatAnchorIndexes; >+ this.tempAnchorIndexesCount = this.unknownFormatAnchorIndexesCount; >+ this.tempLastAnchorFoundIndex = this.unknownFormatLastAnchorFoundIndex; >+ >+ range = computeChildRange(anchor, this.indexOfFieldsBottom); >+ >+ this.unknownFormatLastAnchorFoundIndex = this.tempLastAnchorFoundIndex; >+ this.unknownFormatAnchorIndexesCount = this.tempAnchorIndexesCount; >+ this.unknownFormatAnchorIndexes = this.tempAnchorIndexes; >+ } else { >+ if (this.methodAnchorIndexes == null) { >+ this.methodAnchorIndexes = new int[this.type.getFields().length]; >+ this.methodAnchorIndexesCount = 0; >+ this.methodLastAnchorFoundIndex = this.indexOfAllMethodsTop; >+ } >+ >+ this.tempAnchorIndexes = this.methodAnchorIndexes; >+ this.tempAnchorIndexesCount = this.methodAnchorIndexesCount; >+ this.tempLastAnchorFoundIndex = this.methodLastAnchorFoundIndex; >+ >+ range = computeChildRange(anchor, this.indexOfAllMethodsBottom); >+ >+ this.methodLastAnchorFoundIndex = this.tempLastAnchorFoundIndex; >+ this.methodAnchorIndexesCount = this.tempAnchorIndexesCount; >+ this.methodAnchorIndexes = this.tempAnchorIndexes; >+ } >+ >+ return range; >+ } >+ >+ private String computeMethodAnchorPrefixEnd(BinaryMethod method) throws JavaModelException { >+ String typeQualifiedName = null; >+ if (this.type.isMember()) { >+ IType currentType = this.type; >+ StringBuffer buffer = new StringBuffer(); >+ while (currentType != null) { >+ buffer.insert(0, currentType.getElementName()); >+ currentType = currentType.getDeclaringType(); >+ if (currentType != null) { >+ buffer.insert(0, '.'); >+ } >+ } >+ typeQualifiedName = new String(buffer.toString()); >+ } else { >+ typeQualifiedName = this.type.getElementName(); >+ } >+ >+ String methodName = method.getElementName(); >+ if (method.isConstructor()) { >+ methodName = typeQualifiedName; >+ } >+ IBinaryMethod info = (IBinaryMethod) method.getElementInfo(); >+ >+ char[] genericSignature = info.getGenericSignature(); >+ String anchor = null; >+ if (genericSignature != null) { >+ genericSignature = CharOperation.replaceOnCopy(genericSignature, '/', '.'); >+ anchor = Util.toAnchor(0, genericSignature, methodName, Flags.isVarargs(method.getFlags())); >+ if (anchor == null) throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.UNKNOWN_JAVADOC_FORMAT, method)); >+ } else { >+ anchor = Signature.toString(method.getSignature().replace('/', '.'), methodName, null, true, false, Flags.isVarargs(method.getFlags())); >+ } >+ IType declaringType = this.type; >+ if (declaringType.isMember()) { >+ int depth = 0; >+ final String packageFragmentName = declaringType.getPackageFragment().getElementName(); >+ // might need to remove a part of the signature corresponding to the synthetic argument >+ final IJavaProject javaProject = declaringType.getJavaProject(); >+ char[][] typeNames = CharOperation.splitOn('.', typeQualifiedName.toCharArray()); >+ if (!Flags.isStatic(declaringType.getFlags())) depth++; >+ StringBuffer typeName = new StringBuffer(); >+ for (int i = 0, max = typeNames.length; i < max; i++) { >+ if (typeName.length() == 0) { >+ typeName.append(typeNames[i]); >+ } else { >+ typeName.append('.').append(typeNames[i]); >+ } >+ IType resolvedType = javaProject.findType(packageFragmentName, String.valueOf(typeName)); >+ if (resolvedType != null && resolvedType.isMember() && !Flags.isStatic(resolvedType.getFlags())) depth++; >+ } >+ if (depth != 0) { >+ int indexOfOpeningParen = anchor.indexOf('('); >+ if (indexOfOpeningParen == -1) return null; >+ int index = indexOfOpeningParen; >+ indexOfOpeningParen++; >+ for (int i = 0; i < depth; i++) { >+ int indexOfComma = anchor.indexOf(',', index); >+ if (indexOfComma != -1) { >+ index = indexOfComma + 2; >+ } >+ } >+ anchor = anchor.substring(0, indexOfOpeningParen) + anchor.substring(index); >+ } >+ } >+ return anchor + JavadocConstants.ANCHOR_PREFIX_END; >+ } >+ >+ /* >+ * Compute the range of the part of the javadoc that describe the type >+ */ >+ private void computeTypeRange() throws JavaModelException { >+ final int indexOfStartOfClassData = this.content.indexOf(JavadocConstants.START_OF_CLASS_DATA); >+ if (indexOfStartOfClassData == -1) { >+ this.typeDocRange = UNKNOWN_FORMAT; >+ return; >+ } >+ int indexOfNextSeparator = this.content.indexOf(JavadocConstants.SEPARATOR_START, indexOfStartOfClassData); >+ if (indexOfNextSeparator == -1) { >+ this.typeDocRange = UNKNOWN_FORMAT; >+ return; >+ } >+ int indexOfNextSummary = this.content.indexOf(JavadocConstants.NESTED_CLASS_SUMMARY, indexOfNextSeparator); >+ if (indexOfNextSummary == -1 && this.type.isEnum()) { >+ // try to find enum constant summary start >+ indexOfNextSummary = this.content.indexOf(JavadocConstants.ENUM_CONSTANT_SUMMARY, indexOfNextSeparator); >+ } >+ if (indexOfNextSummary == -1 && this.type.isAnnotation()) { >+ // try to find required enum constant summary start >+ indexOfNextSummary = this.content.indexOf(JavadocConstants.ANNOTATION_TYPE_REQUIRED_MEMBER_SUMMARY, indexOfNextSeparator); >+ if (indexOfNextSummary == -1) { >+ // try to find optional enum constant summary start >+ indexOfNextSummary = this.content.indexOf(JavadocConstants.ANNOTATION_TYPE_OPTIONAL_MEMBER_SUMMARY, indexOfNextSeparator); >+ } >+ } >+ if (indexOfNextSummary == -1) { >+ // try to find field summary start >+ indexOfNextSummary = this.content.indexOf(JavadocConstants.FIELD_SUMMARY, indexOfNextSeparator); >+ } >+ if (indexOfNextSummary == -1) { >+ // try to find constructor summary start >+ indexOfNextSummary = this.content.indexOf(JavadocConstants.CONSTRUCTOR_SUMMARY, indexOfNextSeparator); >+ } >+ if (indexOfNextSummary == -1) { >+ // try to find method summary start >+ indexOfNextSummary = this.content.indexOf(JavadocConstants.METHOD_SUMMARY, indexOfNextSeparator); >+ } >+ >+ if (indexOfNextSummary == -1) { >+ // we take the end of class data >+ indexOfNextSummary = this.content.indexOf(JavadocConstants.END_OF_CLASS_DATA, indexOfNextSeparator); >+ } else { >+ // improve performance of computation of children ranges >+ this.childrenStart = indexOfNextSummary + 1; >+ } >+ >+ if (indexOfNextSummary == -1) { >+ this.typeDocRange = UNKNOWN_FORMAT; >+ return; >+ } >+ /* >+ * Check out to cut off the hierarchy see 119844 >+ * We remove what the contents between the start of class data and the first <P> >+ */ >+ int start = indexOfStartOfClassData + JavadocConstants.START_OF_CLASS_DATA_LENGTH; >+ int indexOfFirstParagraph = this.content.indexOf("<P>", start); //$NON-NLS-1$ >+ if (indexOfFirstParagraph == -1) { >+ indexOfFirstParagraph = this.content.indexOf("<p>", start); //$NON-NLS-1$ >+ } >+ if (indexOfFirstParagraph != -1 && indexOfFirstParagraph < indexOfNextSummary) { >+ start = indexOfFirstParagraph; >+ } >+ >+ this.typeDocRange = new int[]{start, indexOfNextSummary}; >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 237241
:
105028
|
105876
| 127647