<commit_before>package com.intellij.refactoring.typeCook.deductive.util;

import com.intellij.refactoring.typeCook.Util;
import com.intellij.refactoring.typeCook.Settings;
import com.intellij.psi.*;

import java.util.HashSet;

/**
 * Created by IntelliJ IDEA.
 * User: db
 * Date: Jul 5, 2004
 * Time: 6:45:51 PM
 * To change this template use File | Settings | File Templates.
 */
public class VictimCollector extends Visitor {
  final HashSet<PsiElement> myVictims = new HashSet<PsiElement>();
  final PsiElement[] myElements;
  final Settings mySettings;

  public VictimCollector(final PsiElement[] elements, final Settings settings) {
    myElements = elements;
    mySettings = settings;
  }

  private void testNAdd(final PsiElement element, final PsiType t) {
    if (Util.isRaw(t, mySettings)) {
      if (element instanceof PsiNewExpression && t.getCanonicalText().equals("java.lang.Object")){
        return;  
      }

      myVictims.add(element);
    }
  }

  public void visitLocalVariable(final PsiLocalVariable variable) {
    testNAdd(variable, variable.getType());

    super.visitLocalVariable(variable);
  }

  public void visitField(final PsiField field) {
    testNAdd(field, field.getType());

    super.visitField(field);
  }

  public void visitMethod(final PsiMethod method) {
    final PsiParameter[] parms = method.getParameterList().getParameters();

    for (int i = 0; i < parms.length; i++) {
      testNAdd(parms[i], parms[i].getType());
    }

    if (Util.isRaw(method.getReturnType(), mySettings)) {
      myVictims.add(method);
    }

    final PsiCodeBlock body = method.getBody();

    if (body != null) {
      body.accept(this);
    }
  }

  public void visitNewExpression(final PsiNewExpression expression) {
    if (expression.getClassReference() != null) {
      testNAdd(expression, expression.getType());
    }

    super.visitNewExpression(expression);
  }

  public void visitTypeCastExpression (final PsiTypeCastExpression cast){
    testNAdd(cast, cast.getCastType().getType());
    
    super.visitTypeCastExpression(cast);
  }

  public void visitReferenceExpression(final PsiReferenceExpression expression) {
  }

  public HashSet<PsiElement> getVictims() {
    for (int i = 0; i < myElements.length; i++) {
      myElements[i].accept(this);
    }

    return myVictims;
  }
}
<commit_msg>(no message)<commit_after>package com.intellij.refactoring.typeCook.deductive.util;

import com.intellij.refactoring.typeCook.Util;
import com.intellij.refactoring.typeCook.Settings;
import com.intellij.psi.*;
import com.intellij.psi.jsp.JspFile;

import java.util.HashSet;

/**
 * Created by IntelliJ IDEA.
 * User: db
 * Date: Jul 5, 2004
 * Time: 6:45:51 PM
 * To change this template use File | Settings | File Templates.
 */
public class VictimCollector extends Visitor {
  final HashSet<PsiElement> myVictims = new HashSet<PsiElement>();
  final PsiElement[] myElements;
  final Settings mySettings;

  public VictimCollector(final PsiElement[] elements, final Settings settings) {
    myElements = elements;
    mySettings = settings;
  }

  private void testNAdd(final PsiElement element, final PsiType t) {
    if (Util.isRaw(t, mySettings)) {
      if (element instanceof PsiNewExpression && t.getCanonicalText().equals("java.lang.Object")){
        return;  
      }

      myVictims.add(element);
    }
  }

  public void visitLocalVariable(final PsiLocalVariable variable) {
    testNAdd(variable, variable.getType());

    super.visitLocalVariable(variable);
  }

  public void visitField(final PsiField field) {
    testNAdd(field, field.getType());

    super.visitField(field);
  }

  public void visitMethod(final PsiMethod method) {
    final PsiParameter[] parms = method.getParameterList().getParameters();

    for (PsiParameter parm : parms) {
      testNAdd(parm, parm.getType());
    }

    if (Util.isRaw(method.getReturnType(), mySettings)) {
      myVictims.add(method);
    }

    final PsiCodeBlock body = method.getBody();

    if (body != null) {
      body.accept(this);
    }
  }

  public void visitNewExpression(final PsiNewExpression expression) {
    if (expression.getClassReference() != null) {
      testNAdd(expression, expression.getType());
    }

    super.visitNewExpression(expression);
  }

  public void visitTypeCastExpression (final PsiTypeCastExpression cast){
    testNAdd(cast, cast.getCastType().getType());
    
    super.visitTypeCastExpression(cast);
  }

  public void visitReferenceExpression(final PsiReferenceExpression expression) {
  }

  public void visitFile(PsiFile file) {
    if (file instanceof PsiJavaFile || file instanceof JspFile) {
      super.visitFile(file);
    }
  }

  public HashSet<PsiElement> getVictims() {
    for (PsiElement element : myElements) {
      element.accept(this);
    }

    return myVictims;
  }
}

{'fraction_non_alphanumeric': 0.11299318322660608, 'fraction_numerical': 0.00454451559595125, 'mean_word_length': 3.7610619469026547, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3837894', 'n_tokens_mistral': 1545, 'n_tokens_neox': 1492, 'n_words': 331}