com.intellij.psi.PsiNewExpression Java Examples

The following examples show how to use com.intellij.psi.PsiNewExpression. 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: PDGObjectSliceUnion.java    From IntelliJDeodorant with MIT License 6 votes vote down vote up
private boolean duplicatedSliceNodeWithClassInstantiationHasDependenceOnRemovableNode() {
    Set<PDGNode> duplicatedNodes = new LinkedHashSet<>(sliceNodes);
    duplicatedNodes.retainAll(indispensableNodes);
    for (PDGNode duplicatedNode : duplicatedNodes) {
        if (duplicatedNode.containsClassInstanceCreation()) {
            Map<PsiVariable, PsiNewExpression> classInstantiations = duplicatedNode.getClassInstantiations();
            for (PsiVariable variableDeclaration : classInstantiations.keySet()) {
                for (GraphEdge edge : duplicatedNode.outgoingEdges) {
                    PDGDependence dependence = (PDGDependence) edge;
                    if (subgraph.edgeBelongsToBlockBasedRegion(dependence) && dependence != null) {
                        PDGNode dstPDGNode = (PDGNode) dependence.dst;
                        if (removableNodes.contains(dstPDGNode)) {
                            if (dstPDGNode.changesStateOfReference(variableDeclaration)
                                    || dstPDGNode.assignsReference(variableDeclaration)
                                    || dstPDGNode.accessesReference(variableDeclaration))
                                return true;
                        }
                    }
                }
            }
        }
    }
    return false;
}
 
Example #2
Source File: PDGSliceUnion.java    From IntelliJDeodorant with MIT License 6 votes vote down vote up
private boolean duplicatedSliceNodeWithClassInstantiationHasDependenceOnRemovableNode() {
    Set<PDGNode> duplicatedNodes = new LinkedHashSet<>(sliceNodes);
    duplicatedNodes.retainAll(indispensableNodes);
    for (PDGNode duplicatedNode : duplicatedNodes) {
        if (duplicatedNode.containsClassInstanceCreation()) {
            Map<PsiVariable, PsiNewExpression> classInstantiations = duplicatedNode.getClassInstantiations();
            for (PsiVariable variableDeclaration : classInstantiations.keySet()) {
                for (GraphEdge edge : duplicatedNode.outgoingEdges) {
                    PDGDependence dependence = (PDGDependence) edge;
                    if (subgraph.edgeBelongsToBlockBasedRegion(dependence) && dependence != null) {
                        PDGNode dstPDGNode = (PDGNode) dependence.dst;
                        if (removableNodes.contains(dstPDGNode)) {
                            if (dstPDGNode.changesStateOfReference(variableDeclaration)
                                    || dstPDGNode.assignsReference(variableDeclaration)
                                    || dstPDGNode.accessesReference(variableDeclaration))
                                return true;
                        }
                    }
                }
            }
        }
    }
    return false;
}
 
Example #3
Source File: PsiJavaElementVisitor.java    From KodeBeagle with Apache License 2.0 5 votes vote down vote up
private void visitExpression(final PsiElement element) {
    if (element.getNode().getElementType().equals(JavaElementType.NEW_EXPRESSION)) {
        visitPsiNewExpression((PsiNewExpression) element);
    } else if (element.getNode().getElementType().
            equals(JavaElementType.METHOD_CALL_EXPRESSION)) {
        visitPsiMethodCallExpression((PsiMethodCallExpression) element);
    } else if (element.getNode().getElementType().
            equals(JavaElementType.ASSIGNMENT_EXPRESSION)) {
        visitPsiAssignmentExpression((PsiAssignmentExpression) element);
    } else if (element.getNode().getElementType().
            equals(JavaElementType.REFERENCE_EXPRESSION)) {
        visitPsiReferenceExpression((PsiReferenceExpression) element);
    }
}
 
Example #4
Source File: PsiJavaElementVisitor.java    From KodeBeagle with Apache License 2.0 5 votes vote down vote up
private void visitPsiNewExpression(final PsiNewExpression element) {
    if (element.getType() != null) {
        PsiType psiType = element.getType();
        if (psiType != null && !ClassUtils.isPrimitive(psiType)) {
            String type = removeSpecialSymbols(psiType.getCanonicalText());
            addInMap(type, emptySet);
        }
    }
}
 
Example #5
Source File: OttoLineMarkerProvider.java    From otto-intellij-plugin with Apache License 2.0 5 votes vote down vote up
@Override public boolean shouldShow(Usage usage) {
  PsiElement element = ((UsageInfo2UsageAdapter) usage).getElement();
  if (element.getParent() instanceof PsiNewExpression) {
    PsiMethod method = PsiConsultantImpl.findMethod(element);
    return !SubscriberMetadata.isAnnotatedWithProducer(method);
  }
  return false;
}
 
Example #6
Source File: ArrayCreationObject.java    From IntelliJDeodorant with MIT License 4 votes vote down vote up
public void setArrayCreation(PsiNewExpression creation) {
    this.creation = toPointer(creation);
}
 
Example #7
Source File: InstanceOfClassInstanceCreation.java    From IntelliJDeodorant with MIT License 4 votes vote down vote up
public boolean instanceOf(PsiExpression expression) {
	return expression instanceof PsiNewExpression;
}
 
Example #8
Source File: InstanceOfArrayCreation.java    From IntelliJDeodorant with MIT License 4 votes vote down vote up
public boolean instanceOf(PsiExpression expression) {
	return expression instanceof PsiNewExpression;
}
 
Example #9
Source File: ClassInstanceCreationObject.java    From IntelliJDeodorant with MIT License 4 votes vote down vote up
public PsiNewExpression getClassInstanceCreation() {
    return (PsiNewExpression) this.creation.getElement();
}