You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@daffodil.apache.org by Larry Barber <la...@nteligen.com> on 2020/11/06 21:15:32 UTC

IntelliJ IDEA is flagging “errors”

Does anyone know why IntelliJ IDEA is flagging “errors” that don’t really exist?
Here’s an example of what I’m seeing:

In InputSrourceDataInputStrream.scala, the following code viewed in Notepad++:

  def peek(): Char = {
    checkNeedsRefetch()

    val decodedChars = dis.cst.charIteratorState.decodedChars
    if (decodedChars.remaining >= 1) {
      decodedChars.get(decodedChars.position())
    } else if (dis.cst.charIteratorState.moreDataAvailable) {
      fetch()
      peek()
    } else {
      -1.toChar
    }
  }

However, the IntelliJ IDEA adds “ : Int” to as highlighted below:

  def peek(): Char = {
    checkNeedsRefetch()

    val decodedChars = dis.cst.charIteratorState.decodedChars
    if (decodedChars.remaining >= 1) {
      decodedChars.get(decodedChars.position())
    } else if (dis.cst.charIteratorState.moreDataAvailable) {
      fetch()
      peek()
    } else {
      -1.toChar
    } : Int
  }

It furthermore, flags this as an error: “Type mismatch. Required: Char, found: Int”
The “ :Int” seems to be added as a display indicator only and IS NOT COPIED if you try to copy and paste it.

The code is unmodified from GitHub and seems to build cleanly.

I would really like to eliminate these erroneous and distracting error indications.


Re: IntelliJ IDEA is flagging “errors”

Posted by "Beckerle, Mike" <mb...@owlcyberdefense.com>.
I believe one can adjust the various suggestions it makes, but IntelliJ often seems to suggest types where it thinks they would add value. The colorization it uses indicates that this is it's suggestions, not things actually in the text, and my eye has learned to read past these. There are times when it lengthens lines to where you have to scroll horizontally however, which does bug me.

In settings I did spot this, which may or may not be helpful:

[cid:929e2d72-79d9-49d2-8219-0da33aecf20f]

In your code, does peek() perhaps return type Int? If so it's flagging the inconsistency between Char and Int usage. If not I have no clue why it is suggesting Int type here.


________________________________
From: Larry Barber <la...@nteligen.com>
Sent: Friday, November 6, 2020 2:15 PM
To: dev@daffodil.apache.org <de...@daffodil.apache.org>
Subject: IntelliJ IDEA is flagging “errors”


Does anyone know why IntelliJ IDEA is flagging “errors” that don’t really exist?

Here’s an example of what I’m seeing:



In InputSrourceDataInputStrream.scala, the following code viewed in Notepad++:



  def peek(): Char = {

    checkNeedsRefetch()



    val decodedChars = dis.cst.charIteratorState.decodedChars

    if (decodedChars.remaining >= 1) {

      decodedChars.get(decodedChars.position())

    } else if (dis.cst.charIteratorState.moreDataAvailable) {

      fetch()

      peek()

    } else {

      -1.toChar

    }

  }



However, the IntelliJ IDEA adds “ : Int” to as highlighted below:



  def peek(): Char = {

    checkNeedsRefetch()



    val decodedChars = dis.cst.charIteratorState.decodedChars

    if (decodedChars.remaining >= 1) {

      decodedChars.get(decodedChars.position())

    } else if (dis.cst.charIteratorState.moreDataAvailable) {

      fetch()

      peek()

    } else {

      -1.toChar

    } : Int

  }



It furthermore, flags this as an error: “Type mismatch. Required: Char, found: Int”

The “ :Int” seems to be added as a display indicator only and IS NOT COPIED if you try to copy and paste it.



The code is unmodified from GitHub and seems to build cleanly.



I would really like to eliminate these erroneous and distracting error indications.