Intellij marks all methods as unused, even if they are used

Here is the piece of code.

public class MyPolynomial { private double coeffs[]; private int degree; public MyPolynomial(double ... coeffs) { if (coeffs != null && coeffs.length > 0) { this.coeffs = new double[coeffs.length]; System.arraycopy(coeffs, 0, this.coeffs, 0, coeffs.length); } //this.coeffs = Arrays.copyOf(coeffs, coeffs.length); } public MyPolynomial(String filename) { Scanner in = null; try { in = new Scanner(new File(filename)); } catch (FileNotFoundException e) { e.printStackTrace(); } this.degree = in.nextInt(); coeffs = new double[degree+1]; for (int i = 0; i < coeffs.length; i++) { coeffs[i] = in.nextDouble(); } } public String getCoeffs() { return Arrays.toString(coeffs); } } 

The class, constructors, and also all methods are marked as unused. But I used them in a test file. It compiles and works as expected.

Part of the test file:

 MyPolynomial aTest = new MyPolynomial(1, 2, 3, 4, 5); System.out.println(aTest.getCoeffs()); System.out.println(aTest.getDegree()); System.out.println(aTest); 
+5
source share
1 answer

I was able to solve this problem by canceling the caches in the File menu.

+10
source

Source: https://habr.com/ru/post/1202233/


All Articles