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


Java XVariableDeclaration.isWriteable方法代码示例

本文整理汇总了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;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:20,代码来源:XbaseCompiler.java

示例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);
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:12,代码来源:XbaseValidator.java

示例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);
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:41,代码来源:XbaseValidator.java

示例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);
		}
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:10,代码来源:XbaseHighlightingCalculator.java


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