Java 类org.eclipse.jdt.core.dom.ConstructorInvocation 实例源码
项目:che
文件:Invocations.java
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());
}
}
项目:RefDiff
文件:ASTVisitorAtomicChange.java
public boolean visit(ConstructorInvocation node) {
IMethodBinding mmtb = node.resolveConstructorBinding();
if (mtbStack.isEmpty()) // not part of a method
return true;
// make field access fact
try {
facts.add(Fact.makeCallsFact(getQualifiedName(mtbStack.peek()),
getQualifiedName(mmtb)));
} catch (Exception e) {
System.err.println("Cannot resolve constructor invocation in \""
+ "\"");
}
return true;
}
项目:Ref-Finder
文件:ASTVisitorAtomicChange.java
public boolean visit(ConstructorInvocation node)
{
IMethodBinding mmtb = node.resolveConstructorBinding();
if (this.mtbStack.isEmpty()) {
return true;
}
try
{
this.facts.add(Fact.makeCallsFact(getQualifiedName((IMethodBinding)this.mtbStack.peek()),
getQualifiedName(mmtb)));
}
catch (Exception e)
{
System.err.println("Cannot resolve constructor invocation in \"\"");
}
return true;
}
项目:Ref-Finder
文件:ASTVisitorAtomicChange.java
public boolean visit(ConstructorInvocation node) {
IMethodBinding mmtb = node.resolveConstructorBinding();
if (mtbStack.isEmpty()) // not part of a method
return true;
// make field access fact
try {
facts.add(Fact.makeCallsFact(getQualifiedName(mtbStack.peek()),
getQualifiedName(mmtb)));
} catch (Exception e) {
System.err.println("Cannot resolve constructor invocation in \""
+ "\"");
}
return true;
}
项目:Ref-Finder
文件:ASTVisitorAtomicChange.java
public boolean visit(ConstructorInvocation node)
{
IMethodBinding mmtb = node.resolveConstructorBinding();
if (this.mtbStack.isEmpty()) {
return true;
}
try
{
this.facts.add(Fact.makeCallsFact(getQualifiedName((IMethodBinding)this.mtbStack.peek()),
getQualifiedName(mmtb)));
}
catch (Exception localException)
{
System.err.println("Cannot resolve constructor invocation in \"\"");
}
return true;
}
项目:che
文件:Invocations.java
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());
}
}
项目:che
文件:Invocations.java
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());
}
}
项目:che
文件:InlineMethodRefactoring.java
/**
* Creates a new inline method refactoring
*
* @param unit the compilation unit or class file
* @param node the compilation unit node
* @param selectionStart start
* @param selectionLength length
* @return returns the refactoring
*/
public static InlineMethodRefactoring create(
ITypeRoot unit, CompilationUnit node, int selectionStart, int selectionLength) {
ASTNode target =
RefactoringAvailabilityTester.getInlineableMethodNode(
unit, node, selectionStart, selectionLength);
if (target == null) return null;
if (target.getNodeType() == ASTNode.METHOD_DECLARATION) {
return new InlineMethodRefactoring(
unit, (MethodDeclaration) target, selectionStart, selectionLength);
} else {
ICompilationUnit cu = (ICompilationUnit) unit;
if (target.getNodeType() == ASTNode.METHOD_INVOCATION) {
return new InlineMethodRefactoring(
cu, (MethodInvocation) target, selectionStart, selectionLength);
} else if (target.getNodeType() == ASTNode.SUPER_METHOD_INVOCATION) {
return new InlineMethodRefactoring(
cu, (SuperMethodInvocation) target, selectionStart, selectionLength);
} else if (target.getNodeType() == ASTNode.CONSTRUCTOR_INVOCATION) {
return new InlineMethodRefactoring(
cu, (ConstructorInvocation) target, selectionStart, selectionLength);
}
}
return null;
}
项目:che
文件:InlineMethodRefactoring.java
public RefactoringStatus setCurrentMode(Mode mode) throws JavaModelException {
if (fCurrentMode == mode) return new RefactoringStatus();
Assert.isTrue(getInitialMode() == Mode.INLINE_SINGLE);
fCurrentMode = mode;
if (mode == Mode.INLINE_SINGLE) {
if (fInitialNode instanceof MethodInvocation)
fTargetProvider =
TargetProvider.create(
(ICompilationUnit) fInitialTypeRoot, (MethodInvocation) fInitialNode);
else if (fInitialNode instanceof SuperMethodInvocation)
fTargetProvider =
TargetProvider.create(
(ICompilationUnit) fInitialTypeRoot, (SuperMethodInvocation) fInitialNode);
else if (fInitialNode instanceof ConstructorInvocation)
fTargetProvider =
TargetProvider.create(
(ICompilationUnit) fInitialTypeRoot, (ConstructorInvocation) fInitialNode);
else throw new IllegalStateException(String.valueOf(fInitialNode));
} else {
fTargetProvider = TargetProvider.create(fSourceProvider.getDeclaration());
}
return fTargetProvider.checkActivation();
}
项目:che
文件:JavadocFinder.java
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;
}
}
项目:Eclipse-Postfix-Code-Completion
文件:Invocations.java
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());
}
}
项目:Eclipse-Postfix-Code-Completion
文件:Invocations.java
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());
}
}
项目:Eclipse-Postfix-Code-Completion
文件:Invocations.java
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());
}
}
项目:Eclipse-Postfix-Code-Completion
文件:InlineMethodRefactoring.java
/**
* Creates a new inline method refactoring
* @param unit the compilation unit or class file
* @param node the compilation unit node
* @param selectionStart start
* @param selectionLength length
* @return returns the refactoring
*/
public static InlineMethodRefactoring create(ITypeRoot unit, CompilationUnit node, int selectionStart, int selectionLength) {
ASTNode target= RefactoringAvailabilityTester.getInlineableMethodNode(unit, node, selectionStart, selectionLength);
if (target == null)
return null;
if (target.getNodeType() == ASTNode.METHOD_DECLARATION) {
return new InlineMethodRefactoring(unit, (MethodDeclaration)target, selectionStart, selectionLength);
} else {
ICompilationUnit cu= (ICompilationUnit) unit;
if (target.getNodeType() == ASTNode.METHOD_INVOCATION) {
return new InlineMethodRefactoring(cu, (MethodInvocation)target, selectionStart, selectionLength);
} else if (target.getNodeType() == ASTNode.SUPER_METHOD_INVOCATION) {
return new InlineMethodRefactoring(cu, (SuperMethodInvocation)target, selectionStart, selectionLength);
} else if (target.getNodeType() == ASTNode.CONSTRUCTOR_INVOCATION) {
return new InlineMethodRefactoring(cu, (ConstructorInvocation)target, selectionStart, selectionLength);
}
}
return null;
}
项目:Eclipse-Postfix-Code-Completion
文件:InlineMethodRefactoring.java
public RefactoringStatus setCurrentMode(Mode mode) throws JavaModelException {
if (fCurrentMode == mode)
return new RefactoringStatus();
Assert.isTrue(getInitialMode() == Mode.INLINE_SINGLE);
fCurrentMode= mode;
if (mode == Mode.INLINE_SINGLE) {
if (fInitialNode instanceof MethodInvocation)
fTargetProvider= TargetProvider.create((ICompilationUnit) fInitialTypeRoot, (MethodInvocation)fInitialNode);
else if (fInitialNode instanceof SuperMethodInvocation)
fTargetProvider= TargetProvider.create((ICompilationUnit) fInitialTypeRoot, (SuperMethodInvocation)fInitialNode);
else if (fInitialNode instanceof ConstructorInvocation)
fTargetProvider= TargetProvider.create((ICompilationUnit) fInitialTypeRoot, (ConstructorInvocation)fInitialNode);
else
throw new IllegalStateException(String.valueOf(fInitialNode));
} else {
fTargetProvider= TargetProvider.create(fSourceProvider.getDeclaration());
}
return fTargetProvider.checkActivation();
}
项目:Eclipse-Postfix-Code-Completion
文件:JavadocHover.java
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;
}
}
项目:Eclipse-Postfix-Code-Completion-Juno38
文件:Invocations.java
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());
}
}
项目:Eclipse-Postfix-Code-Completion-Juno38
文件:Invocations.java
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());
}
}
项目:Eclipse-Postfix-Code-Completion-Juno38
文件:Invocations.java
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());
}
}
项目:Eclipse-Postfix-Code-Completion-Juno38
文件:InlineMethodRefactoring.java
/**
* Creates a new inline method refactoring
* @param unit the compilation unit or class file
* @param node the compilation unit node
* @param selectionStart start
* @param selectionLength length
* @return returns the refactoring
*/
public static InlineMethodRefactoring create(ITypeRoot unit, CompilationUnit node, int selectionStart, int selectionLength) {
ASTNode target= RefactoringAvailabilityTester.getInlineableMethodNode(unit, node, selectionStart, selectionLength);
if (target == null)
return null;
if (target.getNodeType() == ASTNode.METHOD_DECLARATION) {
return new InlineMethodRefactoring(unit, (MethodDeclaration)target, selectionStart, selectionLength);
} else {
ICompilationUnit cu= (ICompilationUnit) unit;
if (target.getNodeType() == ASTNode.METHOD_INVOCATION) {
return new InlineMethodRefactoring(cu, (MethodInvocation)target, selectionStart, selectionLength);
} else if (target.getNodeType() == ASTNode.SUPER_METHOD_INVOCATION) {
return new InlineMethodRefactoring(cu, (SuperMethodInvocation)target, selectionStart, selectionLength);
} else if (target.getNodeType() == ASTNode.CONSTRUCTOR_INVOCATION) {
return new InlineMethodRefactoring(cu, (ConstructorInvocation)target, selectionStart, selectionLength);
}
}
return null;
}
项目:Eclipse-Postfix-Code-Completion-Juno38
文件:InlineMethodRefactoring.java
public RefactoringStatus setCurrentMode(Mode mode) throws JavaModelException {
if (fCurrentMode == mode)
return new RefactoringStatus();
Assert.isTrue(getInitialMode() == Mode.INLINE_SINGLE);
fCurrentMode= mode;
if (mode == Mode.INLINE_SINGLE) {
if (fInitialNode instanceof MethodInvocation)
fTargetProvider= TargetProvider.create((ICompilationUnit) fInitialTypeRoot, (MethodInvocation)fInitialNode);
else if (fInitialNode instanceof SuperMethodInvocation)
fTargetProvider= TargetProvider.create((ICompilationUnit) fInitialTypeRoot, (SuperMethodInvocation)fInitialNode);
else if (fInitialNode instanceof ConstructorInvocation)
fTargetProvider= TargetProvider.create((ICompilationUnit) fInitialTypeRoot, (ConstructorInvocation)fInitialNode);
else
throw new IllegalStateException(String.valueOf(fInitialNode));
} else {
fTargetProvider= TargetProvider.create(fSourceProvider.getDeclaration());
}
return fTargetProvider.checkActivation();
}
项目:Eclipse-Postfix-Code-Completion-Juno38
文件:ASTFlattener.java
@Override
public boolean visit(ConstructorInvocation node) {
if (node.getAST().apiLevel() >= JLS3) {
if (!node.typeArguments().isEmpty()) {
this.fBuffer.append("<");//$NON-NLS-1$
for (Iterator<Type> it= node.typeArguments().iterator(); it.hasNext();) {
Type t= it.next();
t.accept(this);
if (it.hasNext()) {
this.fBuffer.append(",");//$NON-NLS-1$
}
}
this.fBuffer.append(">");//$NON-NLS-1$
}
}
this.fBuffer.append("this(");//$NON-NLS-1$
for (Iterator<Expression> it= node.arguments().iterator(); it.hasNext();) {
Expression e= it.next();
e.accept(this);
if (it.hasNext()) {
this.fBuffer.append(",");//$NON-NLS-1$
}
}
this.fBuffer.append(");");//$NON-NLS-1$
return false;
}
项目:Eclipse-Postfix-Code-Completion-Juno38
文件:NaiveASTFlattener.java
public boolean visit(ConstructorInvocation node) {
printIndent();
if (node.getAST().apiLevel() >= JLS3) {
if (!node.typeArguments().isEmpty()) {
this.buffer.append("<");//$NON-NLS-1$
for (Iterator it = node.typeArguments().iterator(); it.hasNext(); ) {
Type t = (Type) it.next();
t.accept(this);
if (it.hasNext()) {
this.buffer.append(",");//$NON-NLS-1$
}
}
this.buffer.append(">");//$NON-NLS-1$
}
}
this.buffer.append("this(");//$NON-NLS-1$
for (Iterator it = node.arguments().iterator(); it.hasNext(); ) {
Expression e = (Expression) it.next();
e.accept(this);
if (it.hasNext()) {
this.buffer.append(",");//$NON-NLS-1$
}
}
this.buffer.append(");\n");//$NON-NLS-1$
return false;
}
项目:jive
文件:ExpressionVisitor.java
/**
* [<type..>] this( arguments )
*/
@Override
public boolean visit(final ConstructorInvocation node)
{
// method binding for this creation
final IMethodBinding method = node.resolveConstructorBinding().getMethodDeclaration();
// create the resolved call
final IResolvedCall rcall = createResolvedCall(node, node.getStartPosition(), method);
// process the arguments
if (rcall != null)
{
// actual-ins
processActualParameters(node, node.getStartPosition(), rcall, node.arguments());
// append the call after all its arguments
uses.add(rcall);
}
// do not visit children
return false;
}
项目:j2d
文件:J2dVisitor.java
@Override
public boolean visit(ConstructorInvocation node) {
//System.out.println("Found: " + node.getClass());
// TODO Type arguments
print("this(");
int printed = 0;
for (Object o : node.arguments()) {
Expression t = (Expression)o;
if (printed > 0) {
print(", ");
}
t.accept(this);
printed++;
}
println(");");
return false;
}
项目:eclipse.jdt.ls
文件:FlowAnalyzer.java
@Override
public void endVisit(ConstructorInvocation node) {
if (skipNode(node)) {
return;
}
processSequential(node, node.arguments());
}
项目:eclipse.jdt.ls
文件:ExceptionAnalyzer.java
@Override
public boolean visit(ConstructorInvocation node) {
if (!isSelected(node)) {
return false;
}
return handleExceptions(node.resolveConstructorBinding(), node);
}
项目:eclipse.jdt.ls
文件:SurroundWithAnalyzer.java
@Override
public void endVisit(ConstructorInvocation node) {
if (getSelection().getEndVisitSelectionMode(node) == Selection.SELECTED) {
invalidSelection(RefactoringCoreMessages.SurroundWithTryCatchAnalyzer_cannotHandleThis, JavaStatusContext.create(fCUnit, node));
}
super.endVisit(node);
}
项目:Sparrow
文件:OutCodeVisitor.java
@Override
public boolean visit(ConstructorInvocation loc) {
if (currentMethod == null)
return false;
if (loc.resolveConstructorBinding() == null)
return false;
if (loc.resolveConstructorBinding().getMethodDeclaration() == null || loc.resolveConstructorBinding().getMethodDeclaration().getJavaElement() == null)
return true;
if (loc.resolveConstructorBinding().getMethodDeclaration().getJavaElement().isReadOnly())
return true;
if (loc.resolveConstructorBinding().getJavaElement() != null)
addCalledMethod(loc.resolveConstructorBinding());
return true;
}
项目:Constants-to-Enum-Eclipse-Plugin
文件:ParameterProcessingVisitor.java
public boolean visit(ConstructorInvocation node) {
if (node.getStartPosition() == this.loc) {
final Expression param = (Expression) node.arguments().get(
this.paramNumber);
this.expressions.add(param);
}
return true;
}
项目:Constants-to-Enum-Eclipse-Plugin
文件:ASTNodeProcessor.java
private void findFormalsForVariable(ConstructorInvocation ctorCall)
throws JavaModelException, CoreException {
final IMethod meth = (IMethod) ctorCall.resolveConstructorBinding()
.getJavaElement();
final IMethod top = Util.getTopMostSourceMethod(meth, this.monitor);
if (top == null)
throw new DefinitelyNotEnumerizableException(Messages.ASTNodeProcessor_SourceNotPresent,
ctorCall);
else
this.findFormalsForVariable(top, getParamNumber(ctorCall
.arguments(), this.name));
}
项目:che
文件:VariableDeclarationFix.java
private boolean callsWritingConstructor(
MethodDeclaration methodDeclaration,
HashSet<IMethodBinding> writingConstructorBindings,
Set<MethodDeclaration> visitedMethodDeclarations) {
Block body = methodDeclaration.getBody();
if (body == null) return false;
List<Statement> statements = body.statements();
if (statements.size() == 0) return false;
Statement statement = statements.get(0);
if (!(statement instanceof ConstructorInvocation)) return false;
ConstructorInvocation invocation = (ConstructorInvocation) statement;
IMethodBinding constructorBinding = invocation.resolveConstructorBinding();
if (constructorBinding == null) return false;
if (writingConstructorBindings.contains(constructorBinding)) {
return true;
} else {
ASTNode declaration =
ASTNodes.findDeclaration(constructorBinding, methodDeclaration.getParent());
if (!(declaration instanceof MethodDeclaration)) return false;
if (visitedMethodDeclarations.contains(declaration)) {
return false;
}
visitedMethodDeclarations.add(methodDeclaration);
return callsWritingConstructor(
(MethodDeclaration) declaration, writingConstructorBindings, visitedMethodDeclarations);
}
}
项目:che
文件:ChangeSignatureProcessor.java
private static boolean containsImplicitCallToSuperConstructor(MethodDeclaration constructor) {
Assert.isTrue(constructor.isConstructor());
Block body = constructor.getBody();
if (body == null) return false;
if (body.statements().size() == 0) return true;
if (body.statements().get(0) instanceof ConstructorInvocation) return false;
if (body.statements().get(0) instanceof SuperConstructorInvocation) return false;
return true;
}
项目:che
文件:ChangeSignatureProcessor.java
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;
}
项目:che
文件:ASTNodeSearchUtil.java
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;
}
项目:che
文件:PromoteTempToFieldRefactoring.java
private static boolean shouldInsertTempInitialization(MethodDeclaration constructor) {
Assert.isTrue(constructor.isConstructor());
if (constructor.getBody() == null) return false;
List<Statement> statements = constructor.getBody().statements();
if (statements == null) return false;
if (statements.size() > 0 && statements.get(0) instanceof ConstructorInvocation) return false;
return true;
}
项目:che
文件:TargetProvider.java
@Override
public boolean visit(ConstructorInvocation node) {
if (matches(node.resolveConstructorBinding()) && fCurrent != null) {
fCurrent.addInvocation(node);
}
return true;
}
项目:che
文件:ExtractTempRefactoring.java
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;
}
项目:che
文件:InlineMethodRefactoring.java
private InlineMethodRefactoring(
ICompilationUnit unit, ConstructorInvocation node, int offset, int length) {
this(unit, (ASTNode) node, offset, length);
fTargetProvider = TargetProvider.create(unit, node);
fInitialMode = fCurrentMode = Mode.INLINE_SINGLE;
fDeleteSource = false;
}
项目:che
文件:FullConstraintCreator.java
@Override
public ITypeConstraint[] create(ConstructorInvocation 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()]);
}