List of usage examples for org.eclipse.jdt.core.compiler CharOperation indexOf
public static final int indexOf(char toBeFound, char[] array, int start, int end)
From source file:com.codenvy.ide.ext.java.server.internal.core.JavadocContents.java
License:Open Source License
public String getPackageDoc() throws JavaModelException { if (this.content == null) return null; int[] range = null; int index = CharOperation.indexOf(JavadocConstants.PACKAGE_DESCRIPTION_START, this.content, false, 0); if (index == -1) return null; index = CharOperation.indexOf(JavadocConstants.ANCHOR_SUFFIX, this.content, false, index); if (index == -1) return null; int start = CharOperation.indexOf(JavadocConstants.H2_PREFIX, this.content, false, index); if (start != -1) { start = CharOperation.indexOf(JavadocConstants.H2_SUFFIX, this.content, false, start); if (start != -1) index = start + JavadocConstants.H2_SUFFIX_LENGTH; }// w w w.j a v a 2 s .c o m if (index != -1) { int end = CharOperation.indexOf(JavadocConstants.BOTTOM_NAVBAR, this.content, false, index); if (end == -1) end = this.content.length - 1; range = new int[] { index, end }; return String.valueOf(CharOperation.subarray(this.content, range[0], range[1])); } return null; }
From source file:com.codenvy.ide.ext.java.server.internal.core.JavadocContents.java
License:Open Source License
private 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.prefixEquals(anchor, this.content, false, anchorEndStart)) { this.tempAnchorIndexes[i] = -1; return computeChildRange(anchorEndStart, anchor, indexOfSectionBottom); }//w w w .j av a2s . c o m } } int fromIndex = this.tempLastAnchorFoundIndex; int index; // check each next unknown anchor locations while ((index = CharOperation.indexOf(JavadocConstants.ANCHOR_PREFIX_START, this.content, false, fromIndex)) != -1 && (index < indexOfSectionBottom || indexOfSectionBottom == -1)) { fromIndex = index + 1; int anchorEndStart = index + JavadocConstants.ANCHOR_PREFIX_START_LENGHT; this.tempLastAnchorFoundIndex = anchorEndStart; if (CharOperation.prefixEquals(anchor, this.content, false, 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; }
From source file:com.codenvy.ide.ext.java.server.internal.core.JavadocContents.java
License:Open Source License
private 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 anchor int indexOfEndLink = CharOperation.indexOf(JavadocConstants.ANCHOR_SUFFIX, this.content, false, anchorEndStart + anchor.length); if (indexOfEndLink != -1) { // try to find the next anchor int indexOfNextElement = CharOperation.indexOf(JavadocConstants.ANCHOR_PREFIX_START, this.content, false, indexOfEndLink); int javadocStart = indexOfEndLink + JavadocConstants.ANCHOR_SUFFIX_LENGTH; int javadocEnd = indexOfNextElement == -1 ? indexOfBottom : Math.min(indexOfNextElement, indexOfBottom); range = new int[] { javadocStart, javadocEnd }; } else {/*from w w w .j a v a 2 s. c o m*/ // the anchor has no suffix range = UNKNOWN_FORMAT; } } else { // the detail section has no bottom range = UNKNOWN_FORMAT; } return range; }
From source file:com.codenvy.ide.ext.java.server.internal.core.JavadocContents.java
License:Open Source License
private 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; // try to find field detail start this.indexOfFieldDetails = CharOperation.indexOf(JavadocConstants.FIELD_DETAIL, this.content, false, lastIndex);//w ww. j a v a2 s. com lastIndex = this.indexOfFieldDetails == -1 ? lastIndex : this.indexOfFieldDetails; // try to find constructor detail start this.indexOfConstructorDetails = CharOperation.indexOf(JavadocConstants.CONSTRUCTOR_DETAIL, this.content, false, lastIndex); lastIndex = this.indexOfConstructorDetails == -1 ? lastIndex : this.indexOfConstructorDetails; // try to find method detail start this.indexOfMethodDetails = CharOperation.indexOf(JavadocConstants.METHOD_DETAIL, this.content, false, lastIndex); lastIndex = this.indexOfMethodDetails == -1 ? lastIndex : this.indexOfMethodDetails; // we take the end of class data this.indexOfEndOfClassData = CharOperation.indexOf(JavadocConstants.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; }
From source file:org.eclipse.objectteams.otdt.core.compiler.OTNameUtils.java
License:Open Source License
/** Remove all occurrences of '__OT__' from a given type name. */ public static char[] removeOTDelim(char[] typeName) { if (!CharOperation.contains(OT_DELIM_NAME, typeName)) return typeName; char[] strippedName = new char[0]; int start = 0; int pos = CharOperation.indexOf(OT_DELIM_NAME, typeName, true, start); while (pos > -1) { strippedName = CharOperation.concat(strippedName, CharOperation.subarray(typeName, start, pos)); start = pos;/* w ww.j a v a2s . co m*/ pos = CharOperation.indexOf(OT_DELIM_NAME, typeName, true, start + 1); } strippedName = CharOperation.concat(strippedName, CharOperation.subarray(typeName, start + OT_DELIM_LEN, -1)); return strippedName; }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.lookup.SyntheticRoleBridgeMethodBinding.java
License:Open Source License
public static boolean isPrivateBridgeSelector(char[] selector) { if (!CharOperation.prefixEquals(IOTConstants.OT_DOLLAR_NAME, selector)) return false; return CharOperation.indexOf(PRIVATE, selector, true, IOTConstants.OT_DOLLAR_LEN) > -1; }
From source file:org.eclipse.swt.tools.builders.Check64CompilationParticipant.java
License:Open Source License
boolean replace(char[] source, char[] src, char[] dest) { boolean changed = false; int start = 0; while (start < source.length) { int index = CharOperation.indexOf(src, source, true, start); if (index == -1) break; changed |= true;// w w w .j a v a2 s . c o m System.arraycopy(dest, 0, source, index, dest.length); start = index + 1; } return changed; }
From source file:org.eclipse.tycho.compiler.jdt.JDTCompiler.java
License:Open Source License
/** * check the compiler arguments. Extract from files specified using @, lines marked with * ADAPTER_PREFIX These lines specify information that needs to be interpreted by us. * //from w w w. j ava 2 s . c o m * @param args * compiler arguments to process */ private void checkCompilerArgs(Map<String, String> args) { for (String arg : args.keySet()) { if (arg.charAt(0) == '@') { try { char[] content = Util.getFileCharContent(new File(arg.substring(1)), null); int offset = 0; int prefixLength = ADAPTER_PREFIX.length; while ((offset = CharOperation.indexOf(ADAPTER_PREFIX, content, true, offset)) > -1) { int start = offset + prefixLength; int end = CharOperation.indexOf('\n', content, start); if (end == -1) end = content.length; while (CharOperation.isWhitespace(content[end])) { end--; } // end is inclusive, but in the API end is exclusive if (CharOperation.equals(ADAPTER_ENCODING, content, start, start + ADAPTER_ENCODING.length)) { CharOperation.replace(content, SEPARATOR_CHARS, File.separatorChar, start, end + 1); // file or folder level custom encoding start += ADAPTER_ENCODING.length; int encodeStart = CharOperation.lastIndexOf('[', content, start, end); if (start < encodeStart && encodeStart < end) { boolean isFile = CharOperation.equals(SuffixConstants.SUFFIX_java, content, encodeStart - 5, encodeStart, false); String str = String.valueOf(content, start, encodeStart - start); String enc = String.valueOf(content, encodeStart, end - encodeStart + 1); if (isFile) { if (fileEncodings == null) fileEncodings = new HashMap<String, String>(); // use File to translate the string into a // path with the correct File.seperator fileEncodings.put(str, enc); } else { if (dirEncodings == null) dirEncodings = new HashMap<String, String>(); dirEncodings.put(str, enc); } } } else if (CharOperation.equals(ADAPTER_ACCESS, content, start, start + ADAPTER_ACCESS.length)) { // access rules for the classpath start += ADAPTER_ACCESS.length; int accessStart = CharOperation.indexOf('[', content, start, end); // CharOperation.replace(content, SEPARATOR_CHARS, // File.separatorChar, start, accessStart); if (start < accessStart && accessStart < end) { String path = String.valueOf(content, start, accessStart - start); String access = String.valueOf(content, accessStart, end - accessStart + 1); if (accessRules == null) accessRules = new ArrayList<String>(); accessRules.add(path); accessRules.add(access); } } offset = end; } } catch (IOException e) { // ignore } } } }