Unary + and -, redeclarations reported as errors
This commit is contained in:
@@ -188,6 +188,12 @@ public class JetExpressionParsing extends AbstractJetParsing {
|
||||
IElementType[] usedOperations = ALL_OPERATIONS.getTypes();
|
||||
Set<IElementType> usedSet = new HashSet<IElementType>(Arrays.asList(usedOperations));
|
||||
|
||||
// if (opSet.size() > usedSet.size()) {
|
||||
// opSet.removeAll(usedSet);
|
||||
// assert false : opSet;
|
||||
// }
|
||||
// assert usedSet.size() == opSet.size();
|
||||
|
||||
usedSet.removeAll(opSet);
|
||||
|
||||
assert usedSet.isEmpty() : "" + usedSet;
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
package org.jetbrains.jet.lang.psi;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiNameIdentifierOwner;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -30,60 +27,6 @@ public abstract class JetNamedDeclaration extends JetDeclaration implements PsiN
|
||||
return findChildByType(JetTokens.IDENTIFIER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiReference getReference() {
|
||||
return new PsiReference() {
|
||||
@Override
|
||||
public PsiElement getElement() {
|
||||
return getNameIdentifier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextRange getRangeInElement() {
|
||||
PsiElement element = getElement();
|
||||
if (element == null) return null;
|
||||
return element.getTextRange().shiftRight(element.getTextOffset());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement resolve() {
|
||||
return PsiTreeUtil.getParentOfType(JetNamedDeclaration.this, JetFile.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getCanonicalText() {
|
||||
return "<TBD>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement handleElementRename(String newElementName) throws IncorrectOperationException {
|
||||
throw new IncorrectOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException {
|
||||
throw new IncorrectOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReferenceTo(PsiElement element) {
|
||||
return resolve() == element;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Object[] getVariants() {
|
||||
return EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSoft() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException {
|
||||
return getNameIdentifier().replace(JetChangeUtil.createNameIdentifier(getProject(), name));
|
||||
|
||||
@@ -117,11 +117,11 @@ public class TopDownAnalyzer {
|
||||
}
|
||||
|
||||
private void processExtension(JetExtension extension) {
|
||||
throw new UnsupportedOperationException(); // TODO
|
||||
throw new UnsupportedOperationException(extension.getText()); // TODO
|
||||
}
|
||||
|
||||
private void processTypeDef(JetTypedef typedef) {
|
||||
throw new UnsupportedOperationException(); // TODO
|
||||
private void processTypeDef(@NotNull JetTypedef typedef) {
|
||||
throw new UnsupportedOperationException(typedef.getText()); // TODO
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -149,8 +149,9 @@ public class WritableScope extends JetScopeAdapter {
|
||||
public void addTypeParameterDescriptor(TypeParameterDescriptor typeParameterDescriptor) {
|
||||
String name = typeParameterDescriptor.getName();
|
||||
Map<String, TypeParameterDescriptor> typeParameterDescriptors = getTypeParameterDescriptors();
|
||||
if (typeParameterDescriptors.containsKey(name)) {
|
||||
throw new UnsupportedOperationException("Type parameter redeclared"); // TODO
|
||||
TypeParameterDescriptor originalDescriptor = typeParameterDescriptors.get(name);
|
||||
if (originalDescriptor != null) {
|
||||
errorHandler.redeclaration(originalDescriptor, typeParameterDescriptor);
|
||||
}
|
||||
typeParameterDescriptors.put(name, typeParameterDescriptor);
|
||||
}
|
||||
@@ -178,9 +179,11 @@ public class WritableScope extends JetScopeAdapter {
|
||||
|
||||
public void addClassAlias(String name, ClassDescriptor classDescriptor) {
|
||||
Map<String, ClassDescriptor> classDescriptors = getClassDescriptors();
|
||||
if (classDescriptors.put(name, classDescriptor) != null) {
|
||||
throw new UnsupportedOperationException("Class redeclared: " + classDescriptor.getName());
|
||||
ClassDescriptor originalDescriptor = classDescriptors.get(name);
|
||||
if (originalDescriptor != null) {
|
||||
errorHandler.redeclaration(originalDescriptor, classDescriptor);
|
||||
}
|
||||
classDescriptors.put(name, classDescriptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -219,7 +222,7 @@ public class WritableScope extends JetScopeAdapter {
|
||||
public void addNamespace(NamespaceDescriptor namespaceDescriptor) {
|
||||
NamespaceDescriptor oldValue = getNamespaceDescriptors().put(namespaceDescriptor.getName(), namespaceDescriptor);
|
||||
if (oldValue != null) {
|
||||
throw new UnsupportedOperationException("Namespace redeclared: " + namespaceDescriptor.getName());
|
||||
errorHandler.redeclaration(oldValue, namespaceDescriptor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@ public class JetTypeInferrer {
|
||||
static {
|
||||
unaryOperationNames.put(JetTokens.PLUSPLUS, "inc");
|
||||
unaryOperationNames.put(JetTokens.MINUSMINUS, "dec");
|
||||
unaryOperationNames.put(JetTokens.PLUS, "plus");
|
||||
unaryOperationNames.put(JetTokens.MINUS, "minus");
|
||||
unaryOperationNames.put(JetTokens.EXCL, "not");
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ package org.jetbrains.jet.lexer;
|
||||
import com.intellij.psi.TokenType;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import org.jetbrains.jet.lang.parsing.JetExpressionParsing;
|
||||
|
||||
public interface JetTokens {
|
||||
JetToken EOF = new JetToken("EOF");
|
||||
@@ -163,6 +162,8 @@ public interface JetTokens {
|
||||
MINUS, EXCL, DIV, PERC, LT, GT, LTEQ, GTEQ, EQEQEQ, ARROW, EXCLEQEQEQ, EQEQ, EXCLEQ, ANDAND, OROR,
|
||||
SAFE_ACCESS, ELVIS,
|
||||
// MAP, FILTER,
|
||||
QUEST, COLON, SEMICOLON, RANGE, EQ, MULTEQ, DIVEQ, PERCEQ, PLUSEQ, MINUSEQ,
|
||||
QUEST, COLON,
|
||||
// SEMICOLON,
|
||||
RANGE, EQ, MULTEQ, DIVEQ, PERCEQ, PLUSEQ, MINUSEQ,
|
||||
NOT_IN, NOT_IS, HASH, IDENTIFIER, LABEL_IDENTIFIER, ATAT, AT);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user