Java Code Examples for org.eclipse.jdt.core.dom.TypeDeclaration#isInterface()

The following examples show how to use org.eclipse.jdt.core.dom.TypeDeclaration#isInterface() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ASTFlattenerUtils.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
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));
  })));
}
 
Example 2
Source File: UiBinderJavaValidator.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 3
Source File: UiBinderJavaValidator.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 4
Source File: ClientBundleValidator.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
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;
}
 
Example 5
Source File: JavaASTVisitor.java    From SnowGraph with Apache License 2.0 5 votes vote down vote up
@Override
public boolean visit(TypeDeclaration node) {
    if (node.isInterface())
        return visitInterface(node);
    else
        return visitClass(node);
}
 
Example 6
Source File: CodeStyleFix.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public boolean visit(TypeDeclaration node) {
	if (!fFindUnqualifiedStaticAccesses && !fFindUnqualifiedStaticMethodAccesses && node.isInterface())
		return false;

	return super.visit(node);
}
 
Example 7
Source File: TestQ15.java    From compiler with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example 8
Source File: TestQ16.java    From compiler with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example 9
Source File: TestQ19.java    From compiler with Apache License 2.0 5 votes vote down vote up
@Override
public void endVisit(TypeDeclaration node) {
	if (node.isInterface())
		return;
	classes++;
	if (maxFields < fieds2)
		maxFields = fieds2;
	if (minFields > fieds2)
		minFields = fieds2;
	fieds2 = fieldsStack.pop();
}
 
Example 10
Source File: TestQ13.java    From compiler with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 11
Source File: TestQ10.java    From compiler with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example 12
Source File: Testq12.java    From compiler with Apache License 2.0 5 votes vote down vote up
@Override
public void endVisit(TypeDeclaration node) {
	if (node.isInterface())
		return;
		classes++;
	if (maxMethods < methods2)
		maxMethods = methods2;
	if (minMethods > methods2)
		minMethods = methods2;
	methods2 = methodsStack.pop();
}
 
Example 13
Source File: TestQ20.java    From compiler with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example 14
Source File: TestQ22.java    From compiler with Apache License 2.0 5 votes vote down vote up
@Override
public void endVisit(TypeDeclaration node) {
	if (node.isInterface())
		return;
	classes++;
	if (maxStringField < stringField2)
		maxStringField = stringField2;
	if (minStringField > stringField2)
		minStringField = stringField2;
	stringField2 = stringFieldStack.pop();
}
 
Example 15
Source File: TestQ21.java    From compiler with Apache License 2.0 5 votes vote down vote up
@Override
public void endVisit(TypeDeclaration node) {
	if (node.isInterface())
		return;
	if (maxFields < fieds2)
		maxFields = fieds2;
	if (minFields > fieds2)
		minFields = fieds2;
	fieds2 = fieldsStack.pop();
}
 
Example 16
Source File: HeaderTypeDeclarationWriter.java    From juniversal with MIT License 4 votes vote down vote up
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));
}
 
Example 17
Source File: RemoteServiceValidator.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 4 votes vote down vote up
@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;
}
 
Example 18
Source File: ASTFlattenerUtils.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
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());
    }))));
}
 
Example 19
Source File: JavaASTFlattener.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@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;
}