Java Code Examples for org.eclipse.jdt.internal.compiler.lookup.TypeBinding#qualifiedPackageName()

The following examples show how to use org.eclipse.jdt.internal.compiler.lookup.TypeBinding#qualifiedPackageName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PatchDelegate.java    From EasyMPermission with MIT License 6 votes vote down vote up
private static String typeBindingToSignature(TypeBinding binding) {
	binding = binding.erasure();
	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 "";
}
 
Example 2
Source File: PatchExtensionMethod.java    From EasyMPermission with MIT License 6 votes vote down vote up
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);
	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);
	}
}
 
Example 3
Source File: PatchVal.java    From EasyMPermission with MIT License 5 votes vote down vote up
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);
}