<commit_before>package org.jetbrains.plugins.scala
package lang
package psi
package impl
package base
package types

import api.statements.{ScTypeAliasDeclaration, ScTypeAliasDefinition, ScTypeAlias}
import api.toplevel.{ScNamedElement, ScPolymorphicElement}
import com.intellij.lang.ASTNode
import com.intellij.psi._
import tree.{IElementType, TokenSet}
import api.base.types._
import api.base.ScReferenceElement
import psi.ScalaPsiElementImpl
import lexer.ScalaTokenTypes
import lang.resolve.ScalaResolveResult
import psi.types._
import psi.impl.toplevel.synthetic.ScSyntheticClass
import collection.Set
import result.{TypeResult, Success, TypingContext}
import scala.None

/**
 * @author <NAME>
 * Date: 22.02.2008
 */

class ScSimpleTypeElementImpl(node: ASTNode) extends ScalaPsiElementImpl(node) with ScSimpleTypeElement {
  override def toString: String = "SimpleTypeElement"

  def singleton = getNode.findChildByType(ScalaTokenTypes.kTYPE) != null

  protected def innerType(ctx: TypingContext): TypeResult[ScType] = {
    val lift: (ScType) => Success[ScType] = Success(_, Some(this))

    val result: TypeResult[ScType] = wrap(reference) flatMap {
      ref => ref.qualifier match {
        case Some(q) => wrap(ref.bind) flatMap {
          case ScalaResolveResult(aliasDef: ScTypeAliasDefinition, s) => {
            if (aliasDef.typeParameters.length == 0) aliasDef.aliasedType(ctx) map {t => s.subst(t)}
            else {
              //todo work with recursive aliases
              lift(new ScTypeConstructorType(aliasDef, s))
            }
          }
          case _ => Success(ScProjectionType(new ScSingletonType(q), ref), Some(this))
        }//Success(ScProjectionType(new ScSingletonType(q), ref), Some(this))
        case None => wrap(ref.bind) flatMap {
          case ScalaResolveResult(e, s) => e match {
            case aliasDef: ScTypeAliasDefinition =>
              if (aliasDef.typeParameters.length == 0) aliasDef.aliasedType(ctx) map {t => s.subst(t)}
              else {
                //todo work with recursive aliases
                lift(new ScTypeConstructorType(aliasDef, s))
              }
            case alias: ScTypeAliasDeclaration => lift(new ScTypeAliasType(alias, s))
            case tp: PsiTypeParameter => lift(ScalaPsiManager.typeVariable(tp))
            case synth: ScSyntheticClass => lift(synth.t)
            case null => lift(Any)
            case _ => lift(ScDesignatorType(e))
          }
        }
      }
    }
    if (result.isEmpty && singleton) {
      Success(ScSingletonType(pathElement), Some(this))
    } else {
      //if type parameters ommited, we should to infer them manually, but this is Parameterized Type.
      if (getParent.isInstanceOf[ScParameterizedTypeElement]) return result
      result match {
        case Success(p: ScParameterizedType, _) => result
        case Success(tp: ScType, _) => {
          ScType.extractClassType(tp) match {
            case Some((clazz: PsiClass, subst: ScSubstitutor)) => {<commit_msg>fix for Simple types. If you use SyntheticClass it's more handy to not use it as ProjectionType.<commit_after>package org.jetbrains.plugins.scala
package lang
package psi
package impl
package base
package types

import api.statements.{ScTypeAliasDeclaration, ScTypeAliasDefinition, ScTypeAlias}
import api.toplevel.{ScNamedElement, ScPolymorphicElement}
import com.intellij.lang.ASTNode
import com.intellij.psi._
import tree.{IElementType, TokenSet}
import api.base.types._
import api.base.ScReferenceElement
import psi.ScalaPsiElementImpl
import lexer.ScalaTokenTypes
import lang.resolve.ScalaResolveResult
import psi.types._
import psi.impl.toplevel.synthetic.ScSyntheticClass
import collection.Set
import result.{TypeResult, Success, TypingContext}
import scala.None

/**
 * @author <NAME>
 * Date: 22.02.2008
 */

class ScSimpleTypeElementImpl(node: ASTNode) extends ScalaPsiElementImpl(node) with ScSimpleTypeElement {
  override def toString: String = "SimpleTypeElement"

  def singleton = getNode.findChildByType(ScalaTokenTypes.kTYPE) != null

  protected def innerType(ctx: TypingContext): TypeResult[ScType] = {
    val lift: (ScType) => Success[ScType] = Success(_, Some(this))

    val result: TypeResult[ScType] = wrap(reference) flatMap {
      ref => ref.qualifier match {
        case Some(q) => wrap(ref.bind) flatMap {
          case ScalaResolveResult(aliasDef: ScTypeAliasDefinition, s) => {
            if (aliasDef.typeParameters.length == 0) aliasDef.aliasedType(ctx) map {t => s.subst(t)}
            else {
              //todo work with recursive aliases
              lift(new ScTypeConstructorType(aliasDef, s))
            }
          }
          case ScalaResolveResult(synth: ScSyntheticClass, _) => lift(synth.t)
          case _ => Success(ScProjectionType(new ScSingletonType(q), ref), Some(this))
        }
        case None => wrap(ref.bind) flatMap {
          case ScalaResolveResult(e, s) => e match {
            case aliasDef: ScTypeAliasDefinition =>
              if (aliasDef.typeParameters.length == 0) aliasDef.aliasedType(ctx) map {t => s.subst(t)}
              else {
                //todo work with recursive aliases
                lift(new ScTypeConstructorType(aliasDef, s))
              }
            case alias: ScTypeAliasDeclaration => lift(new ScTypeAliasType(alias, s))
            case tp: PsiTypeParameter => lift(ScalaPsiManager.typeVariable(tp))
            case synth: ScSyntheticClass => lift(synth.t)
            case null => lift(Any)
            case _ => lift(ScDesignatorType(e))
          }
        }
      }
    }
    if (result.isEmpty && singleton) {
      Success(ScSingletonType(pathElement), Some(this))
    } else {
      //if type parameters ommited, we should to infer them manually, but this is Parameterized Type.
      if (getParent.isInstanceOf[ScParameterizedTypeElement]) return result
      result match {
        case Success(p: ScParameterizedType, _) => result
        case Success(tp: ScType, _) => {
          ScType.extractClassType(tp) match {
            case Some((clazz: PsiClass, subst: ScSubstitutor)) => {
{'fraction_non_alphanumeric': 0.09996733093760209, 'fraction_numerical': 0.003266906239790918, 'mean_word_length': 3.106639839034205, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 42, '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': '4268275', 'n_tokens_mistral': 1820, 'n_tokens_neox': 1773, 'n_words': 432}