下面列出了org.eclipse.jdt.core.dom.TypeDeclaration#isInterface ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public boolean canConvertToRichText(final InfixExpression node) {
final FieldDeclaration parentFieldDecl = this.<FieldDeclaration>findParentOfType(node, FieldDeclaration.class);
if ((parentFieldDecl != null)) {
final TypeDeclaration typeDeclr = this.<TypeDeclaration>findParentOfType(parentFieldDecl, TypeDeclaration.class);
if ((typeDeclr.isInterface() || (this.isFinal(parentFieldDecl.modifiers()) && this.isStatic(parentFieldDecl.modifiers())))) {
return false;
}
}
final SingleMemberAnnotation parentSingleMemberAnnotation = this.<SingleMemberAnnotation>findParentOfType(node, SingleMemberAnnotation.class);
if ((parentSingleMemberAnnotation != null)) {
return false;
}
final Iterable<StringLiteral> nodes = this.collectCompatibleNodes(node);
return ((!IterableExtensions.isEmpty(nodes)) && IterableExtensions.<StringLiteral>forall(nodes, ((Function1<StringLiteral, Boolean>) (StringLiteral it) -> {
return Boolean.valueOf(this.canTranslate(it));
})));
}
/**
* If true is returned, the type declaration has a resolvable binding.
*/
private boolean shouldValidateType(TypeDeclaration typeDecl) {
if (typeDecl.isInterface()) {
return false;
}
IType ownerType = getType(typeDecl);
if (ownerType == null) {
return false;
}
if (!uiBinderToOwner.isOwnerType(ownerType.getFullyQualifiedName('.'))) {
return false;
}
if (typeDecl.resolveBinding() == null) {
GWTPluginLog.logWarning("Could not resolve binding for "
+ typeDecl.getName().getFullyQualifiedName());
return false;
}
return true;
}
/**
* If true is returned, the type declaration has a resolveable binding.
*/
private boolean shouldValidateType(TypeDeclaration typeDecl) {
if (!typeDecl.isInterface()) {
return false;
}
ITypeBinding typeBinding = typeDecl.resolveBinding();
if (typeBinding == null) {
return false;
}
if (!isUiBinder(typeBinding)) {
return false;
}
// Passed all tests, so validate
return true;
}
private static boolean shouldValidateType(TypeDeclaration type) {
if (!type.isInterface()) {
return false;
}
ITypeBinding typeBinding = type.resolveBinding();
if (typeBinding == null) {
return false;
}
if (!ClientBundleUtilities.isClientBundle(typeBinding)) {
return false;
}
// Don't actually validate the built-in ClientBundle and
// ClientBundleWithLookup types.
String typeName = typeBinding.getQualifiedName();
if (typeName.equals(ClientBundleUtilities.CLIENT_BUNDLE_TYPE_NAME)
|| typeName.equals(ClientBundleUtilities.CLIENT_BUNDLE_WITH_LOOKUP_TYPE_NAME)) {
return false;
}
// Passed all tests, so validate
return true;
}
@Override
public boolean visit(TypeDeclaration node) {
if (node.isInterface())
return visitInterface(node);
else
return visitClass(node);
}
@Override
public void endVisit(TypeDeclaration node) {
if (node.isInterface())
return;
if (methods2 > 0) {
classes++;
if (maxMethods < methods2)
maxMethods = methods2;
if (minMethods > methods2)
minMethods = methods2;
}
methods2 = methodsStack.pop();
}
@Override
public void endVisit(TypeDeclaration node) {
if (node.isInterface())
return;
classes++;
if (maxFields < fieds2)
maxFields = fieds2;
if (minFields > fieds2)
minFields = fieds2;
fieds2 = fieldsStack.pop();
}
@Override
public void endVisit(TypeDeclaration node) {
if (node.isInterface()) {
if (methods2 > 0) {
interfacesWithMethods++;
}
if (maxMethods < methods2)
maxMethods = methods2;
if (minMethods > methods2)
minMethods = methods2;
methods2 = methodsStack.pop();
} else
return;
}
@Override
public void endVisit(TypeDeclaration node) {
if (node.isInterface())
return;
if (methods2 > 0) {classes ++;}
if (maxMethods < methods2)
maxMethods = methods2;
if (minMethods > methods2)
minMethods = methods2;
methods2 = methodsStack.pop();
}
@Override
public void endVisit(TypeDeclaration node) {
if (node.isInterface())
return;
classes++;
if (maxMethods < methods2)
maxMethods = methods2;
if (minMethods > methods2)
minMethods = methods2;
methods2 = methodsStack.pop();
}
@Override
public void endVisit(TypeDeclaration node) {
if (node.isInterface())
return;
if (maxTransient < transient2)
maxTransient = transient2;
if (minTransient > transient2)
minTransient = transient2;
transient2 = transientStack.pop();
if (maxVolatile < volatile2)
maxVolatile = volatile2;
if (minVolatile > volatile2)
minVolatile = volatile2;
volatile2 = volatileStack.pop();
}
@Override
public void endVisit(TypeDeclaration node) {
if (node.isInterface())
return;
classes++;
if (maxStringField < stringField2)
maxStringField = stringField2;
if (minStringField > stringField2)
minStringField = stringField2;
stringField2 = stringFieldStack.pop();
}
@Override
public void endVisit(TypeDeclaration node) {
if (node.isInterface())
return;
if (maxFields < fieds2)
maxFields = fieds2;
if (minFields > fieds2)
minFields = fieds2;
fieds2 = fieldsStack.pop();
}
@Override
public void endVisit(TypeDeclaration node) {
if (node.isInterface())
return;
if (methods2 > 0) {
classes ++;
if (maxMethods < methods2)
maxMethods = methods2;
if (minMethods > methods2)
minMethods = methods2;
}
methods2 = methodsStack.pop();
}
/**
* {@inheritDoc}
*/
@Override
public boolean visit(TypeDeclaration node) {
if (!fFindUnqualifiedStaticAccesses && !fFindUnqualifiedStaticMethodAccesses && node.isInterface())
return false;
return super.visit(node);
}
@Override
public boolean visit(final TypeDeclaration it) {
boolean _isDummyType = this._aSTFlattenerUtils.isDummyType(it);
if (_isDummyType) {
this.visitAll(it.bodyDeclarations(), this.nl());
return false;
}
boolean _isNotSupportedInnerType = this._aSTFlattenerUtils.isNotSupportedInnerType(it);
if (_isNotSupportedInnerType) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("/* FIXME Non-static inner classes are not supported.*/");
this.appendToBuffer(_builder.toString());
this.addProblem(it, "Non-static inner classes are not supported.");
}
Javadoc _javadoc = it.getJavadoc();
boolean _tripleNotEquals = (_javadoc != null);
if (_tripleNotEquals) {
it.getJavadoc().accept(this);
}
this.appendModifiers(it, it.modifiers());
boolean _isInterface = it.isInterface();
if (_isInterface) {
this.appendToBuffer("interface ");
} else {
boolean _isPackageVisibility = this._aSTFlattenerUtils.isPackageVisibility(Iterables.<Modifier>filter(it.modifiers(), Modifier.class));
if (_isPackageVisibility) {
this.appendToBuffer("package ");
}
this.appendToBuffer("class ");
}
it.getName().accept(this);
boolean _isEmpty = it.typeParameters().isEmpty();
boolean _not = (!_isEmpty);
if (_not) {
this.appendTypeParameters(it.typeParameters());
}
this.appendSpaceToBuffer();
Type _superclassType = it.getSuperclassType();
boolean _tripleNotEquals_1 = (_superclassType != null);
if (_tripleNotEquals_1) {
this.appendToBuffer("extends ");
it.getSuperclassType().accept(this);
this.appendSpaceToBuffer();
}
boolean _isEmpty_1 = it.superInterfaceTypes().isEmpty();
boolean _not_1 = (!_isEmpty_1);
if (_not_1) {
boolean _isInterface_1 = it.isInterface();
if (_isInterface_1) {
this.appendToBuffer("extends ");
} else {
this.appendToBuffer("implements ");
}
this.visitAllSeparatedByComma(it.superInterfaceTypes());
}
this.appendToBuffer("{");
this.increaseIndent();
BodyDeclaration prev = null;
List _bodyDeclarations = it.bodyDeclarations();
for (final BodyDeclaration body : ((Iterable<BodyDeclaration>) _bodyDeclarations)) {
{
if ((prev instanceof EnumConstantDeclaration)) {
if ((body instanceof EnumConstantDeclaration)) {
this.appendToBuffer(", ");
} else {
this.appendToBuffer("; ");
}
}
this.appendLineWrapToBuffer();
body.accept(this);
prev = body;
}
}
ASTNode _root = it.getRoot();
if ((_root instanceof CompilationUnit)) {
ASTNode _root_1 = it.getRoot();
final CompilationUnit cu = ((CompilationUnit) _root_1);
final Consumer<Comment> _function = (Comment it_1) -> {
it_1.accept(this);
this.assignedComments.add(it_1);
};
this.unAssignedComments(cu).forEach(_function);
}
this.decreaseIndent();
this.appendLineWrapToBuffer();
this.appendToBuffer("}");
return false;
}
public boolean isNotSupportedInnerType(final TypeDeclaration it) {
return (((!it.isInterface()) && ((it.getParent() instanceof TypeDeclaration) || (it.getParent() instanceof Block))) &&
(!IterableExtensions.<Modifier>exists(Iterables.<Modifier>filter(it.modifiers(), Modifier.class), ((Function1<Modifier, Boolean>) (Modifier it_1) -> {
return Boolean.valueOf(it_1.isStatic());
}))));
}
@Override
public boolean visit(TypeDeclaration changedType) {
if (!changedType.isInterface()) {
return true;
}
ITypeBinding typeBinding = changedType.resolveBinding();
if (typeBinding == null) {
return true;
}
PairedInterfaceValidator validator;
String typeQualifiedName = typeBinding.getQualifiedName();
TypeDeclaration dependentType = null;
String dependentTypeQualifiedName;
if (RemoteServiceUtilities.isSynchronousInterface(typeBinding)) {
dependentTypeQualifiedName = RemoteServiceUtilities.computeAsyncTypeName(typeQualifiedName);
dependentType = JavaASTUtils.findTypeDeclaration(javaProject,
dependentTypeQualifiedName);
validator = synchronousInterfaceValidator;
} else {
validator = asynchronousInterfaceValidator;
dependentTypeQualifiedName = RemoteServiceUtilities.computeSyncTypeName(typeQualifiedName);
if (dependentTypeQualifiedName == null) {
// Not an async interface...
return true;
}
dependentType = JavaASTUtils.findTypeDeclaration(javaProject,
dependentTypeQualifiedName);
}
// Add the type dependency (even if the type doesn't yet resolve)
dependentTypes.add(dependentTypeQualifiedName);
ITypeBinding dependentTypeBinding = null;
if (dependentType != null) {
dependentTypeBinding = dependentType.resolveBinding();
}
problems.addAll(validator.validate(changedType, dependentTypeBinding));
return true;
}
public void write(TypeDeclaration typeDeclaration) {
this.typeDeclaration = typeDeclaration;
// Skip the modifiers and the space/comments following them
skipModifiers(typeDeclaration.modifiers());
skipSpaceAndComments();
// Remember how much the type is indented (typically only nested types are indented), so we can use that in
// determining the "natural" indent for some things inside the type declaration.
typeIndent = getTargetWriter().getCurrColumn();
boolean isInterface = typeDeclaration.isInterface();
@SuppressWarnings("unchecked")
List<TypeParameter> typeParameters = (List<TypeParameter>) typeDeclaration.typeParameters();
boolean isGeneric = !typeParameters.isEmpty();
if (isGeneric) {
write("template ");
//sCPlusPlusASTWriter.writeTypeParameters(typeParameters, true);
write(" ");
}
if (isInterface)
matchAndWrite("interface", "class");
else
matchAndWrite("class");
copySpaceAndComments();
matchAndWrite(typeDeclaration.getName().getIdentifier());
// Skip past the type parameters
if (isGeneric) {
setPosition(ASTUtil.getEndPosition(typeParameters));
skipSpaceAndComments();
match(">");
}
writeSuperClassAndInterfaces();
copySpaceAndComments();
matchAndWrite("{");
copySpaceAndCommentsUntilEOL();
writeln();
// sourceFileWriter.getTargetWriter().incrementByPreferredIndent();
outputSomethingForType = false;
writeNestedTypes();
writeMethods();
writeSuperDefinition();
writeFields();
writeSpaces(typeIndent);
write("};");
setPosition(ASTUtil.getEndPosition(typeDeclaration));
}