本文整理汇总了Java中org.eclipse.xtext.xbase.XVariableDeclaration.isWriteable方法的典型用法代码示例。如果您正苦于以下问题:Java XVariableDeclaration.isWriteable方法的具体用法?Java XVariableDeclaration.isWriteable怎么用?Java XVariableDeclaration.isWriteable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.xtext.xbase.XVariableDeclaration
的用法示例。
在下文中一共展示了XVariableDeclaration.isWriteable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: appendVariableTypeAndName
import org.eclipse.xtext.xbase.XVariableDeclaration; //导入方法依赖的package包/类
protected LightweightTypeReference appendVariableTypeAndName(XVariableDeclaration varDeclaration, ITreeAppendable appendable) {
if (!varDeclaration.isWriteable()) {
appendable.append("final ");
}
LightweightTypeReference type = null;
if (varDeclaration.getType() != null) {
serialize(varDeclaration.getType(), varDeclaration, appendable);
type = getLightweightType((JvmIdentifiableElement) varDeclaration);
} else {
type = getLightweightType(varDeclaration.getRight());
if (type.isAny()) {
type = getTypeForVariableDeclaration(varDeclaration.getRight());
}
appendable.append(type);
}
appendable.append(" ");
appendable.append(appendable.declareVariable(varDeclaration, makeJavaIdentifier(varDeclaration.getName())));
return type;
}
示例2: checkVariableDeclaration
import org.eclipse.xtext.xbase.XVariableDeclaration; //导入方法依赖的package包/类
@Check
public void checkVariableDeclaration(XVariableDeclaration declaration) {
if (declaration.getRight() == null) {
if (!declaration.isWriteable())
error("Value must be initialized", Literals.XVARIABLE_DECLARATION__WRITEABLE,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX, MISSING_INITIALIZATION);
if (declaration.getType() == null)
error("Type cannot be derived", Literals.XVARIABLE_DECLARATION__NAME,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX, MISSING_TYPE);
}
}
示例3: checkAssignment
import org.eclipse.xtext.xbase.XVariableDeclaration; //导入方法依赖的package包/类
protected void checkAssignment(XExpression expression, EStructuralFeature feature, boolean simpleAssignment) {
if (!(expression instanceof XAbstractFeatureCall)) {
error("The left-hand side of an assignment must be a variable", expression, null,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX, ASSIGNMENT_TO_NO_VARIABLE);
return;
}
XAbstractFeatureCall assignment = (XAbstractFeatureCall) expression;
JvmIdentifiableElement assignmentFeature = assignment.getFeature();
if (assignmentFeature instanceof XVariableDeclaration) {
XVariableDeclaration variableDeclaration = (XVariableDeclaration) assignmentFeature;
if (variableDeclaration.isWriteable()) {
return;
}
error("Assignment to final variable", expression, feature,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX, ASSIGNMENT_TO_FINAL);
} else if (assignmentFeature instanceof JvmFormalParameter) {
error("Assignment to final parameter", expression, feature,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX, ASSIGNMENT_TO_FINAL);
} else if (assignmentFeature instanceof JvmField) {
JvmField field = (JvmField) assignmentFeature;
if (!field.isFinal()) {
return;
}
if (simpleAssignment) {
JvmIdentifiableElement container = logicalContainerProvider.getNearestLogicalContainer(assignment);
// don't issue an error if it's an assignment of a local final field within a constructor.
if (container != null && container instanceof JvmConstructor) {
JvmConstructor constructor = (JvmConstructor) container;
if (field.getDeclaringType() == constructor.getDeclaringType())
return;
}
}
error("Assignment to final field", expression, feature,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX, ASSIGNMENT_TO_FINAL);
} else if (!simpleAssignment) {
error("The left-hand side of an assignment must be a variable", expression, null,
ValidationMessageAcceptor.INSIGNIFICANT_INDEX, ASSIGNMENT_TO_NO_VARIABLE);
}
}
示例4: highlightVariableDeclaration
import org.eclipse.xtext.xbase.XVariableDeclaration; //导入方法依赖的package包/类
protected void highlightVariableDeclaration(XVariableDeclaration varDecl, IHighlightedPositionAcceptor acceptor) {
if (!SPECIAL_FEATURE_NAMES.contains(varDecl.getName())) {
// highlighting of special identifiers is done separately, so it's omitted here
highlightFeature(acceptor, varDecl, XbasePackage.Literals.XVARIABLE_DECLARATION__NAME, LOCAL_VARIABLE_DECLARATION);
if (!varDecl.isWriteable()) {
highlightFeature(acceptor, varDecl, XbasePackage.Literals.XVARIABLE_DECLARATION__NAME, LOCAL_FINAL_VARIABLE_DECLARATION);
}
}
}