如何在groovy代码中列出`无法解析符号'警告? (的IntelliJ)

时间:2015-12-11 11:38:18

标签: intellij-idea groovy

我想在我的groovy代码中列出所有cannot resolve symbol警告。我将检查配置文件中的Groovy->Probable bugs->Access to unresolved expression严重性级别设置为Warning。 IntelliJ会在编辑视图中突出显示cannot resolve symbol警告,但在运行Analyze->Inspect Code...后,它不会列出问题列表中的问题。

我使用的是IntelliJ IDEA 15.0.2。

对下面的groovy代码运行检查会响应一条消息No suspicious code found,但fooo()会突出显示。

class Example {
  def foo() {
    fooo() // highlighted as `Cannot resolve symbol 'fooo'`
  }
}

1 个答案:

答案 0 :(得分:1)

您正在寻找静态编译行为。请使用@CompileStatic

who_first <- function(){

  dummylist <- c()
  playersdummy <- 1:number_of_players

  first_rolling <- function(players_left=number_of_players){

    for(i in 1:players_left){
      # Random variable where 1, 2 & 3 represents Ws, Cs and Gs respectively.
      die_poss <- c(1, 1, 1, 2, 2, 3)
      die_result <- sample(die_poss, 4, replace=T)
      dummy2 <- 0

      for(j in 1:4){
        if(die_result[j]==1){
          dummy2 <- dummy2 + 1
        }
      }

      dummy3 <- append(dummylist, dummy2, after=i)
      # dummylist stores the number of Ws rolled by each respective player, 
      # i.e. first element says how many Ws 1st player still left in rolled.
      dummylist <<- dummy3 
    }

    dummy4 <- 0
    for(k in 1:players_left){
      if(dummylist[k]==max(dummylist)){
        # dummy4 represents the number of players who rolled the highest number of Ws that roll.
        dummy4 <<- dummy4 + 1 
      }
    }
    return(dummy4)
  }

  while(dummy4 >= 1){
    if(dummy4==1){
      playersdummy <<- playersdummy[(which(dummylist==max(dummylist))==TRUE)]
      return(playersdummy)
    }

    else if(dummy4 > 1){
      dummy5 <- c()
      for(l in 1:length(playersdummy)){
        if(any((playersdummy[l]==which(dummylist==max(dummylist)))==TRUE)){
          dummy6 <- append(dummy5, playersdummy[l], after=l)
          dummy5 <<- dummy6
        }
      }

      # playersdummy becomes the vector containing which players are left in the game, i.e. 2 represents player 2.
      playersdummy <<- dummy5 
      dummylist <<- c()
      first_rolling(length(playersdummy))
    }
  }
}



 who_first()

 [1] 1 2 3 4 5 6 7
 Warning message:
 In max(dummylist) : no non-missing arguments to max; returning -Inf*