/** * 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 String toString() { String s = ""; //$NON-NLS-1$ char[][] qualifiedName; for (int i = 0, l = this.qualifiedNames.length; i < l; i++) if ((qualifiedName = this.qualifiedNames[i]) != null) s += CharOperation.toString(qualifiedName) + "\n"; //$NON-NLS-1$ return s; } }
final char[][] qualified = Arrays.copyOfRange(tokens, 0, i + 1); if (searchPackage(qualified, units) == null) { access = CharOperation.toString(qualified); break;
CtTypeReference<Object> getTypeParameterReference(TypeBinding binding, TypeReference ref) { CtTypeReference<Object> ctRef = getTypeReference(binding); if (ctRef != null && isCorrectTypeReference(ref)) { if (!(ctRef instanceof CtTypeParameterReference)) { CtTypeParameterReference typeParameterRef = this.jdtTreeBuilder.getFactory().Core().createTypeParameterReference(); typeParameterRef.setSimpleName(ctRef.getSimpleName()); typeParameterRef.setDeclaringType(ctRef.getDeclaringType()); typeParameterRef.setPackage(ctRef.getPackage()); ctRef = typeParameterRef; } insertGenericTypesInNoClasspathFromJDTInSpoon(ref, ctRef); return ctRef; } return getTypeParameterReference(CharOperation.toString(ref.getParameterizedTypeName())); }
@Override public String toString() { StringBuffer buffer = new StringBuffer(); for (int i = 0; i < this.size; i++) { buffer.append(CharOperation.toString(this.elements[i])).append("\n"); //$NON-NLS-1$ } return buffer.toString(); } }
public String toString() { StringBuffer buffer = new StringBuffer(); for (int i = 0; i < this.size; i++) { buffer.append(CharOperation.toString(this.elements[i])).append("\n"); //$NON-NLS-1$ } return buffer.toString(); } }
public void packageCollidesWithType(CompilationUnitDeclaration compUnitDecl) { String[] arguments = new String[] {CharOperation.toString(compUnitDecl.currentPackage.tokens)}; this.handle( IProblem.PackageCollidesWithType, arguments, arguments, compUnitDecl.currentPackage.sourceStart, compUnitDecl.currentPackage.sourceEnd); } public void packageIsNotExpectedPackage(CompilationUnitDeclaration compUnitDecl) {
public void conflictingImport(ImportReference importRef) { String[] arguments = new String[] {CharOperation.toString(importRef.tokens)}; this.handleUntagged( IProblem.ConflictingImport, arguments, arguments, importRef.sourceStart, importRef.sourceEnd); } public void constantOutOfRange(Literal literal, TypeBinding literalType) {
public void conflictingImport(ImportReference importRef) { String[] arguments = new String[] {CharOperation.toString(importRef.tokens)}; this.handleUntagged( IProblem.ConflictingImport, arguments, arguments, importRef.sourceStart, importRef.sourceEnd); } public void constantOutOfRange(Literal literal, TypeBinding literalType) {
public void cannotImportPackage(ImportReference importRef) { String[] arguments = new String[] {CharOperation.toString(importRef.tokens)}; this.handleUntagged( IProblem.CannotImportPackage, arguments, arguments, importRef.sourceStart, importRef.sourceEnd); } public void cannotInstantiate(Expression typeRef, TypeBinding type) {
public void duplicateImport(ImportReference importRef) { String[] arguments = new String[] {CharOperation.toString(importRef.tokens)}; this.handleUntagged( IProblem.DuplicateImport, arguments, arguments, importRef.sourceStart, importRef.sourceEnd); }
public void packageCollidesWithType(CompilationUnitDeclaration compUnitDecl) { String[] arguments = new String[] {CharOperation.toString(compUnitDecl.currentPackage.tokens)}; this.handle( IProblem.PackageCollidesWithType, arguments, arguments, compUnitDecl.currentPackage.sourceStart, compUnitDecl.currentPackage.sourceEnd); } public void packageIsNotExpectedPackage(CompilationUnitDeclaration compUnitDecl) {
public void conflictingPackagesFromOtherModules(ImportReference currentPackage, Set<ModuleBinding> declaringModules) { String moduleNames = declaringModules.stream() .map(p -> String.valueOf(p.name())) .sorted() .collect(Collectors.joining(", ")); //$NON-NLS-1$ String[] arguments = new String[] { CharOperation.toString(currentPackage.tokens), moduleNames }; this.handle(IProblem.ConflictingPackageFromOtherModules, arguments, arguments, currentPackage.sourceStart, currentPackage.sourceEnd); } public void incompatibleExceptionInThrowsClause(SourceTypeBinding type, MethodBinding currentMethod, MethodBinding inheritedMethod, ReferenceBinding exceptionType) {
public void illegalVararg(Argument argType, AbstractMethodDeclaration methodDecl) { String[] arguments = new String[] {CharOperation.toString(argType.type.getTypeName()), new String(methodDecl.selector)}; this.handle( IProblem.IllegalVararg, arguments, arguments, argType.sourceStart, argType.sourceEnd); } public void illegalVarargInLambda(Argument argType) {
public void parameterLackingNullableAnnotation(Argument argument, ReferenceBinding declaringClass, char[][] inheritedAnnotationName) { this.handle( IProblem.ParameterLackingNullableAnnotation, new String[] { new String(declaringClass.readableName()), CharOperation.toString(inheritedAnnotationName)}, new String[] { new String(declaringClass.shortReadableName()), new String(inheritedAnnotationName[inheritedAnnotationName.length-1])}, argument.type.sourceStart, argument.type.sourceEnd); } public void parameterLackingNonnullAnnotation(Argument argument, ReferenceBinding declaringClass, char[][] inheritedAnnotationName) {
public String toString() { if (this.hasTypeAnnotations()) return super.annotatedDebugName() + "(unresolved)"; //$NON-NLS-1$ return "Unresolved type " + ((this.compoundName != null) ? CharOperation.toString(this.compoundName) : "UNNAMED"); //$NON-NLS-1$ //$NON-NLS-2$ } }
context.compilationUnitSpoon.setDeclaredPackage(getFactory().Package().getOrCreate(CharOperation.toString(scope.currentPackageName), module)); CtPackageDeclaration packageDeclaration = context.compilationUnitSpoon.getPackageDeclaration(); if (packageDeclaration != null) {
CtTypeReference<T> typeReference; if (qualifiedNameReference.binding instanceof ProblemBinding) { typeReference = jdtTreeBuilder.getFactory().Type().<T>createReference(CharOperation.toString(qualifiedNameReference.tokens)); } else if (qualifiedNameReference.binding instanceof FieldBinding) { final ReferenceBinding declaringClass = ((FieldBinding) qualifiedNameReference.binding).declaringClass;