List of usage examples for org.eclipse.jdt.internal.compiler.lookup TypeBinding qualifiedSourceName
public abstract char[] qualifiedSourceName();
From source file:com.codenvy.ide.ext.java.server.internal.core.search.matching.PatternLocator.java
License:Open Source License
public static char[] qualifiedSourceName(TypeBinding binding) { if (binding instanceof ReferenceBinding) { ReferenceBinding type = (ReferenceBinding) binding; if (type.isLocalType()) return type.isMemberType() ? CharOperation.concat(qualifiedSourceName(type.enclosingType()), type.sourceName(), '.') : CharOperation.concat(qualifiedSourceName(type.enclosingType()), new char[] { '.', '1', '.' }, type.sourceName()); }// w w w. j a v a 2 s .c o m return binding != null ? binding.qualifiedSourceName() : null; }
From source file:com.codenvy.ide.ext.java.server.internal.core.search.matching.PatternLocator.java
License:Open Source License
protected char[] getQualifiedSourceName(TypeBinding binding) { TypeBinding type = binding instanceof ArrayBinding ? ((ArrayBinding) binding).leafComponentType : binding; if (type instanceof ReferenceBinding) { if (type.isLocalType()) { return CharOperation.concat(qualifiedSourceName(type.enclosingType()), new char[] { '.', '1', '.' }, binding.sourceName()); } else if (type.isMemberType()) { return CharOperation.concat(qualifiedSourceName(type.enclosingType()), binding.sourceName(), '.'); }/*from w ww . j a va 2s. com*/ } return binding != null ? binding.qualifiedSourceName() : null; }
From source file:com.google.gwt.dev.javac.JdtUtil.java
License:Apache License
public static String getSourceName(TypeBinding classBinding) { return Joiner.on(".").skipNulls() .join(new String[] { Strings.emptyToNull(CharOperation.charToString(classBinding.qualifiedPackageName())), CharOperation.charToString(classBinding.qualifiedSourceName()) }); }
From source file:com.redhat.ceylon.eclipse.core.model.loader.JDTUtils.java
License:Open Source License
public static String getFullyQualifiedName(TypeBinding type) { StringBuilder builder = new StringBuilder(); char[] packageName = type.qualifiedPackageName(); if (packageName != CharOperation.NO_CHAR) { builder.append(packageName).append('.'); }//from ww w . j a va 2 s . c om return builder.append(type.qualifiedSourceName()).toString(); }
From source file:com.redhat.ceylon.eclipse.core.model.mirror.UnknownTypeMirror.java
License:Open Source License
public JDTType(TypeBinding type, IdentityHashMap<TypeBinding, JDTType> originatingTypes) { originatingTypes.put(type, this); // type params are not qualified if (type instanceof TypeVariableBinding) qualifiedName = new String(type.qualifiedSourceName()); else/*w w w .ja v a 2 s .c om*/ qualifiedName = JDTUtils.getFullyQualifiedName(type); typeKind = findKind(type); isPrimitive = type.isBaseType() && type.id != TypeIds.T_void && type.id != TypeIds.T_null; isRaw = type.isRawType(); if (type instanceof ParameterizedTypeBinding && !(type instanceof RawTypeBinding)) { TypeBinding[] javaTypeArguments = ((ParameterizedTypeBinding) type).arguments; if (javaTypeArguments == null) { javaTypeArguments = new TypeBinding[0]; } typeArguments = new ArrayList<TypeMirror>(javaTypeArguments.length); for (TypeBinding typeArgument : javaTypeArguments) typeArguments.add(toTypeMirror(typeArgument, type, this, originatingTypes)); } else { typeArguments = Collections.emptyList(); } if (type instanceof ArrayBinding) { TypeBinding jdtComponentType = ((ArrayBinding) type).elementsType(); componentType = toTypeMirror(jdtComponentType, type, this, originatingTypes); } else { componentType = null; } if (type.isWildcard()) { WildcardBinding wildcardBinding = (WildcardBinding) type; if (wildcardBinding.boundKind == Wildcard.EXTENDS) { TypeBinding upperBoundBinding = wildcardBinding.bound; if (upperBoundBinding != null) { upperBound = toTypeMirror(upperBoundBinding, type, this, originatingTypes); } } } else if (type.isTypeVariable()) { TypeVariableBinding typeVariableBinding = (TypeVariableBinding) type; TypeBinding boundBinding = typeVariableBinding.firstBound; // TODO : we should confirm this if (boundBinding != null) { upperBound = toTypeMirror(boundBinding, type, this, originatingTypes); } } else { upperBound = null; } if (type.isWildcard()) { WildcardBinding wildcardBinding = (WildcardBinding) type; if (wildcardBinding.boundKind == Wildcard.SUPER) { TypeBinding lowerBoundBinding = wildcardBinding.bound; if (lowerBoundBinding != null) { lowerBound = toTypeMirror(lowerBoundBinding, type, this, originatingTypes); } } } if (type instanceof ParameterizedTypeBinding || type instanceof SourceTypeBinding || type instanceof BinaryTypeBinding) { ReferenceBinding refBinding = (ReferenceBinding) type; declaredClass = new JDTClass(refBinding, JDTModelLoader.toType(refBinding)); } if (type instanceof TypeVariableBinding) { typeParameter = new JDTTypeParameter((TypeVariableBinding) type, this, originatingTypes); } }
From source file:lombok.eclipse.agent.ExtensionMethodCompletionProposal.java
License:Open Source License
public void setMethodBinding(final MethodBinding method, final ASTNode node) { MethodBinding original = method.original(); TypeBinding[] parameters = Arrays.copyOf(method.parameters, method.parameters.length); method.parameters = Arrays.copyOfRange(method.parameters, 1, method.parameters.length); TypeBinding[] originalParameters = null; if (original != method) { originalParameters = Arrays.copyOf(method.original().parameters, method.original().parameters.length); method.original().parameters = Arrays.copyOfRange(method.original().parameters, 1, method.original().parameters.length); }// w w w . j a va2 s .co m int length = method.parameters == null ? 0 : method.parameters.length; char[][] parameterPackageNames = new char[length][]; char[][] parameterTypeNames = new char[length][]; for (int i = 0; i < length; i++) { TypeBinding type = method.original().parameters[i]; parameterPackageNames[i] = type.qualifiedPackageName(); parameterTypeNames[i] = type.qualifiedSourceName(); } char[] completion = CharOperation.concat(method.selector, new char[] { '(', ')' }); setDeclarationSignature(CompletionEngine.getSignature(method.declaringClass)); setSignature(CompletionEngine.getSignature(method)); if (original != method) { setOriginalSignature(CompletionEngine.getSignature(original)); } setDeclarationPackageName(method.declaringClass.qualifiedPackageName()); setDeclarationTypeName(method.declaringClass.qualifiedSourceName()); setParameterPackageNames(parameterPackageNames); setParameterTypeNames(parameterTypeNames); setPackageName(method.returnType.qualifiedPackageName()); setTypeName(method.returnType.qualifiedSourceName()); setName(method.selector); setCompletion(completion); setFlags(method.modifiers & (~AccStatic)); int index = node.sourceEnd + 1; if (node instanceof CompletionOnQualifiedNameReference) { index -= ((CompletionOnQualifiedNameReference) node).completionIdentifier.length; } if (node instanceof CompletionOnMemberAccess) { index -= ((CompletionOnMemberAccess) node).token.length; } if (node instanceof CompletionOnSingleNameReference) { index -= ((CompletionOnSingleNameReference) node).token.length; } setReplaceRange(index, index); setTokenRange(index, index); setRelevance(100); method.parameters = parameters; if (original != method) { method.original().parameters = originalParameters; } }
From source file:lombok.eclipse.agent.PatchDelegate.java
License:Open Source License
private static boolean isDelegate(Annotation ann, TypeDeclaration decl) { if (ann.type == null) return false; TypeBinding tb = ann.type.resolveType(decl.initializerScope); if (tb == null) return false; if (!charArrayEquals("lombok", tb.qualifiedPackageName()) && !charArrayEquals("lombok.experimental", tb.qualifiedPackageName())) return false; if (!charArrayEquals("Delegate", tb.qualifiedSourceName())) return false; return true;//from w w w .j a v a 2 s .co m }
From source file:lombok.eclipse.agent.PatchDelegate.java
License:Open Source License
private static String typeBindingToSignature(TypeBinding binding) { binding = binding.erasure();/* ww w . j a v a2s . c o m*/ if (binding != null && binding.isBaseType()) { return new String(binding.sourceName()); } else if (binding instanceof ReferenceBinding) { String pkg = binding.qualifiedPackageName() == null ? "" : new String(binding.qualifiedPackageName()); String qsn = binding.qualifiedSourceName() == null ? "" : new String(binding.qualifiedSourceName()); return pkg.isEmpty() ? qsn : (pkg + "." + qsn); } else if (binding instanceof ArrayBinding) { StringBuilder out = new StringBuilder(); out.append(typeBindingToSignature(binding.leafComponentType())); for (int i = 0; i < binding.dimensions(); i++) out.append("[]"); return out.toString(); } return ""; }
From source file:lombok.eclipse.agent.PatchExtensionMethod.java
License:Open Source License
private static NameReference createNameRef(TypeBinding typeBinding, ASTNode source) { long p = ((long) source.sourceStart << 32) | source.sourceEnd; char[] pkg = typeBinding.qualifiedPackageName(); char[] basename = typeBinding.qualifiedSourceName(); StringBuilder sb = new StringBuilder(); if (pkg != null) sb.append(pkg);//from w ww . j av a 2 s .com if (sb.length() > 0) sb.append("."); sb.append(basename); String tName = sb.toString(); if (tName.indexOf('.') == -1) { return new SingleNameReference(basename, p); } else { char[][] sources; String[] in = tName.split("\\."); sources = new char[in.length][]; for (int i = 0; i < in.length; i++) sources[i] = in[i].toCharArray(); long[] poss = new long[in.length]; Arrays.fill(poss, p); return new QualifiedNameReference(sources, poss, source.sourceStart, source.sourceEnd); } }
From source file:lombok.eclipse.agent.PatchVal.java
License:Open Source License
private static boolean isVal(TypeReference ref, BlockScope scope) { if (!couldBeVal(ref)) return false; TypeBinding resolvedType = ref.resolvedType; if (resolvedType == null) resolvedType = ref.resolveType(scope, false); if (resolvedType == null) return false; char[] pkg = resolvedType.qualifiedPackageName(); char[] nm = resolvedType.qualifiedSourceName(); return matches("lombok", pkg) && matches("val", nm); }