<commit_before>/*
 * Copyright 2000-2017 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.intellij.codeInspection.dataFlow;

import com.intellij.codeInspection.dataFlow.rangeSet.LongRangeSet;
import com.intellij.codeInspection.dataFlow.value.*;
import com.intellij.openapi.util.Key;
import com.intellij.psi.PsiModifierListOwner;
import com.intellij.psi.PsiPrimitiveType;
import com.intellij.psi.PsiType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

/**
 * A type of the fact which restricts some value.
 *
 * @author <NAME>
 */
public abstract class DfaFactType<T> extends Key<T> {
  private static final List<DfaFactType<?>> ourFactTypes = new ArrayList<>();

  /**
   * This fact specifies whether the value can be null. The absence of the fact means that the nullability is unknown.
   */
  public static final DfaFactType<Boolean> CAN_BE_NULL = new DfaFactType<Boolean>("Nullability") {
    @NotNull
    @Override
    public String toString(@NotNull Boolean fact) {
      return fact ? "Nullable" : "NotNull";
    }

    @NotNull
    @Override
    public String getPresentationText(@NotNull Boolean fact, @Nullable PsiType type) {
      if (type instanceof PsiPrimitiveType) return "";
      return super.getPresentationText(fact, type);
    }

    @Nullable
    @Override
    Boolean intersectFacts(@NotNull Boolean left, @NotNull Boolean right) {
      if (Boolean.FALSE.equals(left) || Boolean.FALSE.equals(right)) {
        return Boolean.FALSE;
      }
      return super.intersectFacts(left, right);
    }<commit_msg>DfaFactType#CAN_BE_NULL: notnull (but not nullable) is superstate for unknown<commit_after>/*
 * Copyright 2000-2017 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.intellij.codeInspection.dataFlow;

import com.intellij.codeInspection.dataFlow.rangeSet.LongRangeSet;
import com.intellij.codeInspection.dataFlow.value.*;
import com.intellij.openapi.util.Key;
import com.intellij.psi.PsiModifierListOwner;
import com.intellij.psi.PsiPrimitiveType;
import com.intellij.psi.PsiType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

/**
 * A type of the fact which restricts some value.
 *
 * @author <NAME>
 */
public abstract class DfaFactType<T> extends Key<T> {
  private static final List<DfaFactType<?>> ourFactTypes = new ArrayList<>();

  /**
   * This fact specifies whether the value can be null. The absence of the fact means that the nullability is unknown.
   */
  public static final DfaFactType<Boolean> CAN_BE_NULL = new DfaFactType<Boolean>("Nullability") {
    @NotNull
    @Override
    public String toString(@NotNull Boolean fact) {
      return fact ? "Nullable" : "NotNull";
    }

    @NotNull
    @Override
    public String getPresentationText(@NotNull Boolean fact, @Nullable PsiType type) {
      if (type instanceof PsiPrimitiveType) return "";
      return super.getPresentationText(fact, type);
    }

    @Override
    boolean isSuper(@Nullable Boolean superFact, @Nullable Boolean subFact) {
      return (superFact == null && Boolean.FALSE.equals(subFact)) || super.isSuper(superFact, subFact);
    }

    @Nullable
    @Override
    Boolean intersectFacts(@NotNull Boolean left, @NotNull Boolean right) {
      if (Boolean.FALSE.equals(left) || Boolean.FALSE.equals(right)) {
        return Boolean.FALSE;
      }
      return super.intersectFacts(left, right);
    }
{'fraction_non_alphanumeric': 0.09605963791267305, 'fraction_numerical': 0.005111821086261981, 'mean_word_length': 4.017094017094017, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '986052', 'n_tokens_mistral': 1348, 'n_tokens_neox': 1323, 'n_words': 434}