当前位置: 首页>>代码示例>>Java>>正文


Java IDatatype.getOperationCount方法代码示例

本文整理汇总了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;
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:34,代码来源:ExpressionProposalProvider.java

示例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;
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:44,代码来源:ModelTranslator.java

示例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);
            }
        }
    }        
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:54,代码来源:ExpressionProposalProvider.java


注:本文中的net.ssehub.easy.varModel.model.datatypes.IDatatype.getOperationCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。