本文整理汇总了Java中net.ssehub.easy.varModel.model.datatypes.IDatatype.getOperationCount方法的典型用法代码示例。如果您正苦于以下问题:Java IDatatype.getOperationCount方法的具体用法?Java IDatatype.getOperationCount怎么用?Java IDatatype.getOperationCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.ssehub.easy.varModel.model.datatypes.IDatatype
的用法示例。
在下文中一共展示了IDatatype.getOperationCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: inferType
import net.ssehub.easy.varModel.model.datatypes.IDatatype; //导入方法依赖的package包/类
/**
* Determines the type of the operation <code>name</code> on <code>operand</code> with given parameters.
*
* @param name the name of the operation
* @param operand the operand type
* @param pTypes the parameter types (may be <b>null</b>)
* @param containerOp propose only container operations
* @return the inferred type or <b>null</b> if no type is available
*/
private IDatatype inferType(String name, IDatatype operand, IDatatype[] pTypes, boolean containerOp) {
IDatatype result = null;
operand = Reference.dereference(operand);
operand = DerivedDatatype.resolveToBasis(operand);
for (int o = 0; null == result && o < operand.getOperationCount(); o++) {
Operation op = operand.getOperation(o);
if (containerOp == op.isContainerOperation() && op.getName().equals(name)) {
boolean ok;
int pCount = op.getParameterCount();
if (0 == pCount) {
ok = (null == pTypes || 0 == pTypes.length);
} else {
ok = (null != pTypes && pCount == pTypes.length);
}
for (int p = 0; ok && p < pCount; p++) {
ok = op.getParameterType(p).isAssignableFrom(pTypes[p]);
}
if (ok) {
result = op.getActualReturnType(operand, pTypes);
}
}
}
return result;
}
示例2: findOperation
import net.ssehub.easy.varModel.model.datatypes.IDatatype; //导入方法依赖的package包/类
/**
* Finds an operation on a given datatype.
*
* @param datatype
* the datatype to search for
* @param operation
* the operation to be searched for
* @param considerOperand
* whether the operand of the operations defined in
* <code>datatype</code> should be considered as first parameter
* of <code>operation</code>, used to match the implicit project
* parameter for ambigous operation checking
* @return <code>true</code> if the operation was found, <code>false</code>
* else
*/
private boolean findOperation(IDatatype datatype, Operation operation,
boolean considerOperand) {
boolean found = false;
for (int op = 0; !found && op < datatype.getOperationCount(); op++) {
Operation defOperation = datatype.getOperation(op);
int defParamCount = defOperation.getParameterCount();
if (considerOperand) {
defParamCount++;
}
if (defOperation.getName().equals(operation.getName())
&& (defParamCount == operation.getParameterCount())) {
boolean paramMatch = true;
int defPInc = 0;
if (considerOperand) {
paramMatch = defOperation.getOperand().equals(
operation.getParameterType(0));
defPInc = 1;
}
for (int p = 0; paramMatch
&& p < defOperation.getParameterCount(); p++) {
paramMatch = defOperation.getParameterType(p + defPInc).equals(
operation.getParameterType(p));
}
found = paramMatch;
}
}
return found;
}
示例3: proposeOperations
import net.ssehub.easy.varModel.model.datatypes.IDatatype; //导入方法依赖的package包/类
/**
* Propose operations based on an IVML type.
*
* @param type the IVML type to propose operations for (may be <b>null</b>)
* @param context the content assist context
* @param acceptor the proposal acceptor
* @param containerOp propose only container operations
*/
private void proposeOperations(IDatatype type, ContentAssistContext context, ICompletionProposalAcceptor acceptor,
boolean containerOp) {
if (null != type) {
type = DerivedDatatype.resolveToBasis(type);
type = Reference.dereference(type);
for (int o = 0, n = type.getOperationCount(); o < n; o++) {
Operation op = type.getOperation(o);
if (containerOp == op.isContainerOperation()) {
String sig = stripSignature(op.getSignature());
String prop = "";
switch(op.getFormattingHint()) {
case FUNCTION_CALL:
prop = sig;
sig = op.getName() + "(";
for (int p = 0; p < op.getParameterCount(); p++) {
if (p > 0) {
sig += ", ";
}
sig += IvmlDatatypeVisitor.getUniqueType(op.getParameterType(p));
}
sig += ")";
break;
case OPERATOR_INFIX:
sig = op.getName() + " " + IvmlDatatypeVisitor.getUnqualifiedType(op.getParameterType(0));
prop = op.getName();
break;
case OPERATOR_POSTFIX:
sig = IvmlDatatypeVisitor.getUnqualifiedType(op.getOperand()) + " " + op.getName();
prop = op.getName();
break;
case OPERATOR_PREFIX:
sig = op.getName() +" " + IvmlDatatypeVisitor.getUnqualifiedType(op.getOperand());
prop = op.getName();
break;
}
StyledString displayName = new StyledString();
displayName.append(sig);
ICompletionProposal proposal = createCompletionProposal(prop, displayName,
imageHelper.getImage(Images.NAME_OPERATION), 400, // TODO check image
context.getPrefix(), context);
acceptor.accept(proposal);
}
}
}
}