Java Code Examples for org.eclipse.jdt.core.dom.ArrayType#getElementType()

The following examples show how to use org.eclipse.jdt.core.dom.ArrayType#getElementType() . 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: StubUtility.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static String[] getVariableNameSuggestions(int variableKind, IJavaProject project, Type expectedType, Collection<String> excluded, boolean evaluateDefault) {
	int dim= 0;
	if (expectedType.isArrayType()) {
		ArrayType arrayType= (ArrayType)expectedType;
		dim= arrayType.getDimensions();
		expectedType= arrayType.getElementType();
	}
	if (expectedType.isParameterizedType()) {
		expectedType= ((ParameterizedType)expectedType).getType();
	}
	String typeName= ASTNodes.getTypeName(expectedType);

	if (typeName.length() > 0) {
		return getVariableNameSuggestions(variableKind, project, typeName, dim, excluded, evaluateDefault);
	}
	return EMPTY;
}
 
Example 2
Source File: RefactoringUtility.java    From JDeodorant with MIT License 6 votes vote down vote up
private static boolean isQualifiedType(Type type) {
	if(type instanceof SimpleType) {
		SimpleType simpleType = (SimpleType)type;
		Name name = simpleType.getName();
		if(name instanceof QualifiedName) {
			return true;
		}
	}
	else if(type instanceof QualifiedType) {
		QualifiedType qualifiedType = (QualifiedType)type;
		Type qualifier = qualifiedType.getQualifier();
		return isQualifiedType(qualifier);
	}
	else if(type instanceof ArrayType) {
		ArrayType arrayType = (ArrayType)type;
		Type elementType = arrayType.getElementType();
		return isQualifiedType(elementType);
	}
	else if(type instanceof ParameterizedType) {
		ParameterizedType parameterizedType = (ParameterizedType)type;
		Type erasureType = parameterizedType.getType();
		return isQualifiedType(erasureType);
	}
	return false;
}
 
Example 3
Source File: CodeBlock.java    From SimFix with GNU General Public License v2.0 5 votes vote down vote up
private ArrayAcc visit(ArrayAccess node) {
	int startLine = _cunit.getLineNumber(node.getStartPosition());
	int endLine = _cunit.getLineNumber(node.getStartPosition() + node.getLength());
	ArrayAcc arrayAcc = new ArrayAcc(startLine, endLine, node);
	
	Expr array = (Expr) process(node.getArray());
	array.setParent(arrayAcc);
	arrayAcc.setArray(array);
	
	Expr indexExpr = (Expr) process(node.getIndex());
	indexExpr.setParent(arrayAcc);
	arrayAcc.setIndex(indexExpr);
	
	Pair<String, String> classAndMethodName = NodeUtils.getTypeDecAndMethodDec(node);
	String nodeStr = node.toString();
	int index = nodeStr.indexOf("[");
	if(index >= 0){
		nodeStr = nodeStr.substring(0, index);
	}
	Type type = ProjectInfo.getVariableType(classAndMethodName.getFirst(), classAndMethodName.getSecond(), nodeStr);
	if(type != null){
		if(type instanceof ArrayType){
			ArrayType arrayType = (ArrayType) type;
			type = arrayType.getElementType();
		} else {
			System.out.println("ArrayAccess type error : not array type ! " + node.toString());
		}
	}
	arrayAcc.setType(type);
	
	return arrayAcc;
}
 
Example 4
Source File: SuperTypeConstraintsCreator.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public final void endVisit(final ArrayType node) {
	Type elementType= node.getElementType();
	final ConstraintVariable2 variable= fModel.createTypeVariable(elementType);
	if (variable != null) {
		elementType.setProperty(PROPERTY_CONSTRAINT_VARIABLE, variable);
		node.setProperty(PROPERTY_CONSTRAINT_VARIABLE, variable);
	}
}
 
Example 5
Source File: TypeContextChecker.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static boolean isVoidArrayType(Type type){
	if (! type.isArrayType())
		return false;

	ArrayType arrayType= (ArrayType)type;
	if (! arrayType.getElementType().isPrimitiveType())
		return false;
	PrimitiveType primitiveType= (PrimitiveType) arrayType.getElementType();
	return (primitiveType.getPrimitiveTypeCode() == PrimitiveType.VOID);
}