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


Java CheckType类代码示例

本文整理汇总了Java中org.eclipse.xtext.validation.CheckType的典型用法代码示例。如果您正苦于以下问题:Java CheckType类的具体用法?Java CheckType怎么用?Java CheckType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CheckType类属于org.eclipse.xtext.validation包,在下文中一共展示了CheckType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createPostProcessingFailedError

import org.eclipse.xtext.validation.CheckType; //导入依赖的package包/类
private Issue createPostProcessingFailedError(N4JSResource res, Throwable th) {
	final String thKind = th instanceof Error ? "error" : (th instanceof Exception ? "exception" : "throwable");
	final String thName = th.getClass().getSimpleName();
	final String trace = "\n" + Stream.of(th.getStackTrace())
			.map(ste -> ste.toString())
			.collect(Collectors.joining("\n")); // cannot add indentation, because Xtext would reformat the message
	final String msg = IssueCodes.getMessageForPOST_PROCESSING_FAILED(thKind, thName, th.getMessage() + trace);
	final Issue.IssueImpl issue = new Issue.IssueImpl();
	issue.setCode(IssueCodes.POST_PROCESSING_FAILED);
	issue.setSeverity(IssueCodes.getDefaultSeverity(IssueCodes.POST_PROCESSING_FAILED));
	issue.setMessage(msg);
	issue.setUriToProblem(EcoreUtil.getURI(res.getScript()));
	issue.setType(CheckType.FAST); // using CheckType.FAST is important to get proper marker update behavior in ...
	// ... the editor between persisted and dirty states!
	issue.setOffset(0);
	issue.setLength(0);
	issue.setLineNumber(0);
	issue.setColumn(0);
	return issue;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:21,代码来源:N4JSResourceValidator.java

示例2: checkUnusedEntry

import org.eclipse.xtext.validation.CheckType; //导入依赖的package包/类
@Check(CheckType.FAST)
public void checkUnusedEntry(final Entry entry) {
	if (entry.getParentRegion().getComposite() instanceof org.yakindu.sct.model.sgraph.State
			&& entry.getIncomingTransitions().isEmpty()) {
		org.yakindu.sct.model.sgraph.State state = (org.yakindu.sct.model.sgraph.State) entry.getParentRegion()
				.getComposite();
		if (!STextValidationModelUtils.isDefault(entry)) {
			boolean hasIncomingTransition = false;
			Iterator<Transition> transitionIt = state.getIncomingTransitions().iterator();
			while (transitionIt.hasNext() && !hasIncomingTransition) {
				Iterator<ReactionProperty> propertyIt = transitionIt.next().getProperties().iterator();
				while (propertyIt.hasNext() && !hasIncomingTransition) {
					ReactionProperty property = propertyIt.next();
					if (property instanceof EntryPointSpec) {
						hasIncomingTransition = entry.getName().equals(((EntryPointSpec) property).getEntrypoint());
					}
				}
			}
			if (!hasIncomingTransition) {
				warning(ENTRY_UNUSED, entry, null, -1);
			}
		}
	}
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:25,代码来源:STextJavaValidator.java

示例3: checkValueOfNoEvent

import org.eclipse.xtext.validation.CheckType; //导入依赖的package包/类
@Check(CheckType.FAST)
public void checkValueOfNoEvent(EventValueReferenceExpression exp) {

	Expression eventExpr = exp.getValue();

	EObject element = null;
	if (eventExpr instanceof ElementReferenceExpression) {
		element = ((ElementReferenceExpression) eventExpr).getReference();
	} else if (eventExpr instanceof FeatureCall) {
		element = ((FeatureCall) eventExpr).getFeature();
	}

	if (element != null && (!(element instanceof Event))) {
		String elementName = "";
		if (element instanceof NamedElement) {
			elementName = "'" + ((NamedElement) element).getName() + "' ";
		}
		error(elementName + "is no event.", StextPackage.Literals.EVENT_VALUE_REFERENCE_EXPRESSION__VALUE, 0,
				VALUE_OF_REQUIRES_EVENT);
	}
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:22,代码来源:STextJavaValidator.java

示例4: checkTopLeveEntryIsDefaultEntry

import org.eclipse.xtext.validation.CheckType; //导入依赖的package包/类
@Check(CheckType.NORMAL)
public void checkTopLeveEntryIsDefaultEntry(final Entry entry) {
	Region parentRegion = entry.getParentRegion();
	// 1. check if is toplevel
	if (isTopLevelRegion(parentRegion)) {
		boolean isDefaultEntry = STextValidationModelUtils.isDefault(entry);
		// 2. check if is default entry
		if (!isDefaultEntry) {
			Map<Region, List<Entry>> regionsWithoutDefaultEntry = STextValidationModelUtils
					.getRegionsWithoutDefaultEntry(Lists.newArrayList(parentRegion));
			List<Entry> list = regionsWithoutDefaultEntry.get(parentRegion);
			if (list != null)
				error(TOP_LEVEL_REGION_ENTRY_HAVE_TO_BE_A_DEFAULT_ENTRY, entry, SGraphPackage.Literals.ENTRY__KIND,
						-1);
			else
				warning(TOP_LEVEL_REGION_ENTRY_HAVE_TO_BE_A_DEFAULT_ENTRY, entry,
						SGraphPackage.Literals.ENTRY__KIND, -1);
		}
	}
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:21,代码来源:STextJavaValidator.java

示例5: checkAssignmentExpression

import org.eclipse.xtext.validation.CheckType; //导入依赖的package包/类
@Check(CheckType.FAST)
public void checkAssignmentExpression(final AssignmentExpression exp) {
	final String name = getVariableName(exp);
	List<AssignmentExpression> contents = EcoreUtil2.eAllOfType(exp, AssignmentExpression.class);
	contents.remove(exp);
	Iterable<AssignmentExpression> filter = Iterables.filter(contents, new Predicate<AssignmentExpression>() {
		public boolean apply(final AssignmentExpression ex) {
			String variableName = getVariableName(ex);
			return variableName.equals(name);

		}
	});
	if (Iterables.size(filter) > 0) {
		error(ASSIGNMENT_EXPRESSION, null);
	}
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:17,代码来源:STextJavaValidator.java

示例6: checkReactionTriggerRegularEvent

import org.eclipse.xtext.validation.CheckType; //导入依赖的package包/类
@Check(CheckType.FAST)
public void checkReactionTriggerRegularEvent(ReactionTrigger reactionTrigger) {
	for (int i = 0; i < reactionTrigger.getTriggers().size(); i++) {
		EventSpec eventSpec = reactionTrigger.getTriggers().get(i);
		if (eventSpec instanceof RegularEventSpec) {
			EObject element = unwrap(((RegularEventSpec) eventSpec).getEvent());
			if (element != null && (!(element instanceof Event))) {
				String elementName = "";
				if (element instanceof NamedElement) {
					elementName = "'" + ((NamedElement) element).getName() + "' ";
				}
				error("Trigger " + elementName + "is no event.", StextPackage.Literals.REACTION_TRIGGER__TRIGGERS,
						i, TRIGGER_IS_NO_EVENT);
			}
		}
	}
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:18,代码来源:STextJavaValidator.java

示例7: checkReactionEffectActions

import org.eclipse.xtext.validation.CheckType; //导入依赖的package包/类
/**
 * Only Expressions that produce an effect should be used as actions.
 * 
 * @param effect
 */
@Check(CheckType.FAST)
public void checkReactionEffectActions(ReactionEffect effect) {
	for (Expression exp : effect.getActions()) {

		if (!(exp instanceof AssignmentExpression) && !(exp instanceof EventRaisingExpression) 
				&& !(exp instanceof PostFixUnaryExpression)) {

			if (exp instanceof FeatureCall) {
				checkFeatureCallEffect((FeatureCall) exp);
			} else if (exp instanceof ElementReferenceExpression) {
				checkElementReferenceEffect((ElementReferenceExpression) exp);
			} else {
				error("Action has no effect.", StextPackage.Literals.REACTION_EFFECT__ACTIONS,
						effect.getActions().indexOf(exp), FEATURE_CALL_HAS_NO_EFFECT);
			}

		}
	}
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:25,代码来源:STextJavaValidator.java

示例8: checkAnnotationTarget

import org.eclipse.xtext.validation.CheckType; //导入依赖的package包/类
@Check(CheckType.FAST)
public void checkAnnotationTarget(final AnnotatableElement element) {
	EList<Annotation> annotations = element.getAnnotations();
	for (Annotation annotation : annotations) {
		EList<EObject> targets = annotation.getType().getTargets();
		if(targets.isEmpty())
			continue;
		boolean found = Iterables.any(targets, new Predicate<EObject>() {
			@Override
			public boolean apply(EObject input) {
				return ((EClass) input).isInstance(element);
			}
		});
		if (!found) {
			error(String.format(ERROR_WRONG_ANNOTATION_TARGET_MSG, annotation.getType().getName(),
					element.eClass()), null,
					element.getAnnotations().indexOf(annotation), ERROR_WRONG_ANNOTATION_TARGET_CODE);
		}
	}
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:21,代码来源:ExpressionsJavaValidator.java

示例9: checkDesignNameUnique

import org.eclipse.xtext.validation.CheckType; //导入依赖的package包/类
@Check(CheckType.NORMAL)
public void checkDesignNameUnique(Design design) {
	List<Design> designs = new ArrayList<Design>();
	IResourceDescription resourceDescription = resourceDescriptions.getResourceDescription(design.eResource()
			.getURI());
	List<IContainer> visiblecontainers = containermanager.getVisibleContainers(resourceDescription,
			resourceDescriptions);
	for (IContainer container : visiblecontainers) {
		for (IEObjectDescription eobjectDescription : container.getExportedObjects()) {
			EObject eObjectOrProxy = eobjectDescription.getEObjectOrProxy();
			if (eObjectOrProxy instanceof Design)
				designs.add((Design) eObjectOrProxy);
		}
	}

	int count = 0;
	for (Design d : designs) {
		if (d.eIsProxy())
			d = (Design) EcoreUtil.resolve(d, design);
		if (design.getName().equals(d.getName()))
			count++;
	}
	if (count > 1)
		error("Duplicate design in project.", PhdlPackage.Literals.DESIGN__NAME);
}
 
开发者ID:timofonic,项目名称:PHDL,代码行数:26,代码来源:PhdlJavaValidator.java

示例10: checkDevicePhysicalPinNames

import org.eclipse.xtext.validation.CheckType; //导入依赖的package包/类
@Check(CheckType.FAST)
public void checkDevicePhysicalPinNames(Device d) {
	Map<String, Pin> pinMap = new HashMap<String, Pin>();
	for (DeviceElement element : d.getElements()) {
		if (element instanceof Pin) {
			Pin p = (Pin) element;
			List<String> pinList = p.getPinNames();
			for (int i = 0; i < (pinList.size()); i++) {
				String pinNum = pinList.get(i);
				if (pinMap.containsKey(pinNum)) {
					EStructuralFeature f = PhdlPackage.Literals.PIN__PIN_NAMES;
					error("Duplicate physical pin name.", p, f, i);
					Pin orig = pinMap.get(pinNum);
					error("Duplicate physical pin name.", orig, f, orig.getPinNames().indexOf(pinNum));
				} else
					pinMap.put(pinNum, p);
			}
		}
	}
}
 
开发者ID:timofonic,项目名称:PHDL,代码行数:21,代码来源:PhdlJavaValidator.java

示例11: checkDevicePinDeclarations

import org.eclipse.xtext.validation.CheckType; //导入依赖的package包/类
@Check(CheckType.FAST)
public void checkDevicePinDeclarations(Device d) {
	for (DeviceElement element : d.getElements()) {
		if (element instanceof Pin) {
			Pin p = (Pin) element;
			int index = d.getElements().indexOf(p);
			int width = (Math.abs(p.getVector().getMsb() - p.getVector().getLsb())) + 1;
			if (width != p.getPinNames().size())
				error("Pin declaration width mismatch.  Left=" + width + ", right=" + p.getPinNames().size() + ".",
						d, PhdlPackage.Literals.DEVICE__ELEMENTS, d.getElements().indexOf(element),
						IssueCodes.INVALID_PIN_DECLARATION, Integer.toString(index),
						Boolean.toString(p.getVector().isVector()), Integer.toString(width),
						Integer.toString(p.getPinNames().size()));
		}
	}
}
 
开发者ID:timofonic,项目名称:PHDL,代码行数:17,代码来源:PhdlJavaValidator.java

示例12: checkDeviceRequiredAttributes

import org.eclipse.xtext.validation.CheckType; //导入依赖的package包/类
@Check(CheckType.FAST)
public void checkDeviceRequiredAttributes(Device d) {
	for (String reqAttr : reqAttrs) {
		boolean found = false;
		for (DeviceElement element : d.getElements()) {
			if (element instanceof Attr) {
				Attr a = (Attr) element;
				if (a.getName().equalsIgnoreCase(reqAttr)) {
					found = true;
					break;
				}
			}
		}
		if (!found) {
			error("Required attribute '" + reqAttr + "' missing.", d, PhdlPackage.Literals.DEVICE__NAME, -1,
					IssueCodes.REQUIRED_ATTRIBUTE_MISSING, reqAttr);
		}
	}
}
 
开发者ID:timofonic,项目名称:PHDL,代码行数:20,代码来源:PhdlJavaValidator.java

示例13: checkPackageNameUnique

import org.eclipse.xtext.validation.CheckType; //导入依赖的package包/类
@Check(CheckType.NORMAL)
public void checkPackageNameUnique(Package pkg) {
	List<Package> packages = new ArrayList<Package>();
	IResourceDescription resourceDescription = resourceDescriptions
			.getResourceDescription(pkg.eResource().getURI());
	List<IContainer> visiblecontainers = containermanager.getVisibleContainers(resourceDescription,
			resourceDescriptions);
	for (IContainer container : visiblecontainers) {
		for (IEObjectDescription eobjectDescription : container.getExportedObjects()) {
			EObject eObjectOrProxy = eobjectDescription.getEObjectOrProxy();
			if (eObjectOrProxy instanceof Package)
				packages.add((Package) eObjectOrProxy);
		}
	}
	int count = 0;
	for (Package p : packages) {
		if (p.eIsProxy())
			p = (Package) EcoreUtil.resolve(p, pkg);
		if (pkg.getName().equals(p.getName()))
			count++;
	}
	if (count > 1)
		error("Duplicate package in project.", PhdlPackage.Literals.PACKAGE__NAME);
}
 
开发者ID:timofonic,项目名称:PHDL,代码行数:25,代码来源:PhdlJavaValidator.java

示例14: checkPinAssignQualifiers

import org.eclipse.xtext.validation.CheckType; //导入依赖的package包/类
@Check(CheckType.FAST)
public void checkPinAssignQualifiers(PinAssign p) {
	Instance i = (Instance) p.eContainer();
	if (i.getArray().isArray()) {
		if (p.getQualifier() != null) {
			if (p.getQualifier().getIndices().isArray()) {
				if (!PhdlUtils.isValidIndex(i.getArray().getMsb(), i.getArray().getLsb(), p.getQualifier()
						.getIndices().getMsb()))
					invalidMsbError(p.getQualifier().getIndices(), PhdlPackage.Literals.INDICES__MSB);
				if (!PhdlUtils.isValidIndex(i.getArray().getMsb(), i.getArray().getLsb(), p.getQualifier()
						.getIndices().getLsb()))
					invalidLsbError(p.getQualifier().getIndices(), PhdlPackage.Literals.INDICES__LSB);
			} else {
				for (Integer index : p.getQualifier().getIndices().getIndices())
					if (!PhdlUtils.isValidIndex(i.getArray().getMsb(), i.getArray().getLsb(), index))
						invalidIndexError(p.getQualifier().getIndices(), p.getQualifier().getIndices().getIndices()
								.indexOf(index), PhdlPackage.Literals.INDICES__INDICES);
			}
		}
	} else {
		if (p.getQualifier() != null)
			qualifierNotAllowedError(p, PhdlPackage.Literals.PIN_ASSIGN__QUALIFIER);
	}
}
 
开发者ID:timofonic,项目名称:PHDL,代码行数:25,代码来源:PhdlJavaValidator.java

示例15: checkPortAssignQualifiers

import org.eclipse.xtext.validation.CheckType; //导入依赖的package包/类
@Check(CheckType.FAST)
public void checkPortAssignQualifiers(PortAssign p) {
	Instance i = (Instance) p.eContainer();
	if (i.getArray().isArray()) {
		if (p.getQualifier() != null) {
			if (p.getQualifier().getIndices().isArray()) {
				if (!PhdlUtils.isValidIndex(i.getArray().getMsb(), i.getArray().getLsb(), p.getQualifier()
						.getIndices().getMsb()))
					invalidMsbError(p.getQualifier().getIndices(), PhdlPackage.Literals.INDICES__MSB);
				if (!PhdlUtils.isValidIndex(i.getArray().getMsb(), i.getArray().getLsb(), p.getQualifier()
						.getIndices().getLsb()))
					invalidLsbError(p.getQualifier().getIndices(), PhdlPackage.Literals.INDICES__LSB);
			} else {
				for (Integer index : p.getQualifier().getIndices().getIndices())
					if (!PhdlUtils.isValidIndex(i.getArray().getMsb(), i.getArray().getLsb(), index))
						invalidIndexError(p.getQualifier().getIndices(), p.getQualifier().getIndices().getIndices()
								.indexOf(index), PhdlPackage.Literals.INDICES__INDICES);
			}
		}
	} else {
		if (p.getQualifier() != null)
			qualifierNotAllowedError(p, PhdlPackage.Literals.PORT_ASSIGN__QUALIFIER);
	}
}
 
开发者ID:timofonic,项目名称:PHDL,代码行数:25,代码来源:PhdlJavaValidator.java


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