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 179956 Details for
Bug 314170
[assist] Parsing javadocs for content assistance should be more flexible
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
proposed patch 2
patchXHTML.txt (text/plain), 27.95 KB, created by
Ayushman Jain
on 2010-09-30 10:07:20 EDT
(
hide
)
Description:
proposed patch 2
Filename:
MIME Type:
Creator:
Ayushman Jain
Created:
2010-09-30 10:07:20 EDT
Size:
27.95 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >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.107 >diff -u -r1.107 BinaryMethod.java >--- model/org/eclipse/jdt/internal/core/BinaryMethod.java 7 Sep 2010 03:17:29 -0000 1.107 >+++ model/org/eclipse/jdt/internal/core/BinaryMethod.java 30 Sep 2010 13:50:42 -0000 >@@ -313,9 +313,14 @@ > int balance = 0; > int length = parametersSource.length; > int start = 0; >+ boolean listTagBegin = false; > while(index < length) { > switch (parametersSource[index]) { > case '<': >+ if(CharOperation.indexOf("li".toCharArray(), parametersSource, false, index) != -1 //$NON-NLS-1$ >+ || CharOperation.indexOf("/li".toCharArray(), parametersSource, false, index) != -1) { //$NON-NLS-1$ >+ listTagBegin = true; >+ } > balance++; > index++; > while(index < length && parametersSource[index] != '>') { >@@ -325,6 +330,10 @@ > case '>' : > balance--; > index++; >+ if (listTagBegin) { >+ start = index; >+ listTagBegin = false; >+ } > break; > case ',' : > if (balance == 0 && paramIndex < paramCount) { >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.165 >diff -u -r1.165 BinaryType.java >--- model/org/eclipse/jdt/internal/core/BinaryType.java 28 Jul 2009 02:07:34 -0000 1.165 >+++ model/org/eclipse/jdt/internal/core/BinaryType.java 30 Sep 2010 13:50:42 -0000 >@@ -1035,7 +1035,20 @@ > 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); >+ JavadocContents javadocContents = null; >+ if (contents != null ) { >+ int indexOfDoctype = CharOperation.indexOf(JavadocConstants.DOCTYPE_PREFIX, contents.toCharArray(), false); >+ if (indexOfDoctype != -1) { >+ int lastIndexOfDoctype = indexOfDoctype + JavadocConstants.DOCTYPE_PREFIX_LENGTH; >+ if (CharOperation.indexOf("XHTML".toCharArray(), contents.toCharArray(), false, lastIndexOfDoctype) != -1) { //$NON-NLS-1$ >+ javadocContents = new JavadocContentsXHTML(this, contents); >+ } else { >+ javadocContents = new JavadocContents(this, contents); >+ } >+ } >+ } >+ if (javadocContents == null) >+ javadocContents = new JavadocContents(this, contents); > synchronized (projectInfo.javadocCache) { > projectInfo.javadocCache.put(this, javadocContents); > } >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.10 >diff -u -r1.10 JavadocConstants.java >--- model/org/eclipse/jdt/internal/core/JavadocConstants.java 11 Nov 2009 15:27:17 -0000 1.10 >+++ model/org/eclipse/jdt/internal/core/JavadocConstants.java 30 Sep 2010 13:50:42 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2009 IBM Corporation and others. >+ * Copyright (c) 2005, 2010 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 >@@ -34,4 +34,8 @@ > char[] SEPARATOR_START = "<!-- =".toCharArray(); //$NON-NLS-1$ > char[] START_OF_CLASS_DATA = "<!-- ======== START OF CLASS DATA ======== -->".toCharArray(); //$NON-NLS-1$ > int START_OF_CLASS_DATA_LENGTH = JavadocConstants.START_OF_CLASS_DATA.length; >+ char[] DOCTYPE_PREFIX = "!DOCTYPE HTML PUBLIC".toCharArray(); //$NON-NLS-1$ >+ int DOCTYPE_PREFIX_LENGTH = JavadocConstants.DOCTYPE_PREFIX.length; >+ int HTMLDOCTYPE = 0; >+ int XHTMLDOCTYPE = 1; > } >Index: model/org/eclipse/jdt/internal/core/JavadocConstantsXHTML.java >=================================================================== >RCS file: model/org/eclipse/jdt/internal/core/JavadocConstantsXHTML.java >diff -N model/org/eclipse/jdt/internal/core/JavadocConstantsXHTML.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ model/org/eclipse/jdt/internal/core/JavadocConstantsXHTML.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,47 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 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; >+ >+public interface JavadocConstantsXHTML { >+ >+ String ANCHOR_PREFIX_END = "\""; //$NON-NLS-1$ >+ char[] ANCHOR_PREFIX_START = "<A NAME=\"".toCharArray(); //$NON-NLS-1$ >+ int ANCHOR_PREFIX_START_LENGHT = ANCHOR_PREFIX_START.length; >+ char[] ANCHOR_SUFFIX = "</A>".toCharArray(); //$NON-NLS-1$ >+ int ANCHOR_SUFFIX_LENGTH = JavadocConstants.ANCHOR_SUFFIX.length; >+ char[] CONSTRUCTOR_DETAIL = "<!-- ========== CONSTRUCTOR DETAIL ========== -->".toCharArray(); //$NON-NLS-1$ >+ char[] CONSTRUCTOR_SUMMARY = "<!-- ========== CONSTRUCTOR SUMMARY ========== -->".toCharArray(); //$NON-NLS-1$ >+ char[] FIELD_DETAIL= "<!-- ========== FIELD DETAIL ========== -->".toCharArray(); //$NON-NLS-1$ >+ char[] FIELD_SUMMARY = "<!-- ========== FIELD SUMMARY ========== -->".toCharArray(); //$NON-NLS-1$ >+ char[] ENUM_CONSTANT_SUMMARY = "<!-- ========== ENUM CONSTANT SUMMARY ========== -->".toCharArray(); //$NON-NLS-1$ >+ char[] ANNOTATION_TYPE_REQUIRED_MEMBER_SUMMARY = "<!-- ========== ANNOTATION TYPE REQUIRED MEMBER SUMMARY ========== -->".toCharArray(); //$NON-NLS-1$ >+ char[] ANNOTATION_TYPE_OPTIONAL_MEMBER_SUMMARY = "<!-- ========== ANNOTATION TYPE OPTIONAL MEMBER SUMMARY ========== -->".toCharArray(); //$NON-NLS-1$ >+ char[] END_OF_CLASS_DATA = "<!-- ========== END OF CLASS DATA ========== -->".toCharArray(); //$NON-NLS-1$ >+ String HTML_EXTENSION = ".html"; //$NON-NLS-1$ >+ String INDEX_FILE_NAME = "index.html"; //$NON-NLS-1$ >+ char[] METHOD_DETAIL = "<!-- ========== METHOD DETAIL ========== -->".toCharArray(); //$NON-NLS-1$ >+ char[] METHOD_SUMMARY = "<!-- ========== METHOD SUMMARY ========== -->".toCharArray(); //$NON-NLS-1$ >+ char[] NESTED_CLASS_SUMMARY = "<!-- ========== NESTED CLASS SUMMARY ========== -->".toCharArray(); //$NON-NLS-1$ >+ String PACKAGE_FILE_NAME = "package-summary.html"; //$NON-NLS-1$ >+ char[] SEPARATOR_START = "<!-- =".toCharArray(); //$NON-NLS-1$ >+ char[] START_OF_CLASS_DATA = "<!-- ========== START OF CLASS DATA ========== -->".toCharArray(); //$NON-NLS-1$ >+ int START_OF_CLASS_DATA_LENGTH = JavadocConstants.START_OF_CLASS_DATA.length; >+ char[] DOCTYPE_PREFIX = "!DOCTYPE HTML PUBLIC".toCharArray(); //$NON-NLS-1$ >+ int DOCTYPE_PREFIX_LENGTH = JavadocConstants.DOCTYPE_PREFIX.length; >+ char[] ID_TAG_PREFIX = "<h3 id=\"".toCharArray(); //$NON-NLS-1$ >+ int ID_TAG_PREFIX_LENGTH = ID_TAG_PREFIX.length; >+ char[] ID_TAG_SUFFIX = ">".toCharArray(); //$NON-NLS-1$ >+ int ID_TAG_SUFFIX_LENGTH = ID_TAG_SUFFIX.length; >+ char[] XHTML_HEADER_TAG = "<h3>".toCharArray(); //$NON-NLS-1$ >+ char[] XHTML_ORDERED_LIST_END = "</ol>".toCharArray(); //$NON-NLS-1$ >+ int XHTML_ORDERED_LIST_END_LENGTH = XHTML_ORDERED_LIST_END.length; >+ >+} >Index: model/org/eclipse/jdt/internal/core/JavadocContents.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavadocContents.java,v >retrieving revision 1.3 >diff -u -r1.3 JavadocContents.java >--- model/org/eclipse/jdt/internal/core/JavadocContents.java 9 Aug 2010 09:43:40 -0000 1.3 >+++ model/org/eclipse/jdt/internal/core/JavadocContents.java 30 Sep 2010 13:50:45 -0000 >@@ -24,39 +24,39 @@ > import org.eclipse.jdt.internal.core.util.Util; > > public class JavadocContents { >- private static final int[] UNKNOWN_FORMAT = new int[0]; >+ protected static final int[] UNKNOWN_FORMAT = new int[0]; > >- private BinaryType type; >- private char[] content; >+ protected BinaryType type; >+ protected char[] content; > >- private int childrenStart; >+ protected int childrenStart; > >- private boolean hasComputedChildrenSections = false; >- private int indexOfFieldDetails; >- private int indexOfConstructorDetails; >- private int indexOfMethodDetails; >- private int indexOfEndOfClassData; >- >- private int indexOfFieldsBottom; >- 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; >+ protected boolean hasComputedChildrenSections = false; >+ protected int indexOfFieldDetails; >+ protected int indexOfConstructorDetails; >+ protected int indexOfMethodDetails; >+ protected int indexOfEndOfClassData; >+ >+ protected int indexOfFieldsBottom; >+ protected int indexOfAllMethodsTop; >+ protected int indexOfAllMethodsBottom; >+ >+ protected int[] typeDocRange; >+ protected HashtableOfObjectToIntArray fieldDocRanges; >+ protected HashtableOfObjectToIntArray methodDocRanges; >+ >+ protected int[] fieldAnchorIndexes; >+ protected int fieldAnchorIndexesCount; >+ protected int fieldLastAnchorFoundIndex; >+ protected int[] methodAnchorIndexes; >+ protected int methodAnchorIndexesCount; >+ protected int methodLastAnchorFoundIndex; >+ protected int[] unknownFormatAnchorIndexes; >+ protected int unknownFormatAnchorIndexesCount; >+ protected int unknownFormatLastAnchorFoundIndex; >+ protected int[] tempAnchorIndexes; >+ protected int tempAnchorIndexesCount; >+ protected int tempLastAnchorFoundIndex; > > public JavadocContents(BinaryType type, String content) { > this.type = type; >@@ -138,7 +138,7 @@ > /* > * Compute the ranges of the parts of the javadoc that describe each method of the type > */ >- private int[] computeChildRange(char[] anchor, int indexOfSectionBottom) throws JavaModelException { >+ protected int[] computeChildRange(char[] anchor, int indexOfSectionBottom) throws JavaModelException { > > // checks each known anchor locations > if (this.tempAnchorIndexesCount > 0) { >@@ -179,7 +179,7 @@ > return null; > } > >- private int[] computeChildRange(int anchorEndStart, char[] anchor, int indexOfBottom) { >+ protected int[] computeChildRange(int anchorEndStart, char[] anchor, int indexOfBottom) { > int[] range = null; > > // try to find the bottom of the section >@@ -205,7 +205,7 @@ > return range; > } > >- private void computeChildrenSections() { >+ protected void computeChildrenSections() { > // try to find the next separator part > int lastIndex = CharOperation.indexOf(JavadocConstants.SEPARATOR_START, this.content, false, this.childrenStart); > lastIndex = lastIndex == -1 ? this.childrenStart : lastIndex; >@@ -244,7 +244,7 @@ > /* > * 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 { >+ protected int[] computeFieldRange(IField field) throws JavaModelException { > if (!this.hasComputedChildrenSections) { > computeChildrenSections(); > } >@@ -296,7 +296,7 @@ > /* > * Compute the ranges of the parts of the javadoc that describe each method of the type > */ >- private int[] computeMethodRange(IMethod method) throws JavaModelException { >+ protected int[] computeMethodRange(IMethod method) throws JavaModelException { > if (!this.hasComputedChildrenSections) { > computeChildrenSections(); > } >@@ -343,7 +343,7 @@ > return range; > } > >- private String computeMethodAnchorPrefixEnd(BinaryMethod method) throws JavaModelException { >+ protected String computeMethodAnchorPrefixEnd(BinaryMethod method) throws JavaModelException { > String typeQualifiedName = null; > if (this.type.isMember()) { > IType currentType = this.type; >@@ -413,7 +413,7 @@ > /* > * Compute the range of the part of the javadoc that describe the type > */ >- private void computeTypeRange() throws JavaModelException { >+ protected void computeTypeRange() throws JavaModelException { > final int indexOfStartOfClassData = CharOperation.indexOf(JavadocConstants.START_OF_CLASS_DATA, this.content, false); > if (indexOfStartOfClassData == -1) { > this.typeDocRange = UNKNOWN_FORMAT; >Index: model/org/eclipse/jdt/internal/core/JavadocContentsXHTML.java >=================================================================== >RCS file: model/org/eclipse/jdt/internal/core/JavadocContentsXHTML.java >diff -N model/org/eclipse/jdt/internal/core/JavadocContentsXHTML.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ model/org/eclipse/jdt/internal/core/JavadocContentsXHTML.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,334 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 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.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 JavadocContentsXHTML extends JavadocContents { >+ >+ public JavadocContentsXHTML(BinaryType type, String content) { >+ super(type, content); >+ } >+ >+ protected int[] computeChildRange(char[] 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 && CharOperation.indexOf(anchor, this.content, false, anchorEndStart) == anchorEndStart) { >+ >+ this.tempAnchorIndexes[i] = -1; >+ >+ return computeChildRange(anchorEndStart, anchor, indexOfSectionBottom); >+ } >+ } >+ } >+ >+ int fromIndex = this.tempLastAnchorFoundIndex; >+ int index; >+ >+ // check each next unknown anchor locations >+ while ((index = CharOperation.indexOf(JavadocConstantsXHTML.ID_TAG_PREFIX, this.content, false, fromIndex)) != -1 && (index < indexOfSectionBottom || indexOfSectionBottom == -1)) { >+ fromIndex = index + 1; >+ >+ int anchorEndStart = index + JavadocConstantsXHTML.ID_TAG_PREFIX_LENGTH; >+ >+ this.tempLastAnchorFoundIndex = anchorEndStart; >+ >+ if (CharOperation.indexOf(anchor, this.content, false, anchorEndStart) == 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; >+ } >+ >+ protected int[] computeChildRange(int anchorEndStart, char[] anchor, int indexOfBottom) { >+ int[] range = null; >+ >+ // try to find the bottom of the section >+ if (indexOfBottom != -1) { >+ // try to find the end of the id tag >+ int indexOfEndLink = CharOperation.indexOf(JavadocConstantsXHTML.ID_TAG_SUFFIX, this.content, false, anchorEndStart + anchor.length); >+ if (indexOfEndLink != -1) { >+ // try to find the next id tag >+ int indexOfNextElement = CharOperation.indexOf(JavadocConstantsXHTML.ID_TAG_PREFIX, this.content, false, indexOfEndLink); >+ >+ int javadocStart = indexOfEndLink + JavadocConstantsXHTML.ID_TAG_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; >+ } >+ >+ protected 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())); >+ } >+ anchor = anchor.replace('(', '_'); >+ anchor = anchor.replace(')', '_'); >+ anchor = anchor.replace(", ", "_"); //$NON-NLS-1$ //$NON-NLS-2$ >+ anchor = anchor.replace("[]", ".."); //$NON-NLS-1$ //$NON-NLS-2$ >+ >+ 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 + JavadocConstantsXHTML.ANCHOR_PREFIX_END; >+ } >+ >+ 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 String.valueOf(CharOperation.concat(JavadocConstantsXHTML.XHTML_HEADER_TAG, CharOperation.subarray(this.content, range[0], range[1]))); >+ } >+ return null; >+ } >+ >+ 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 String.valueOf(CharOperation.concat(JavadocConstantsXHTML.XHTML_HEADER_TAG,CharOperation.subarray(this.content, range[0], range[1]))); >+ } >+ return null; >+ } >+ >+ /* >+ * Compute the range of the part of the javadoc that describe the type >+ */ >+ protected void computeTypeRange() throws JavaModelException { >+ final int indexOfStartOfClassData = CharOperation.indexOf(JavadocConstantsXHTML.START_OF_CLASS_DATA, this.content, false); >+ if (indexOfStartOfClassData == -1) { >+ this.typeDocRange = UNKNOWN_FORMAT; >+ return; >+ } >+ int indexOfNextSeparator = CharOperation.indexOf(JavadocConstantsXHTML.SEPARATOR_START, this.content, false, indexOfStartOfClassData); >+ if (indexOfNextSeparator == -1) { >+ this.typeDocRange = UNKNOWN_FORMAT; >+ return; >+ } >+ int indexOfNextSummary = CharOperation.indexOf(JavadocConstantsXHTML.NESTED_CLASS_SUMMARY, this.content, false, indexOfNextSeparator); >+ if (indexOfNextSummary == -1 && this.type.isEnum()) { >+ // try to find enum constant summary start >+ indexOfNextSummary = CharOperation.indexOf(JavadocConstantsXHTML.ENUM_CONSTANT_SUMMARY, this.content, false, indexOfNextSeparator); >+ } >+ if (indexOfNextSummary == -1 && this.type.isAnnotation()) { >+ // try to find required enum constant summary start >+ indexOfNextSummary = CharOperation.indexOf(JavadocConstantsXHTML.ANNOTATION_TYPE_REQUIRED_MEMBER_SUMMARY, this.content, false, indexOfNextSeparator); >+ if (indexOfNextSummary == -1) { >+ // try to find optional enum constant summary start >+ indexOfNextSummary = CharOperation.indexOf(JavadocConstantsXHTML.ANNOTATION_TYPE_OPTIONAL_MEMBER_SUMMARY, this.content, false, indexOfNextSeparator); >+ } >+ } >+ if (indexOfNextSummary == -1) { >+ // try to find field summary start >+ indexOfNextSummary = CharOperation.indexOf(JavadocConstantsXHTML.FIELD_SUMMARY, this.content, false, indexOfNextSeparator); >+ } >+ if (indexOfNextSummary == -1) { >+ // try to find constructor summary start >+ indexOfNextSummary = CharOperation.indexOf(JavadocConstantsXHTML.CONSTRUCTOR_SUMMARY, this.content, false, indexOfNextSeparator); >+ } >+ if (indexOfNextSummary == -1) { >+ // try to find method summary start >+ indexOfNextSummary = CharOperation.indexOf(JavadocConstantsXHTML.METHOD_SUMMARY, this.content, false, indexOfNextSeparator); >+ } >+ >+ if (indexOfNextSummary == -1) { >+ // we take the end of class data >+ indexOfNextSummary = CharOperation.indexOf(JavadocConstantsXHTML.END_OF_CLASS_DATA, this.content, false, indexOfNextSeparator); >+ } else { >+ // improve performance of computation of children ranges >+ this.childrenStart = indexOfNextSummary + 1; >+ } >+ >+ if (indexOfNextSummary == -1) { >+ this.typeDocRange = UNKNOWN_FORMAT; >+ return; >+ } >+ /* >+ * We take the part between the start of class data and start of next summary, just before the last >+ * <hr /> tag. >+ */ >+ int fromIndex = indexOfStartOfClassData + JavadocConstantsXHTML.START_OF_CLASS_DATA_LENGTH; >+ int end = -1; >+ int index; >+ int startIndex = fromIndex; >+ while ((index = CharOperation.indexOf(JavadocConstantsXHTML.XHTML_ORDERED_LIST_END, this.content, false, startIndex)) != -1 && (index < indexOfNextSummary)) { >+ fromIndex = index; >+ startIndex = index + JavadocConstantsXHTML.XHTML_ORDERED_LIST_END_LENGTH; >+ } >+ // We got the last </ol> tag in the class data section. Now we need to find the <hr/> tag just after this >+ if (fromIndex == indexOfStartOfClassData + JavadocConstantsXHTML.START_OF_CLASS_DATA_LENGTH) { >+ this.typeDocRange = UNKNOWN_FORMAT; >+ return; >+ } >+ fromIndex += JavadocConstantsXHTML.XHTML_ORDERED_LIST_END_LENGTH; >+ int indexOfLastHrTag = CharOperation.indexOf("<hr />".toCharArray(), this.content, false, fromIndex); //$NON-NLS-1$ >+ if (indexOfLastHrTag != -1 && indexOfLastHrTag < indexOfNextSummary) { >+ end = indexOfLastHrTag; >+ } >+ if (end == -1) { >+ this.typeDocRange = UNKNOWN_FORMAT; >+ return; >+ } >+ >+ this.typeDocRange = new int[]{fromIndex, end}; >+ } >+ >+ protected void computeChildrenSections() { >+ // try to find the next separator part >+ int lastIndex = CharOperation.indexOf(JavadocConstantsXHTML.SEPARATOR_START, this.content, false, this.childrenStart); >+ lastIndex = lastIndex == -1 ? this.childrenStart : lastIndex; >+ >+ // try to find field detail start >+ this.indexOfFieldDetails = CharOperation.indexOf(JavadocConstantsXHTML.FIELD_DETAIL, this.content, false, lastIndex); >+ lastIndex = this.indexOfFieldDetails == -1 ? lastIndex : this.indexOfFieldDetails; >+ >+ // try to find constructor detail start >+ this.indexOfConstructorDetails = CharOperation.indexOf(JavadocConstantsXHTML.CONSTRUCTOR_DETAIL, this.content, false, lastIndex); >+ lastIndex = this.indexOfConstructorDetails == -1 ? lastIndex : this.indexOfConstructorDetails; >+ >+ // try to find method detail start >+ this.indexOfMethodDetails = CharOperation.indexOf(JavadocConstantsXHTML.METHOD_DETAIL, this.content, false, lastIndex); >+ lastIndex = this.indexOfMethodDetails == -1 ? lastIndex : this.indexOfMethodDetails; >+ >+ // we take the end of class data >+ this.indexOfEndOfClassData = CharOperation.indexOf(JavadocConstantsXHTML.END_OF_CLASS_DATA, this.content, false, lastIndex); >+ >+ // try to find the field detail end >+ this.indexOfFieldsBottom = >+ this.indexOfConstructorDetails != -1 ? this.indexOfConstructorDetails : >+ this.indexOfMethodDetails != -1 ? this.indexOfMethodDetails: >+ this.indexOfEndOfClassData; >+ >+ this.indexOfAllMethodsTop = >+ this.indexOfConstructorDetails != -1 ? >+ this.indexOfConstructorDetails : >+ this.indexOfMethodDetails; >+ >+ this.indexOfAllMethodsBottom = this.indexOfEndOfClassData; >+ >+ this.hasComputedChildrenSections = true; >+ } >+ >+}
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 314170
:
170398
|
179823
| 179956