Java Code Examples for org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader#utf8At()

The following examples show how to use org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader#utf8At() . 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: BinaryTypeConverter.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public ImportReference[] buildImports(ClassFileReader reader) {
	// add remaining references to the list of type names
	// (code extracted from BinaryIndexer#extractReferenceFromConstantPool(...))
	int[] constantPoolOffsets = reader.getConstantPoolOffsets();
	int constantPoolCount = constantPoolOffsets.length;
	for (int i = 0; i < constantPoolCount; i++) {
		int tag = reader.u1At(constantPoolOffsets[i]);
		char[] name = null;
		switch (tag) {
			case ClassFileConstants.MethodRefTag :
			case ClassFileConstants.InterfaceMethodRefTag :
				int constantPoolIndex = reader.u2At(constantPoolOffsets[i] + 3);
				int utf8Offset = constantPoolOffsets[reader.u2At(constantPoolOffsets[constantPoolIndex] + 3)];
				name = reader.utf8At(utf8Offset + 3, reader.u2At(utf8Offset + 1));
				break;
			case ClassFileConstants.ClassTag :
				utf8Offset = constantPoolOffsets[reader.u2At(constantPoolOffsets[i] + 1)];
				name = reader.utf8At(utf8Offset + 3, reader.u2At(utf8Offset + 1));
				break;
		}
		if (name == null || (name.length > 0 && name[0] == '['))
			break; // skip over array references
		this.typeNames.add(CharOperation.splitOn('/', name));
	}

	// convert type names into import references
	int typeNamesLength = this.typeNames.size();
	ImportReference[] imports = new ImportReference[typeNamesLength];
	char[][][] set = this.typeNames.set;
	int index = 0;
	for (int i = 0, length = set.length; i < length; i++) {
		char[][] typeName = set[i];
		if (typeName != null) {
			imports[index++] = new ImportReference(typeName, new long[typeName.length]/*dummy positions*/, false/*not on demand*/, 0);
		}
	}
	return imports;
}
 
Example 2
Source File: BinaryIndexer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private char[] extractClassName(int[] constantPoolOffsets, ClassFileReader reader, int index) {
	// the entry at i has to be a field ref or a method/interface method ref.
	int class_index = reader.u2At(constantPoolOffsets[index] + 1);
	int utf8Offset = constantPoolOffsets[reader.u2At(constantPoolOffsets[class_index] + 1)];
	return reader.utf8At(utf8Offset + 3, reader.u2At(utf8Offset + 1));
}
 
Example 3
Source File: BinaryIndexer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private char[] extractName(int[] constantPoolOffsets, ClassFileReader reader, int index) {
	int nameAndTypeIndex = reader.u2At(constantPoolOffsets[index] + 3);
	int utf8Offset = constantPoolOffsets[reader.u2At(constantPoolOffsets[nameAndTypeIndex] + 1)];
	return reader.utf8At(utf8Offset + 3, reader.u2At(utf8Offset + 1));
}
 
Example 4
Source File: BinaryIndexer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private char[] extractClassReference(int[] constantPoolOffsets, ClassFileReader reader, int index) {
	// the entry at i has to be a class ref.
	int utf8Offset = constantPoolOffsets[reader.u2At(constantPoolOffsets[index] + 1)];
	return reader.utf8At(utf8Offset + 3, reader.u2At(utf8Offset + 1));
}
 
Example 5
Source File: BinaryIndexer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private char[] extractType(int[] constantPoolOffsets, ClassFileReader reader, int index) {
	int constantPoolIndex = reader.u2At(constantPoolOffsets[index] + 3);
	int utf8Offset = constantPoolOffsets[reader.u2At(constantPoolOffsets[constantPoolIndex] + 3)];
	return reader.utf8At(utf8Offset + 3, reader.u2At(utf8Offset + 1));
}