org.eclipse.jdt.core.dom.SuperConstructorInvocation Java Examples

The following examples show how to use org.eclipse.jdt.core.dom.SuperConstructorInvocation. 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: Invocations.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 7 votes vote down vote up
public static Expression getExpression(ASTNode invocation) {
	switch (invocation.getNodeType()) {
		case ASTNode.METHOD_INVOCATION:
			return ((MethodInvocation)invocation).getExpression();
		case ASTNode.SUPER_METHOD_INVOCATION:
			return null;
			
		case ASTNode.CONSTRUCTOR_INVOCATION:
			return null;
		case ASTNode.SUPER_CONSTRUCTOR_INVOCATION:
			return ((SuperConstructorInvocation)invocation).getExpression();
			
		case ASTNode.CLASS_INSTANCE_CREATION:
			return ((ClassInstanceCreation)invocation).getExpression();
		case ASTNode.ENUM_CONSTANT_DECLARATION:
			return null;
			
		default:
			throw new IllegalArgumentException(invocation.toString());
	}
}
 
Example #2
Source File: StyledStringVisitor.java    From JDeodorant with MIT License 6 votes vote down vote up
public boolean visit(SuperConstructorInvocation stmnt){
	/*
	 * [ Expression . ]
        [ < Type { , Type } > ]
        super ( [ Expression { , Expression } ] ) ;
	 */
	if (stmnt.getExpression() != null){
		handleExpression((Expression) stmnt.getExpression());
		appendPeriod();
	}
	handleTypeArguments(stmnt.typeArguments());
	styledString.append("super", new StyledStringStyler(keywordStyle));
	handleParameters(stmnt.arguments());
	appendSemicolon();
	return false;
}
 
Example #3
Source File: CodeBlock.java    From SimFix with GNU General Public License v2.0 6 votes vote down vote up
private SuperConstructorInv visit(SuperConstructorInvocation node) {
	int startLine = _cunit.getLineNumber(node.getStartPosition());
	int endLine = _cunit.getLineNumber(node.getStartPosition() + node.getLength());
	SuperConstructorInv superConstructorInv = new SuperConstructorInv(startLine, endLine, node);

	if(node.getExpression() != null){
		Expr expression = (Expr) process(node.getExpression());
		expression.setParent(superConstructorInv);
		superConstructorInv.setExpression(expression);
	}
	
	List<Expr> arguments = new ArrayList<>();
	for(Object object : node.arguments()){
		Expr arg = (Expr) process((ASTNode) object);
		arg.setParent(superConstructorInv);
		arguments.add(arg);
	}
	superConstructorInv.setArguments(arguments);
	
	return superConstructorInv;
}
 
Example #4
Source File: ConstructorFromSuperclassProposal.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
private SuperConstructorInvocation addEnclosingInstanceAccess(ASTRewrite rewrite, ImportRewriteContext importRewriteContext, List<SingleVariableDeclaration> parameters, String[] paramNames, ITypeBinding enclosingInstance) {
	AST ast= rewrite.getAST();
	SuperConstructorInvocation invocation= ast.newSuperConstructorInvocation();

	SingleVariableDeclaration var= ast.newSingleVariableDeclaration();
	var.setType(getImportRewrite().addImport(enclosingInstance, ast, importRewriteContext, TypeLocation.PARAMETER));
	String[] enclosingArgNames= StubUtility.getArgumentNameSuggestions(getCompilationUnit().getJavaProject(), enclosingInstance.getTypeDeclaration().getName(), 0, paramNames);
	String firstName= enclosingArgNames[0];
	var.setName(ast.newSimpleName(firstName));
	parameters.add(var);

	Name enclosing= ast.newSimpleName(firstName);
	invocation.setExpression(enclosing);

	String key= "arg_name_" + firstName; //$NON-NLS-1$
	addLinkedPosition(rewrite.track(enclosing), false, key);
	for (int i= 0; i < enclosingArgNames.length; i++) {
		addLinkedPositionProposal(key, enclosingArgNames[i]); // alternative names
	}
	return invocation;
}
 
Example #5
Source File: JavaASTFlattener.java    From xtext-xtend with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public boolean visit(final SuperConstructorInvocation node) {
  Expression _expression = node.getExpression();
  boolean _tripleNotEquals = (_expression != null);
  if (_tripleNotEquals) {
    node.getExpression().accept(this);
    this.appendToBuffer(".");
  }
  boolean _isEmpty = node.typeArguments().isEmpty();
  boolean _not = (!_isEmpty);
  if (_not) {
    this.appendTypeParameters(node.typeArguments());
  }
  this.appendToBuffer("super(");
  this.visitAllSeparatedByComma(node.arguments());
  this.appendToBuffer(")");
  return false;
}
 
Example #6
Source File: ChangeSignatureProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private void addNewConstructorToSubclass(AbstractTypeDeclaration subclass, CompilationUnitRewrite cuRewrite) {
	AST ast= subclass.getAST();
	MethodDeclaration newConstructor= ast.newMethodDeclaration();
	newConstructor.setName(ast.newSimpleName(subclass.getName().getIdentifier()));
	newConstructor.setConstructor(true);
	newConstructor.setJavadoc(null);
	newConstructor.modifiers().addAll(ASTNodeFactory.newModifiers(ast, getAccessModifier(subclass)));
	newConstructor.setReturnType2(ast.newPrimitiveType(PrimitiveType.VOID));
	Block body= ast.newBlock();
	newConstructor.setBody(body);
	SuperConstructorInvocation superCall= ast.newSuperConstructorInvocation();
	addArgumentsToNewSuperConstructorCall(superCall, cuRewrite);
	body.statements().add(superCall);

	String msg= RefactoringCoreMessages.ChangeSignatureRefactoring_add_constructor;
	TextEditGroup description= cuRewrite.createGroupDescription(msg);
	cuRewrite.getASTRewrite().getListRewrite(subclass, subclass.getBodyDeclarationsProperty()).insertFirst(newConstructor, description);

	// TODO use AbstractTypeDeclaration
}
 
Example #7
Source File: Invocations.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public static List<Expression> getArguments(ASTNode invocation) {
	switch (invocation.getNodeType()) {
		case ASTNode.METHOD_INVOCATION:
			return ((MethodInvocation)invocation).arguments();
		case ASTNode.SUPER_METHOD_INVOCATION:
			return ((SuperMethodInvocation)invocation).arguments();
			
		case ASTNode.CONSTRUCTOR_INVOCATION:
			return ((ConstructorInvocation)invocation).arguments();
		case ASTNode.SUPER_CONSTRUCTOR_INVOCATION:
			return ((SuperConstructorInvocation)invocation).arguments();
			
		case ASTNode.CLASS_INSTANCE_CREATION:
			return ((ClassInstanceCreation)invocation).arguments();
		case ASTNode.ENUM_CONSTANT_DECLARATION:
			return ((EnumConstantDeclaration)invocation).arguments();
			
		default:
			throw new IllegalArgumentException(invocation.toString());
	}
}
 
Example #8
Source File: Invocations.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public static ChildListPropertyDescriptor getArgumentsProperty(ASTNode invocation) {
	switch (invocation.getNodeType()) {
		case ASTNode.METHOD_INVOCATION:
			return MethodInvocation.ARGUMENTS_PROPERTY;
		case ASTNode.SUPER_METHOD_INVOCATION:
			return SuperMethodInvocation.ARGUMENTS_PROPERTY;
			
		case ASTNode.CONSTRUCTOR_INVOCATION:
			return ConstructorInvocation.ARGUMENTS_PROPERTY;
		case ASTNode.SUPER_CONSTRUCTOR_INVOCATION:
			return SuperConstructorInvocation.ARGUMENTS_PROPERTY;
			
		case ASTNode.CLASS_INSTANCE_CREATION:
			return ClassInstanceCreation.ARGUMENTS_PROPERTY;
		case ASTNode.ENUM_CONSTANT_DECLARATION:
			return EnumConstantDeclaration.ARGUMENTS_PROPERTY;
			
		default:
			throw new IllegalArgumentException(invocation.toString());
	}
}
 
Example #9
Source File: Invocations.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public static IMethodBinding resolveBinding(ASTNode invocation) {
	switch (invocation.getNodeType()) {
		case ASTNode.METHOD_INVOCATION:
			return ((MethodInvocation)invocation).resolveMethodBinding();
		case ASTNode.SUPER_METHOD_INVOCATION:
			return ((SuperMethodInvocation)invocation).resolveMethodBinding();
			
		case ASTNode.CONSTRUCTOR_INVOCATION:
			return ((ConstructorInvocation)invocation).resolveConstructorBinding();
		case ASTNode.SUPER_CONSTRUCTOR_INVOCATION:
			return ((SuperConstructorInvocation)invocation).resolveConstructorBinding();
			
		case ASTNode.CLASS_INSTANCE_CREATION:
			return ((ClassInstanceCreation)invocation).resolveConstructorBinding();
		case ASTNode.ENUM_CONSTANT_DECLARATION:
			return ((EnumConstantDeclaration)invocation).resolveConstructorBinding();
			
		default:
			throw new IllegalArgumentException(invocation.toString());
	}
}
 
Example #10
Source File: JavadocHover.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static IBinding resolveBinding(ASTNode node) {
	if (node instanceof SimpleName) {
		SimpleName simpleName= (SimpleName) node;
		// workaround for https://bugs.eclipse.org/62605 (constructor name resolves to type, not method)
		ASTNode normalized= ASTNodes.getNormalizedNode(simpleName);
		if (normalized.getLocationInParent() == ClassInstanceCreation.TYPE_PROPERTY) {
			ClassInstanceCreation cic= (ClassInstanceCreation) normalized.getParent();
			IMethodBinding constructorBinding= cic.resolveConstructorBinding();
			if (constructorBinding == null)
				return null;
			ITypeBinding declaringClass= constructorBinding.getDeclaringClass();
			if (!declaringClass.isAnonymous())
				return constructorBinding;
			ITypeBinding superTypeDeclaration= declaringClass.getSuperclass().getTypeDeclaration();
			return resolveSuperclassConstructor(superTypeDeclaration, constructorBinding);
		}
		return simpleName.resolveBinding();
		
	} else if (node instanceof SuperConstructorInvocation) {
		return ((SuperConstructorInvocation) node).resolveConstructorBinding();
	} else if (node instanceof ConstructorInvocation) {
		return ((ConstructorInvocation) node).resolveConstructorBinding();
	} else {
		return null;
	}
}
 
Example #11
Source File: ConstructorFromSuperclassProposal.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private SuperConstructorInvocation addEnclosingInstanceAccess(ASTRewrite rewrite, ImportRewriteContext importRewriteContext, List<SingleVariableDeclaration> parameters, String[] paramNames, ITypeBinding enclosingInstance) {
	AST ast= rewrite.getAST();
	SuperConstructorInvocation invocation= ast.newSuperConstructorInvocation();

	SingleVariableDeclaration var= ast.newSingleVariableDeclaration();
	var.setType(getImportRewrite().addImport(enclosingInstance, ast, importRewriteContext));
	String[] enclosingArgNames= StubUtility.getArgumentNameSuggestions(getCompilationUnit().getJavaProject(), enclosingInstance.getTypeDeclaration().getName(), 0, paramNames);
	String firstName= enclosingArgNames[0];
	var.setName(ast.newSimpleName(firstName));
	parameters.add(var);

	Name enclosing= ast.newSimpleName(firstName);
	invocation.setExpression(enclosing);

	String key= "arg_name_" + firstName; //$NON-NLS-1$
	addLinkedPosition(rewrite.track(enclosing), false, key);
	for (int i= 0; i < enclosingArgNames.length; i++) {
		addLinkedPositionProposal(key, enclosingArgNames[i], null); // alternative names
	}
	return invocation;
}
 
Example #12
Source File: MoveInnerToTopRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private boolean isInsideTypeNestedInDeclaringType(ASTNode node) {
	Assert.isTrue((node instanceof ClassInstanceCreation) || (node instanceof SuperConstructorInvocation));
	final AbstractTypeDeclaration declaration= (AbstractTypeDeclaration) ASTNodes.getParent(node, AbstractTypeDeclaration.class);
	Assert.isNotNull(declaration);
	ITypeBinding enclosing= declaration.resolveBinding();
	while (enclosing != null) {
		if (isCorrespondingTypeBinding(enclosing, fType.getDeclaringType()))
			return true;
		enclosing= enclosing.getDeclaringClass();
	}
	return false;
}
 
Example #13
Source File: ChangeSignatureProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private boolean isRecursiveReference() {
	MethodDeclaration enclosingMethodDeclaration= (MethodDeclaration) ASTNodes.getParent(fNode, MethodDeclaration.class);
	if (enclosingMethodDeclaration == null)
		return false;

	IMethodBinding enclosingMethodBinding= enclosingMethodDeclaration.resolveBinding();
	if (enclosingMethodBinding == null)
		return false;

	if (fNode instanceof MethodInvocation)
		return enclosingMethodBinding == ((MethodInvocation)fNode).resolveMethodBinding();

	if (fNode instanceof SuperMethodInvocation) {
		IMethodBinding methodBinding= ((SuperMethodInvocation)fNode).resolveMethodBinding();
		return isSameMethod(methodBinding, enclosingMethodBinding);
	}

	if (fNode instanceof ClassInstanceCreation)
		return enclosingMethodBinding == ((ClassInstanceCreation)fNode).resolveConstructorBinding();

	if (fNode instanceof ConstructorInvocation)
		return enclosingMethodBinding == ((ConstructorInvocation)fNode).resolveConstructorBinding();

	if (fNode instanceof SuperConstructorInvocation) {
		return false; //Constructors don't override -> enclosing has not been changed -> no recursion
	}

	if (fNode instanceof EnumConstantDeclaration) {
		return false; //cannot define enum constant inside enum constructor
	}

	Assert.isTrue(false);
	return false;
}
 
Example #14
Source File: ASTNodeSearchUtil.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public static ASTNode getAstNode(CompilationUnit cuNode, int start, int length){
	SelectionAnalyzer analyzer= new SelectionAnalyzer(Selection.createFromStartLength(start, length), true);
	cuNode.accept(analyzer);
	//XXX workaround for jdt core feature 23527
	ASTNode node= analyzer.getFirstSelectedNode();
	if (node == null && analyzer.getLastCoveringNode() instanceof SuperConstructorInvocation)
		node= analyzer.getLastCoveringNode().getParent();
	else if (node == null && analyzer.getLastCoveringNode() instanceof ConstructorInvocation)
		node= analyzer.getLastCoveringNode().getParent();

	if (node == null)
		return null;

	ASTNode parentNode= node.getParent();

	if (parentNode instanceof MethodDeclaration){
		MethodDeclaration md= (MethodDeclaration)parentNode;
		if (!(node instanceof SimpleName)
			&& md.isConstructor()
		    && md.getBody() != null
		    && md.getBody().statements().size() > 0
		    &&(md.getBody().statements().get(0) instanceof ConstructorInvocation || md.getBody().statements().get(0) instanceof SuperConstructorInvocation)
		    &&((ASTNode)md.getBody().statements().get(0)).getLength() == length + 1)
		return (ASTNode)md.getBody().statements().get(0);
	}

	if (parentNode instanceof SuperConstructorInvocation){
		if (parentNode.getLength() == length + 1)
			return parentNode;
	}
	if (parentNode instanceof ConstructorInvocation){
		if (parentNode.getLength() == length + 1)
			return parentNode;
	}
	return node;
}
 
Example #15
Source File: SourceAnalyzer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean visit(SuperConstructorInvocation node) {
	if (fTypeCounter == 0) {
		fHasSuperMethodInvocation= true;
	}
	return true;
}
 
Example #16
Source File: ExtractTempRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private boolean isUsedInExplicitConstructorCall() throws JavaModelException {
	Expression selectedExpression= getSelectedExpression().getAssociatedExpression();
	if (ASTNodes.getParent(selectedExpression, ConstructorInvocation.class) != null)
		return true;
	if (ASTNodes.getParent(selectedExpression, SuperConstructorInvocation.class) != null)
		return true;
	return false;
}
 
Example #17
Source File: JDTUtils.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
private static IBinding resolveBinding(ASTNode node) {
	if (node instanceof SimpleName) {
		SimpleName simpleName = (SimpleName) node;
		// workaround for https://bugs.eclipse.org/62605 (constructor name resolves to type, not method)
		ASTNode normalized = ASTNodes.getNormalizedNode(simpleName);
		if (normalized.getLocationInParent() == ClassInstanceCreation.TYPE_PROPERTY) {
			ClassInstanceCreation cic = (ClassInstanceCreation) normalized.getParent();
			IMethodBinding constructorBinding = cic.resolveConstructorBinding();
			if (constructorBinding == null) {
				return null;
			}
			ITypeBinding declaringClass = constructorBinding.getDeclaringClass();
			if (!declaringClass.isAnonymous()) {
				return constructorBinding;
			}
			ITypeBinding superTypeDeclaration = declaringClass.getSuperclass().getTypeDeclaration();
			return resolveSuperclassConstructor(superTypeDeclaration, constructorBinding);
		}
		return simpleName.resolveBinding();

	} else if (node instanceof SuperConstructorInvocation) {
		return ((SuperConstructorInvocation) node).resolveConstructorBinding();
	} else if (node instanceof ConstructorInvocation) {
		return ((ConstructorInvocation) node).resolveConstructorBinding();
	} else if (node instanceof LambdaExpression) {
		return ((LambdaExpression) node).resolveMethodBinding();
	} else {
		return null;
	}
}
 
Example #18
Source File: ExceptionAnalyzer.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public boolean visit(SuperConstructorInvocation node) {
	if (!isSelected(node)) {
		return false;
	}
	return handleExceptions(node.resolveConstructorBinding(), node);
}
 
Example #19
Source File: FullConstraintCreator.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public ITypeConstraint[] create(SuperConstructorInvocation invocation){
	List<Expression> arguments= invocation.arguments();
	List<ITypeConstraint> result= new ArrayList<ITypeConstraint>(arguments.size());
	IMethodBinding methodBinding= invocation.resolveConstructorBinding();
	result.addAll(Arrays.asList(getArgumentConstraints(arguments, methodBinding)));
	return result.toArray(new ITypeConstraint[result.size()]);
}
 
Example #20
Source File: SurroundWithAnalyzer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void endVisit(SuperConstructorInvocation node) {
	if (getSelection().getEndVisitSelectionMode(node) == Selection.SELECTED) {
		invalidSelection(RefactoringCoreMessages.SurroundWithTryCatchAnalyzer_cannotHandleSuper, JavaStatusContext.create(fCUnit, node));
	}
	super.endVisit(node);
}
 
Example #21
Source File: CalleeAnalyzerVisitor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
    * Find invocations of the supertype's constructor from the called method
    * (=constructor). Since we only traverse into the AST on the wanted method
    * declaration, this method should not hit on more method invocations than those in
    * the wanted method.
    *
    * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.SuperConstructorInvocation)
    */
   @Override
public boolean visit(SuperConstructorInvocation node) {
       progressMonitorWorked(1);
       if (!isFurtherTraversalNecessary(node)) {
           return false;
       }

       if (isNodeWithinMethod(node)) {
           addMethodCall(node.resolveConstructorBinding(), node);
       }

       return true;
   }
 
Example #22
Source File: ImportReferencesCollector.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean visit(SuperConstructorInvocation node) {
	if (!isAffected(node)) {
		return false;
	}

	evalQualifyingExpression(node.getExpression(), null);
	doVisitChildren(node.typeArguments());
	doVisitChildren(node.arguments());
	return false;
}
 
Example #23
Source File: ExceptionOccurrencesFinder.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean visit(SuperConstructorInvocation node) {
	if (matches(node.resolveConstructorBinding())) {
		// mark 'super'
		fResult.add(new OccurrenceLocation(node.getStartPosition(), 5, 0, fDescription));
	}
	return super.visit(node);
}
 
Example #24
Source File: MethodExitsFinder.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean visit(SuperConstructorInvocation node) {
	if (isExitPoint(node.resolveConstructorBinding())) {
		// mark 'super'
		fResult.add(new OccurrenceLocation(node.getStartPosition(), 5, 0, fExitDescription));
	}
	return true;
}
 
Example #25
Source File: SemanticHighlightingReconciler.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean visit(SuperConstructorInvocation node) {
	// XXX Hack for performance reasons (should loop over fJobSemanticHighlightings can call consumes(*))
	if (fJobDeprecatedMemberHighlighting != null) {
		IMethodBinding constructorBinding= node.resolveConstructorBinding();
		if (constructorBinding != null && constructorBinding.isDeprecated()) {
			int offset= node.getStartPosition();
			int length= 5;
			if (offset > -1 && length > 0)
				addPosition(offset, length, fJobDeprecatedMemberHighlighting);
		}
	}
	return true;
}
 
Example #26
Source File: ASTResolving.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public static boolean isInsideConstructorInvocation(MethodDeclaration methodDeclaration, ASTNode node) {
	if (methodDeclaration.isConstructor()) {
		Statement statement= ASTResolving.findParentStatement(node);
		if (statement instanceof ConstructorInvocation || statement instanceof SuperConstructorInvocation) {
			return true; // argument in a this or super call
		}
	}
	return false;
}
 
Example #27
Source File: AdvancedQuickAssistProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static Expression getBooleanExpression(ASTNode node) {
	if (!(node instanceof Expression)) {
		return null;
	}

	// check if the node is a location where it can be negated
	StructuralPropertyDescriptor locationInParent= node.getLocationInParent();
	if (locationInParent == QualifiedName.NAME_PROPERTY) {
		node= node.getParent();
		locationInParent= node.getLocationInParent();
	}
	while (locationInParent == ParenthesizedExpression.EXPRESSION_PROPERTY) {
		node= node.getParent();
		locationInParent= node.getLocationInParent();
	}
	Expression expression= (Expression) node;
	if (!isBoolean(expression)) {
		return null;
	}
	if (expression.getParent() instanceof InfixExpression) {
		return expression;
	}
	if (locationInParent == Assignment.RIGHT_HAND_SIDE_PROPERTY || locationInParent == IfStatement.EXPRESSION_PROPERTY
			|| locationInParent == WhileStatement.EXPRESSION_PROPERTY || locationInParent == DoStatement.EXPRESSION_PROPERTY
			|| locationInParent == ReturnStatement.EXPRESSION_PROPERTY || locationInParent == ForStatement.EXPRESSION_PROPERTY
			|| locationInParent == AssertStatement.EXPRESSION_PROPERTY || locationInParent == MethodInvocation.ARGUMENTS_PROPERTY
			|| locationInParent == ConstructorInvocation.ARGUMENTS_PROPERTY || locationInParent == SuperMethodInvocation.ARGUMENTS_PROPERTY
			|| locationInParent == EnumConstantDeclaration.ARGUMENTS_PROPERTY || locationInParent == SuperConstructorInvocation.ARGUMENTS_PROPERTY
			|| locationInParent == ClassInstanceCreation.ARGUMENTS_PROPERTY || locationInParent == ConditionalExpression.EXPRESSION_PROPERTY
			|| locationInParent == PrefixExpression.OPERAND_PROPERTY) {
		return expression;
	}
	return null;
}
 
Example #28
Source File: PrivateConstructorBodyCreationFragment.java    From SparkBuilderGenerator with MIT License 5 votes vote down vote up
private void populateBodyWithSuperConstructorCall(AST ast, TypeDeclaration builderType, Block body, List<ConstructorParameterSetterBuilderField> builderFields) {
    SuperConstructorInvocation superInvocation = ast.newSuperConstructorInvocation();
    builderFields.stream()
            .sorted((first, second) -> first.getIndex().compareTo(second.getIndex()))
            .forEach(constructorParameter -> addConstructorParameter(ast, builderType, superInvocation, constructorParameter));

    if (!builderFields.isEmpty()) {
        body.statements().add(superInvocation);
    }
}
 
Example #29
Source File: CodeSearch.java    From SimFix with GNU General Public License v2.0 5 votes vote down vote up
public boolean visit(SuperConstructorInvocation node) {
	int start = _unit.getLineNumber(node.getStartPosition());
	if(start == _extendedLine){
		_extendedStatement = node;
		return false;
	}
	return true;
}
 
Example #30
Source File: SemanticHighlightingReconciler.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public boolean visit(SuperConstructorInvocation node) {
	// XXX Hack for performance reasons (should loop over fJobSemanticHighlightings can call consumes(*))
	if (fJobDeprecatedMemberHighlighting != null) {
		IMethodBinding constructorBinding= node.resolveConstructorBinding();
		if (constructorBinding != null && constructorBinding.isDeprecated()) {
			int offset= node.getStartPosition();
			int length= 5;
			if (offset > -1 && length > 0) {
				addPosition(offset, length, fJobDeprecatedMemberHighlighting);
			}
		}
	}
	return true;
}