@Override public boolean onAccess(char[][] tokens, int index) { return !CharOperation.equals(tokens[index + 1], tokens[tokens.length - 1]); } });
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); }
/** * 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); }
for (CompilationUnit compilationUnit : this.compilationUnits) { char[] charName = compilationUnit.getFileName(); boolean isModuleInfo = CharOperation.endsWith(charName, TypeConstants.MODULE_INFO_FILE_NAME); if (isModuleInfo == (round == 0)) { // 1st round: modules, 2nd round others (to ensure populating pathToModCU well in time) int lastSlash = CharOperation.lastIndexOf(File.separatorChar, charName); if (lastSlash != -1) { char[] modulePath = CharOperation.subarray(charName, 0, lastSlash); lastSlash = CharOperation.lastIndexOf(File.separatorChar, modulePath); if (lastSlash == -1) { lastSlash = 0; compilationUnit.module = CharOperation.subarray(modulePath, lastSlash, modulePath.length); pathToModName.put(String.valueOf(modulePath), compilationUnit.module);
/** * Searches a type declared in imports. * * @param typeName * Expected type name. * @param imports * Search the type in imports. * @return qualified name of the expected type. */ static String searchType(String typeName, ImportReference[] imports) { if (typeName == null || imports == null) { return null; } for (ImportReference anImport : imports) { final String importType = CharOperation.charToString(anImport.getImportName()[anImport.getImportName().length - 1]); if (typeName.equals(importType)) { return CharOperation.toString(anImport.getImportName()); } } return null; }
public char[] normalizedPath() { if (this.normalizedPath == null) { String path2 = this.getPath(); char[] rawName = path2.toCharArray(); if (File.separatorChar == '\\') { CharOperation.replace(rawName, '\\', '/'); } this.normalizedPath = CharOperation.subarray(rawName, 0, CharOperation.lastIndexOf('.', rawName)); } return this.normalizedPath; } public String getPath() {
public void acceptType( char[] packageName, char[] typeName, char[][] enclosingTypeNames, int modifiers, AccessRestriction accessRestriction) { char[] fullyQualifiedName = CharOperation.concat(packageName, CharOperation.concat(CharOperation.concatWith(enclosingTypeNames, '.'), typeName, '.'), '.'); if (isQualified && !CharOperation.endsWith(fullyQualifiedName, missingFullyQualifiedName)) return; char[][] compoundName = CharOperation.splitOn('.', fullyQualifiedName); results.add(compoundName); }
@Override public void consumePackage(char[] pkgName) { this.compoundName = CharOperation.splitOn('/', pkgName); this.compilerBinding = new PackageBinding(this.compoundName, null, this.environment, this.environment.module); //TODO(SHMOD) enclosingModule }
public SelectionOnQualifiedNameReference(char[][] previousIdentifiers, char[] selectionIdentifier, long[] positions) { super( CharOperation.arrayConcat(previousIdentifiers, selectionIdentifier), positions, (int) (positions[0] >>> 32), (int) positions[positions.length - 1]); } public StringBuffer printExpression(int indent, StringBuffer output) {
public PackageVisibilityStatement(ImportReference pkgRef, ModuleReference[] targets) { this.pkgRef = pkgRef; this.pkgName = CharOperation.concatWith(this.pkgRef.tokens, '.'); this.targets = targets; } public boolean isQualified() {
private void acceptName(char[] name) { // the null check is added to fix bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=166570 if (name == null) return; if (!CharOperation.prefixEquals(this.completionEngine.completionToken, name, false /* ignore case */) && !(this.completionEngine.options.camelCaseMatch && CharOperation.camelCaseMatch(this.completionEngine.completionToken, name))) return; if (this.acceptedNames.includes(name)) return; this.acceptedNames.add(name); // accept result this.requestor.acceptName(name); }
protected void addTypeName(final ArrayList answers, String fileName, int last, char[] packageName) { int indexOfDot = fileName.lastIndexOf('.'); if (indexOfDot != -1) { String typeName = fileName.substring(last + 1, indexOfDot); answers.add( CharOperation.arrayConcat( CharOperation.splitOn('/', packageName), typeName.toCharArray())); } } @Override
private AccessRestriction getViolatedRestriction(String typeName, String packageName, ClasspathEntry entry, AccessRestriction accessRestriction) { AccessRuleSet accessRuleSet = entry.getAccessRuleSet(); if (accessRuleSet != null) { // TODO (philippe) improve char[] <-> String conversions to avoid performing them on the fly char[][] packageChars = CharOperation.splitOn('.', packageName.toCharArray()); char[] typeChars = typeName.toCharArray(); accessRestriction = accessRuleSet.getViolatedRestriction(CharOperation.concatWith(packageChars, typeChars, '/')); } return accessRestriction; }
private String returnClassName(char[] classInfoName) { if (classInfoName.length == 0) { return EMPTY_CLASS_NAME; } else if (isCompact()) { int lastIndexOfSlash = CharOperation.lastIndexOf('/', classInfoName); if (lastIndexOfSlash != -1) { return new String(classInfoName, lastIndexOfSlash + 1, classInfoName.length - lastIndexOfSlash - 1); } } CharOperation.replace(classInfoName, '/', '.'); return new String(classInfoName); }
public char[] readableName() { if (this.onDemand) return CharOperation.concat(CharOperation.concatWith(this.compoundName, '.'), ".*".toCharArray()); //$NON-NLS-1$ else return CharOperation.concatWith(this.compoundName, '.'); } public String toString() {
@Override public Name getQualifiedName() { ReferenceBinding binding = (ReferenceBinding)_binding; char[] qName; if (binding.isMemberType()) { qName = CharOperation.concatWith(binding.enclosingType().compoundName, binding.sourceName, '.'); CharOperation.replace(qName, '$', '.'); } else { qName = CharOperation.concatWith(binding.compoundName, '.'); } return new NameImpl(qName); }
public final static boolean isExcluded(IPath resourcePath, char[][] exclusionPatterns) { if (exclusionPatterns == null) return false; char[] path = resourcePath.toString().toCharArray(); for (int i = 0, length = exclusionPatterns.length; i < length; i++) if (CharOperation.pathMatch(exclusionPatterns[i], path, true, '/')) return true; return false; }