/** * Checks if the qualified name reference is a problem field binding and have a valid field. * * @param qualifiedNameReference * Reference which should contains a problem field binding. * @return true if the qualified name reference is a valid problem field binding. */ static boolean isValidProblemBindingField(QualifiedNameReference qualifiedNameReference) { return qualifiedNameReference.binding instanceof ProblemFieldBinding && !((FieldBinding) qualifiedNameReference.binding).declaringClass.isAnonymousType() && qualifiedNameReference.tokens.length - 1 == ((FieldBinding) qualifiedNameReference.binding).declaringClass.compoundName.length && CharOperation .equals(CharOperation.subarray(qualifiedNameReference.tokens, 0, qualifiedNameReference.tokens.length - 1), ((FieldBinding) qualifiedNameReference.binding).declaringClass.compoundName); }
int lastSlash = CharOperation.lastIndexOf(File.separatorChar, charName); if (lastSlash != -1) { char[] modulePath = CharOperation.subarray(charName, 0, lastSlash); compilationUnit.module = CharOperation.subarray(modulePath, lastSlash, modulePath.length); pathToModName.put(String.valueOf(modulePath), compilationUnit.module);
public char[][] getPackageName() { int length = this.compoundName.length; if (length <= 1) return CharOperation.NO_CHAR_CHAR; return CharOperation.subarray(this.compoundName, 0, length - 1); } /*
public char[][] getPackageName() { int length = this.compoundName.length; if (length <= 1) return CharOperation.NO_CHAR_CHAR; return CharOperation.subarray(this.compoundName, 0, length - 1); } /*
/** * In no classpath mode, when we build a field access, we have a binding typed by ProblemBinding. * We try to get all information we can get from this binding. * * @param qualifiedNameReference * Used to get the problem binding of the field access and the name of the declaring type. * @return a field access. */ <T> CtFieldAccess<T> createFieldAccessNoClasspath(QualifiedNameReference qualifiedNameReference) { boolean fromAssignment = isLhsAssignment(jdtTreeBuilder.getContextBuilder(), qualifiedNameReference); CtFieldAccess<T> fieldAccess = createFieldAccess(jdtTreeBuilder.getReferencesBuilder().<T>getVariableReference((ProblemBinding) qualifiedNameReference.binding), null, fromAssignment); // In no classpath mode and with qualified name, the type given by JDT is wrong... final char[][] declaringClass = CharOperation.subarray(qualifiedNameReference.tokens, 0, qualifiedNameReference.tokens.length - 1); final MissingTypeBinding declaringType = jdtTreeBuilder.getContextBuilder().compilationunitdeclaration.scope.environment.createMissingType(null, declaringClass); final CtTypeReference<T> declaringRef = jdtTreeBuilder.getReferencesBuilder().getTypeReference(declaringType); fieldAccess.getVariable().setDeclaringType(declaringRef); fieldAccess.getVariable().setStatic(true); fieldAccess.setTarget(jdtTreeBuilder.getFactory().Code().createTypeAccess(declaringRef)); // In no classpath mode and with qualified name, the binding doesn't have a good name. fieldAccess.getVariable() .setSimpleName(createQualifiedTypeName(CharOperation.subarray(qualifiedNameReference.tokens, qualifiedNameReference.tokens.length - 1, qualifiedNameReference.tokens.length))); return fieldAccess; }
char[][] packageName = CharOperation.subarray(anImport.getImportName(), 0, anImport.getImportName().length - indexDeclaring); char[][] className = CharOperation.subarray(anImport.getImportName(), anImport.getImportName().length - indexDeclaring, anImport.getImportName().length - (indexDeclaring - 1)); PackageBinding aPackage; try { char[][] chars = CharOperation.subarray(anImport.getImportName(), 0, anImport.getImportName().length - 1);
private char[] erasure(char[] typeName) { int genericStart = CharOperation.indexOf(Signature.C_GENERIC_START, typeName); if (genericStart > -1) typeName = CharOperation.subarray(typeName, 0, genericStart); return typeName; } public void addConstructorDeclaration(
public void consumeLocalType(char[] uniqueKey) { this.signature = new StringBuffer(); // remove trailing semi-colon as it is added later in comsumeType() uniqueKey = CharOperation.subarray(uniqueKey, 0, uniqueKey.length-1); if (!this.asBinarySignature) CharOperation.replace(uniqueKey, '/', '.'); this.signature.append(uniqueKey); }
/** * assuming a previously stored start of 's' followed by a call to computeEnd() * now retrieve the content between these bounds including trailing angle content */ public char[] getFrom(int s) { if (this.end == this.bracket) { this.end = skipAngleContents(this.bracket); this.start = this.end + 1; } return CharOperation.subarray(this.signature, s, this.end+1); } public char[] tail() {
/** * Returns the souce code to be used for this * field's type. */ protected char[] getTypeContents() { if (isTypeAltered()) { return this.fType.toCharArray(); } else { return CharOperation.subarray(this.fDocument, this.fTypeRange[0], this.fTypeRange[1] + 1); } } /**
public void consumeLocalType(char[] uniqueKey) { this.signature = new StringBuffer(); // remove trailing semi-colon as it is added later in comsumeType() uniqueKey = CharOperation.subarray(uniqueKey, 0, uniqueKey.length-1); CharOperation.replace(uniqueKey, '/', '.'); this.signature.append(uniqueKey); }
@Override public String getQualifier() { char[][] importName = m_astNode.tokens; char[][] qualifier = CharOperation.subarray(importName, 0, importName.length - 1); return CharOperation.toString(qualifier); }
private char[] getReturnType(char[] methodSignature) { // skip type parameters int paren = CharOperation.lastIndexOf(')', methodSignature); // there could be thrown exceptions behind, thus scan one type exactly return CharOperation.subarray(methodSignature, paren + 1, methodSignature.length); }
/** * Returns the souce code to be used for this * field's type. */ protected char[] getTypeContents() { if (isTypeAltered()) { return this.fType.toCharArray(); } else { return CharOperation.subarray(this.fDocument, this.fTypeRange[0], this.fTypeRange[1] + 1); } } /**
} else { char[][] packageName = CharOperation.subarray(qualifiedNameReference.tokens, 0, qualifiedNameReference.tokens.length - 1); char[][] className = CharOperation.subarray(qualifiedNameReference.tokens, qualifiedNameReference.tokens.length - 1, qualifiedNameReference.tokens.length); if (packageName.length > 0) { try {
@Override protected void initRawPackageInfo(HashtableOfArrayToObject rawPackageInfo, String entryName, boolean isDirectory, String compliance) { char[] name = entryName.toCharArray(); if (CharOperation.prefixEquals(ClasspathJMod.CLASSES_FOLDER, name)) { name = CharOperation.subarray(name, ClasspathJMod.CLASSES_FOLDER.length, name.length); } super.initRawPackageInfo(rawPackageInfo, new String(name), isDirectory, compliance); } }
/** answer the next type (incl. type arguments), but don't advance any cursors */ public char[] peekFullType() { int s = this.start, b = this.bracket, e = this.end; int peekEnd = skipAngleContents(computeEnd()); this.start = s; this.bracket = b; this.end = e; return CharOperation.subarray(this.signature, s, peekEnd+1); }
private char[] returnClassName(char[] classInfoName, char separator, int mode) { if (classInfoName.length == 0) { return CharOperation.NO_CHAR; } else if (isCompact(mode)) { int lastIndexOfSlash = CharOperation.lastIndexOf(separator, classInfoName); if (lastIndexOfSlash != -1) { return CharOperation.subarray(classInfoName, lastIndexOfSlash + 1, classInfoName.length); } } return classInfoName; }
public char[] nextWord() { this.end = CharOperation.indexOf(';', this.signature, this.start); if (this.bracket <= this.start) // already know it if its > start this.bracket = CharOperation.indexOf('<', this.signature, this.start); int dot = CharOperation.indexOf('.', this.signature, this.start); if (this.bracket > this.start && this.bracket < this.end) this.end = this.bracket; if (dot > this.start && dot < this.end) this.end = dot; return CharOperation.subarray(this.signature, this.start, this.start = this.end); // skip word } /** similar to nextWord() but don't stop at '.' */
public char[] nextWord() { this.end = CharOperation.indexOf(';', this.signature, this.start); if (this.bracket <= this.start) // already know it if its > start this.bracket = CharOperation.indexOf('<', this.signature, this.start); int dot = CharOperation.indexOf('.', this.signature, this.start); if (this.bracket > this.start && this.bracket < this.end) this.end = this.bracket; if (dot > this.start && dot < this.end) this.end = dot; return CharOperation.subarray(this.signature, this.start, this.start = this.end); // skip word } public String toString() {