package com.intellij.lang.ant.psi.impl.reference;

import com.intellij.lang.ant.AntElementRole;
import com.intellij.lang.ant.psi.AntElement;
import com.intellij.lang.ant.psi.impl.AntElementImpl;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiNamedElement;
import com.intellij.util.IncorrectOperationException;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;

public class AntElementCompletionWrapper extends AntElementImpl implements PsiNamedElement {

  private final String myName;
  private final Project myProject;
  private final AntElementRole myRole;

  public AntElementCompletionWrapper(final AntElement parent, final String name, @NotNull final Project project, final AntElementRole role) {
    super(parent, null);
    myName = name;
    myProject = project;
    myRole = role;
  }

  public TextRange getTextRange() {
    return super.getTextRange();
  }

  public boolean equals(final Object that) {
    if (this == that) {
      return true;
    }
    if (that instanceof AntElementCompletionWrapper) {
      return myName.equals(((AntElementCompletionWrapper)that).myName);
    }
    return false;
  }

  public int hashCode() {
    return myName.hashCode();
  }

  public String getName() {
    return myName;
  }

  @NotNull
  public Project getProject() {
    return myProject;
  }

  public AntElementRole getRole() {
    return myRole;
  }

  public boolean isValid() {
    return true;
  }

  public boolean isPhysical() {
    return false;
  }

  public PsiElement setName(@NonNls @NotNull final String name) throws IncorrectOperationException {
    throw new IncorrectOperationException("Can't rename ant completion element");  
  }
}

@@ -237,52 +237,8 @@
 ct;%0A
-import com.intellij.openapi.util.TextRange;%0A
 impo
@@ -896,25 +896,28 @@
 lic 
-TextRa
+final Stri
 ng
-e
  getText
 Rang
@@ -912,21 +912,16 @@
  getText
-Range
 () %7B%0A   
@@ -932,25 +932,14 @@
 urn 
-super.getTextRang
+getNam
 e();
@@ -1264,16 +1264,22 @@
  public 
+final 
 String g

fix npe (IDEADEV-31044)