本文整理汇总了Java中org.eclipse.xtext.util.IAcceptor类的典型用法代码示例。如果您正苦于以下问题:Java IAcceptor类的具体用法?Java IAcceptor怎么用?Java IAcceptor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IAcceptor类属于org.eclipse.xtext.util包,在下文中一共展示了IAcceptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createEObjectDescriptions
import org.eclipse.xtext.util.IAcceptor; //导入依赖的package包/类
@Override
public boolean createEObjectDescriptions(EObject eObject, IAcceptor<IEObjectDescription> acceptor) {
if (eObject instanceof Type) {
// only export toplevel types
super.createEObjectDescriptions(eObject, acceptor);
return false;
}
return true;
}
示例2: toAcceptor
import org.eclipse.xtext.util.IAcceptor; //导入依赖的package包/类
@Override
protected Acceptor toAcceptor(IAcceptor<IReferenceDescription> acceptor) {
return new ReferenceAcceptor(acceptor, getResourceServiceProviderRegistry()) {
@Override
public void accept(EObject source, URI sourceURI, EReference eReference, int index, EObject targetOrProxy,
URI targetURI) {
// Check if we should ignore named import specifier
if (N4JSReferenceQueryExecutor.ignoreNamedImportSpecifier && source instanceof NamedImportSpecifier)
return;
EObject displayObject = calculateDisplayEObject(source);
String logicallyQualifiedDisplayName = N4JSHierarchicalNameComputerHelper
.calculateLogicallyQualifiedDisplayName(displayObject, labelProvider, false);
ICompositeNode srcNode = NodeModelUtils.getNode(source);
int line = srcNode.getStartLine();
LabelledReferenceDescription description = new LabelledReferenceDescription(source, displayObject,
sourceURI,
targetOrProxy,
targetURI,
eReference, index, logicallyQualifiedDisplayName, line);
accept(description);
}
};
}
示例3: validate
import org.eclipse.xtext.util.IAcceptor; //导入依赖的package包/类
/**
* Don't validate the inferred module since all validation information should be available on the AST elements.
*/
@Override
protected void validate(Resource resource, CheckMode mode, CancelIndicator cancelIndicator,
IAcceptor<Issue> acceptor) {
operationCanceledManager.checkCanceled(cancelIndicator);
if (n4jsCore.isNoValidate(resource.getURI())) {
return;
}
List<EObject> contents = resource.getContents();
if (!contents.isEmpty()) {
EObject firstElement = contents.get(0);
// // Mark the scoping as sealed. (No other usage-flags should be set for import-declarations.)
// if (firstElement instanceof Script) {
// ((Script) firstElement).setFlaggedBound(true);
// }
validate(resource, firstElement, mode, cancelIndicator, acceptor);
// UtilN4.takeSnapshotInGraphView("post validation", resource);
}
}
示例4: createEObjectDescriptions
import org.eclipse.xtext.util.IAcceptor; //导入依赖的package包/类
@Override
public boolean createEObjectDescriptions(final EObject eObject, IAcceptor<IEObjectDescription> acceptor) {
if (getQualifiedNameProvider() == null)
return false;
if (eObject instanceof TModule) {
TModule module = (TModule) eObject;
internalCreateEObjectDescriptionForRoot(module, acceptor);
for (Type type : module.getTopLevelTypes()) {
internalCreateEObjectDescription(type, acceptor);
}
for (TVariable variable : module.getVariables()) {
internalCreateEObjectDescription(variable, acceptor);
}
}
// export is only possible for top-level elements
return false;
}
示例5: buildMap
import org.eclipse.xtext.util.IAcceptor; //导入依赖的package包/类
@Override
protected void buildMap(Resource resource, Map<QualifiedName, IEObjectDescription> elements) {
IDefaultResourceDescriptionStrategy strategy = ((XtextResource) resource).getResourceServiceProvider()
.get(IDefaultResourceDescriptionStrategy.class);
TreeIterator<EObject> allProperContents = EcoreUtil.getAllProperContents(resource, false);
IAcceptor<IEObjectDescription> acceptor = new IAcceptor<IEObjectDescription>() {
@Override
public void accept(IEObjectDescription description) {
elements.put(description.getQualifiedName(), description);
}
};
while (allProperContents.hasNext()) {
EObject content = allProperContents.next();
if (!strategy.createEObjectDescriptions(content, acceptor)) {
allProperContents.prune();
}
}
}
示例6: compile
import org.eclipse.xtext.util.IAcceptor; //导入依赖的package包/类
/**
* Parses, validates and compiles the given source. Calls the given acceptor for each
* resource which is generated from the source.
*
* @param resourceSet - the {@link ResourceSet} to use
* @param acceptor gets called once for each file generated in {@link IGenerator}
*/
public void compile(final ResourceSet resourceSet, IAcceptor<Result> acceptor) {
try {
List<Resource> resourcesToCheck = newArrayList(resourceSet.getResources());
if (generatorConfigProvider instanceof GeneratorConfigProvider) {
GeneratorConfigProvider configProvider = (GeneratorConfigProvider) generatorConfigProvider;
GeneratorConfig config = generatorConfigProvider.get(null);
config.setJavaSourceVersion(javaCompiler.getJavaVersion());
GeneratorConfig existent = configProvider.install(resourceSet, config);
if (existent != null) {
existent.setJavaSourceVersion(javaCompiler.getJavaVersion());
configProvider.install(resourceSet, existent);
}
}
Result result = resultProvider.get();
result.setJavaCompiler(javaCompiler);
result.setCheckMode(getCheckMode());
result.setResources(resourcesToCheck);
result.setResourceSet(resourceSet);
result.setOutputConfigurations(getOutputConfigurations());
result.doGenerate();
acceptor.accept(result);
} catch (Exception e) {
Exceptions.throwUncheckedException(e);
}
}
示例7: validate
import org.eclipse.xtext.util.IAcceptor; //导入依赖的package包/类
@Override
public boolean validate(IAcceptor<? super AbstractDiagnostic> result) {
JvmDeclaredType declaringType = getConstructor().getDeclaringType();
if (declaringType.isAbstract()) {
String message = "Cannot instantiate the abstract type " + declaringType.getSimpleName();
AbstractDiagnostic diagnostic = new EObjectDiagnosticImpl(
Severity.ERROR,
IssueCodes.ABSTRACT_CLASS_INSTANTIATION,
message,
getExpression(),
getDefaultValidationFeature(), -1, null);
result.accept(diagnostic);
return false;
}
return super.validate(result);
}
示例8: validate
import org.eclipse.xtext.util.IAcceptor; //导入依赖的package包/类
@Override
public boolean validate(IAcceptor<? super AbstractDiagnostic> result) {
if (chosenCandidate.validate(result)) {
StringBuilder messageBuilder = new StringBuilder("Suspiciously overloaded method.\n");
messageBuilder.append("The ").append(getFeatureTypeName()).append("\n\t");
appendCandidate(chosenCandidate, messageBuilder);
messageBuilder.append("\noverloads the ").append(getFeatureTypeName()).append("\n\t");
appendCandidate(rejectedCandidate, messageBuilder);
messageBuilder.append(".");
AbstractDiagnostic diagnostic = new EObjectDiagnosticImpl(chosenCandidate.getSeverity(IssueCodes.SUSPICIOUSLY_OVERLOADED_FEATURE),
IssueCodes.SUSPICIOUSLY_OVERLOADED_FEATURE, messageBuilder.toString(), getExpression(),
XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE, -1, null);
result.accept(diagnostic);
}
return false;
}
示例9: validate
import org.eclipse.xtext.util.IAcceptor; //导入依赖的package包/类
@Override
public boolean validate(IAcceptor<? super AbstractDiagnostic> result) {
if (!getState().isInstanceContext()) {
JvmIdentifiableElement implicitFeature = getFeature();
if (implicitFeature instanceof JvmType) {
JvmIdentifiableElement feature = getState().getResolvedTypes().getLinkedFeature(getOwner());
if (feature == null || feature.eIsProxy() || !(feature instanceof JvmFeature))
return true;
String message = "Cannot make an implicit reference to this from a static context";
AbstractDiagnostic diagnostic = new EObjectDiagnosticImpl(Severity.ERROR,
IssueCodes.STATIC_ACCESS_TO_INSTANCE_MEMBER, message, getOwner(),
XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE, -1, null);
result.accept(diagnostic);
return false;
}
}
return super.validate(result);
}
示例10: createEObjectDescriptions
import org.eclipse.xtext.util.IAcceptor; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public boolean createEObjectDescriptions(final EObject from, final IAcceptor<IEObjectDescription> acceptor) {
final IQualifiedNameProvider nameProvider = getQualifiedNameProvider();
if (nameProvider == null) {
return false;
}
try {
return doCreateEObjectDescriptions(from, acceptor);
// CHECKSTYLE:OFF (IllegalCatch)
} catch (final Exception e) {
// We need to catch arbitrary exceptions here, otherwise building may fail spectacularly;
// and the cause may be very hard to find (likely some bug in an export specification).
// CHECKSTYLE:ON
LOGGER.error(MessageFormat.format(Messages.AbstractSdkResourceDescription_OBJECT_DESCRIPTION_FAILURE, EObjectUtil.getLocationString(from)), e);
}
return true;
}
示例11: validate
import org.eclipse.xtext.util.IAcceptor; //导入依赖的package包/类
/**
* Validates this linking candidate and adds respective diagnostics to the given queue.
*
* This checks the following criteria:
* <ol>
* <li>{@link #validateVisibility(IAcceptor) visibility},</li>
* <li>{@link #validateArity(IAcceptor) arity},</li>
* <li>{@link #validateTypeArity(IAcceptor) type arity},</li>
* <li>{@link #validateTypeArgumentConformance(IAcceptor) type arguments},</li>
* <li>{@link #validateUnhandledExceptions(IAcceptor) unhandled excptions},</li>
* </ol>
*/
@Override
public boolean validate(IAcceptor<? super AbstractDiagnostic> result) {
if (!validateVisibility(result)) {
return false;
}
if (!validateArity(result)) {
return false;
}
if (!validateTypeArity(result)) {
return false;
}
if (!validateTypeArgumentConformance(result)) {
return false;
}
if (!validateUnhandledExceptions(result)) {
return false;
}
return true;
}
示例12: validateVisibility
import org.eclipse.xtext.util.IAcceptor; //导入依赖的package包/类
protected boolean validateVisibility(IAcceptor<? super AbstractDiagnostic> result) {
if (!isVisible()) {
String message = String.format("The %1$s %2$s%3$s is not visible",
getFeatureTypeName(),
getSimpleFeatureName(),
getFeatureParameterTypesAsString());
AbstractDiagnostic diagnostic = new EObjectDiagnosticImpl(
Severity.ERROR,
IssueCodes.FEATURE_NOT_VISIBLE,
message,
getExpression(),
getDefaultValidationFeature(), -1, null);
result.accept(diagnostic);
return false;
}
return true;
}
示例13: validateArity
import org.eclipse.xtext.util.IAcceptor; //导入依赖的package包/类
protected boolean validateArity(IAcceptor<? super AbstractDiagnostic> result) {
if (getArityMismatch() != 0) {
String message;
if (getArguments().isEmpty()) {
message = String.format("Invalid number of arguments. The %1$s %2$s%3$s is not applicable without arguments" ,
getFeatureTypeName(),
getSimpleFeatureName(),
getFeatureParameterTypesAsString());
} else {
message = String.format("Invalid number of arguments. The %1$s %2$s%3$s is not applicable for the arguments %4$s" ,
getFeatureTypeName(),
getSimpleFeatureName(),
getFeatureParameterTypesAsString(),
getArgumentTypesAsString());
}
AbstractDiagnostic diagnostic = new EObjectDiagnosticImpl(
Severity.ERROR,
IssueCodes.INVALID_NUMBER_OF_ARGUMENTS,
message,
getExpression(),
getInvalidArgumentsValidationFeature(), -1, null);
result.accept(diagnostic);
return false;
}
return true;
}
示例14: validateTypeArity
import org.eclipse.xtext.util.IAcceptor; //导入依赖的package包/类
protected boolean validateTypeArity(IAcceptor<? super AbstractDiagnostic> result) {
if (getTypeArityMismatch() != 0) {
String message = String.format("Invalid number of type arguments. The %1$s %2$s%3$s is not applicable for the type arguments %4$s",
getFeatureTypeName(),
getSimpleFeatureName(),
getFeatureTypeParametersAsString(true),
getTypeArgumentsAsString(getSyntacticTypeArguments()));
AbstractDiagnostic diagnostic = new EObjectDiagnosticImpl(
Severity.ERROR,
IssueCodes.INVALID_NUMBER_OF_TYPE_ARGUMENTS,
message,
getExpression(),
getDefaultValidationFeature(), -1, null);
result.accept(diagnostic);
return false;
}
return true;
}
示例15: validate
import org.eclipse.xtext.util.IAcceptor; //导入依赖的package包/类
@Override
public boolean validate(IAcceptor<? super AbstractDiagnostic> result) {
JvmType type = (JvmType) description.getElementOrProxy();
String typeKind = "";
if (type instanceof JvmPrimitiveType || type instanceof JvmVoid) {
typeKind = "primitive type";
} else if (type instanceof JvmAnnotationType) {
typeKind = "annotation type";
} else if (type instanceof JvmEnumerationType) {
typeKind = "enum type";
} else if (type instanceof JvmGenericType && ((JvmGenericType) type).isInterface()) {
typeKind = "interface type";
} else if (type instanceof JvmTypeParameter) {
typeKind = "type parameter";
}
String message = String.format("Cannot instantiate the %s %s", typeKind, type.getSimpleName());
AbstractDiagnostic diagnostic = new EObjectDiagnosticImpl(Severity.ERROR,
IssueCodes.ILLEGAL_CLASS_INSTANTIATION, message, getExpression(),
XbasePackage.Literals.XCONSTRUCTOR_CALL__CONSTRUCTOR, -1, null);
result.accept(diagnostic);
return false;
}