Clearing PsiElement interface.

This commit is contained in:
Maxim Shafirov
2005-01-18 15:37:49 +03:00
parent f57c2307e4
commit 983be7df48
15 changed files with 65 additions and 155 deletions
@@ -3,6 +3,10 @@ package com.intellij.lang;
import com.intellij.codeFormatting.PseudoTextBuilder;
import com.intellij.openapi.fileTypes.SyntaxHighlighter;
import com.intellij.openapi.fileTypes.PlainSyntaxHighlighter;
import com.intellij.lexer.Lexer;
import com.intellij.lexer.EmptyLexer;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiMethod;
/**
* Created by IntelliJ IDEA.
@@ -20,4 +24,9 @@ public abstract class Language {
return null;
}
public ParserDefinition getParserDefinition() {
return null;
}
}
@@ -0,0 +1,18 @@
package com.intellij.lang;
import com.intellij.lexer.Lexer;
import com.intellij.psi.PsiElement;
import com.intellij.psi.tree.IElementType;
/**
* Created by IntelliJ IDEA.
* User: max
* Date: Jan 17, 2005
* Time: 7:57:54 PM
* To change this template use File | Settings | File Templates.
*/
public interface ParserDefinition {
Lexer createLexer();
PsiParser createParser();
PsiElement createElement(IElementType type, ElementFactoryHelper helper);
}
@@ -0,0 +1,23 @@
package com.intellij.lang;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.PsiElement;
/**
* Created by IntelliJ IDEA.
* User: max
* Date: Jan 17, 2005
* Time: 1:27:50 PM
* To change this template use File | Settings | File Templates.
*/
public interface PsiBuilder {
interface Marker {}
Marker start(IElementType symbol);
void rollbackTo(Marker marker);
void drop(Marker marker);
void done(Marker marker);
void insertErrorElement(String messageText);
PsiElement getTreeBuilt();
}
@@ -0,0 +1,15 @@
package com.intellij.lang;
import com.intellij.psi.PsiElement;
import com.intellij.lexer.Lexer;
/**
* Created by IntelliJ IDEA.
* User: max
* Date: Jan 17, 2005
* Time: 2:14:05 PM
* To change this template use File | Settings | File Templates.
*/
public interface PsiParser {
PsiElement parse(Lexer lexer, PsiBuilder builder);
}
@@ -74,22 +74,12 @@ public interface PsiElement extends UserDataHolder, Iconable {
void checkAdd(PsiElement element) throws IncorrectOperationException;
void checkAddBefore(PsiElement element, PsiElement anchor) throws IncorrectOperationException;
void checkAddAfter(PsiElement element, PsiElement anchor) throws IncorrectOperationException;
PsiElement addRange(PsiElement first, PsiElement last) throws IncorrectOperationException;
PsiElement addRangeBefore(PsiElement first, PsiElement last, PsiElement anchor) throws IncorrectOperationException;
PsiElement addRangeAfter(PsiElement first, PsiElement last, PsiElement anchor) throws IncorrectOperationException;
void checkAddRange(PsiElement first, PsiElement last) throws IncorrectOperationException;
void checkAddRangeBefore(PsiElement first, PsiElement last, PsiElement anchor) throws IncorrectOperationException;
void checkAddRangeAfter(PsiElement first, PsiElement last, PsiElement anchor) throws IncorrectOperationException;
void delete() throws IncorrectOperationException;
void checkDelete() throws IncorrectOperationException;
@@ -98,8 +88,6 @@ public interface PsiElement extends UserDataHolder, Iconable {
PsiElement replace(PsiElement newElement) throws IncorrectOperationException;
void checkReplace(PsiElement newElement) throws IncorrectOperationException;
boolean isValid();
boolean isWritable();
@@ -6,5 +6,4 @@ package com.intellij.psi;
public interface PsiErrorElement extends PsiElement{
String getErrorDescription();
String getExpectedToken();
}
@@ -69,20 +69,6 @@ public abstract class PsiElementBase extends ElementBase implements PsiElement {
throw new IncorrectOperationException();
}
public void checkAddRange(PsiElement first, PsiElement last) throws IncorrectOperationException {
throw new IncorrectOperationException();
}
public void checkAddRangeBefore(PsiElement first, PsiElement last, PsiElement anchor)
throws IncorrectOperationException {
throw new IncorrectOperationException();
}
public void checkAddRangeAfter(PsiElement first, PsiElement last, PsiElement anchor)
throws IncorrectOperationException {
throw new IncorrectOperationException();
}
public void deleteChildRange(PsiElement first, PsiElement last) throws IncorrectOperationException {
throw new IncorrectOperationException();
}
@@ -42,14 +42,6 @@ abstract class ClsElementImpl extends PsiElementBase implements PsiCompiledEleme
throw new IncorrectOperationException(CAN_NOT_MODIFY_MESSAGE);
}
public void checkAddBefore(PsiElement element, PsiElement anchor) throws IncorrectOperationException {
throw new IncorrectOperationException(CAN_NOT_MODIFY_MESSAGE);
}
public void checkAddAfter(PsiElement element, PsiElement anchor) throws IncorrectOperationException {
throw new IncorrectOperationException(CAN_NOT_MODIFY_MESSAGE);
}
public PsiElement add(PsiElement element) throws IncorrectOperationException {
throw new IncorrectOperationException(CAN_NOT_MODIFY_MESSAGE);
}
@@ -74,10 +66,6 @@ abstract class ClsElementImpl extends PsiElementBase implements PsiCompiledEleme
throw new IncorrectOperationException(CAN_NOT_MODIFY_MESSAGE);
}
public void checkReplace(PsiElement newElement) throws IncorrectOperationException {
throw new IncorrectOperationException(CAN_NOT_MODIFY_MESSAGE);
}
protected static final String CAN_NOT_MODIFY_MESSAGE = "Cannot modify compiled element";
public abstract String getMirrorText();
@@ -190,14 +190,6 @@ public class PsiBinaryFileImpl extends PsiElementBase implements PsiBinaryFile,
throw new IncorrectOperationException();
}
public void checkAddBefore(PsiElement element, PsiElement anchor) throws IncorrectOperationException {
throw new IncorrectOperationException();
}
public void checkAddAfter(PsiElement element, PsiElement anchor) throws IncorrectOperationException {
throw new IncorrectOperationException();
}
public void delete() throws IncorrectOperationException{
checkDelete();
PsiFileImplUtil.doDelete(this);
@@ -214,9 +206,6 @@ public class PsiBinaryFileImpl extends PsiElementBase implements PsiBinaryFile,
return null;
}
public void checkReplace(PsiElement newElement) throws IncorrectOperationException {
}
public boolean isValid() {
if (myFile == null) return true; // "dummy" file
if (!myFile.isValid()) return false;
@@ -539,14 +539,6 @@ public class PsiDirectoryImpl extends PsiElementBase implements PsiDirectory {
throw new IncorrectOperationException();
}
public void checkAddBefore(PsiElement element, PsiElement anchor) throws IncorrectOperationException {
throw new IncorrectOperationException();
}
public void checkAddAfter(PsiElement element, PsiElement anchor) throws IncorrectOperationException {
throw new IncorrectOperationException();
}
public void delete() throws IncorrectOperationException {
checkDelete();
//PsiDirectory parent = getParentDirectory();
@@ -587,13 +579,6 @@ public class PsiDirectoryImpl extends PsiElementBase implements PsiDirectory {
return null;
}
/**
* @not_implemented
*/
public void checkReplace(PsiElement newElement) throws IncorrectOperationException {
LOG.error("not implemented");
}
public void accept(PsiElementVisitor visitor) {
visitor.visitDirectory(this);
}
@@ -271,14 +271,6 @@ public class PsiPackageImpl extends PsiElementBase implements PsiPackage {
throw new IncorrectOperationException();
}
public void checkAddBefore(PsiElement element, PsiElement anchor) throws IncorrectOperationException {
throw new IncorrectOperationException();
}
public void checkAddAfter(PsiElement element, PsiElement anchor) throws IncorrectOperationException {
throw new IncorrectOperationException();
}
public void delete() throws IncorrectOperationException {
checkDelete();
PsiDirectory[] dirs = getDirectories();
@@ -298,10 +290,6 @@ public class PsiPackageImpl extends PsiElementBase implements PsiPackage {
throw new IncorrectOperationException();
}
public void checkReplace(PsiElement newElement) throws IncorrectOperationException {
throw new IncorrectOperationException();
}
public boolean isValid() {
return getDirectories().length > 0;
}
@@ -84,14 +84,6 @@ public abstract class LightElement extends PsiElementBase {
throw new IncorrectOperationException();
}
public void checkAddBefore(PsiElement element, PsiElement anchor) throws IncorrectOperationException{
throw new IncorrectOperationException();
}
public void checkAddAfter(PsiElement element, PsiElement anchor) throws IncorrectOperationException{
throw new IncorrectOperationException();
}
public PsiElement add(PsiElement element) throws IncorrectOperationException{
throw new IncorrectOperationException();
}
@@ -116,7 +108,4 @@ public abstract class LightElement extends PsiElementBase {
throw new IncorrectOperationException();
}
public void checkReplace(PsiElement newElement) throws IncorrectOperationException{
throw new IncorrectOperationException();
}
}
@@ -121,14 +121,6 @@ public abstract class CompositePsiElement extends CompositeElement implements Ps
CheckUtil.checkWritable(this);
}
public final void checkAddBefore(PsiElement element, PsiElement anchor) throws IncorrectOperationException {
CheckUtil.checkWritable(this);
}
public final void checkAddAfter(PsiElement element, PsiElement anchor) throws IncorrectOperationException {
CheckUtil.checkWritable(this);
}
public final PsiElement addRange(PsiElement first, PsiElement last) throws IncorrectOperationException {
return SharedImplUtil.addRange(this, first, last, null, null);
}
@@ -143,20 +135,6 @@ public abstract class CompositePsiElement extends CompositeElement implements Ps
return SharedImplUtil.addRange(this, first, last, SourceTreeToPsiMap.psiElementToTree(anchor), Boolean.FALSE);
}
public final void checkAddRange(PsiElement first, PsiElement last) throws IncorrectOperationException {
CheckUtil.checkWritable(this);
}
public final void checkAddRangeBefore(PsiElement first, PsiElement last, PsiElement anchor)
throws IncorrectOperationException {
CheckUtil.checkWritable(this);
}
public final void checkAddRangeAfter(PsiElement first, PsiElement last, PsiElement anchor)
throws IncorrectOperationException {
CheckUtil.checkWritable(this);
}
public void delete() throws IncorrectOperationException {
LOG.assertTrue(getTreeParent() != null);
CheckUtil.checkWritable(this);
@@ -189,10 +167,6 @@ public abstract class CompositePsiElement extends CompositeElement implements Ps
return result;
}
public void checkReplace(PsiElement newElement) throws IncorrectOperationException {
CheckUtil.checkWritable(this);
}
public void accept(PsiElementVisitor visitor) { //TODO: remove this method!!
visitor.visitElement(this);
}
@@ -98,14 +98,6 @@ public class LeafPsiElement extends LeafElementImpl implements PsiElement {
throw new IncorrectOperationException();
}
public void checkAddBefore(PsiElement element, PsiElement anchor) throws IncorrectOperationException {
throw new IncorrectOperationException();
}
public void checkAddAfter(PsiElement element, PsiElement anchor) throws IncorrectOperationException {
throw new IncorrectOperationException();
}
public PsiElement addRange(PsiElement first, PsiElement last) throws IncorrectOperationException {
throw new IncorrectOperationException();
}
@@ -120,20 +112,6 @@ public class LeafPsiElement extends LeafElementImpl implements PsiElement {
throw new IncorrectOperationException();
}
public void checkAddRange(PsiElement first, PsiElement last) throws IncorrectOperationException {
throw new IncorrectOperationException();
}
public void checkAddRangeBefore(PsiElement first, PsiElement last, PsiElement anchor)
throws IncorrectOperationException {
throw new IncorrectOperationException();
}
public void checkAddRangeAfter(PsiElement first, PsiElement last, PsiElement anchor)
throws IncorrectOperationException {
throw new IncorrectOperationException();
}
public void delete() throws IncorrectOperationException {
LOG.assertTrue(getTreeParent() != null);
CheckUtil.checkWritable(this);
@@ -161,10 +139,6 @@ public class LeafPsiElement extends LeafElementImpl implements PsiElement {
return result;
}
public void checkReplace(PsiElement newElement) throws IncorrectOperationException {
CheckUtil.checkWritable(this);
}
public String toString() {
return "PsiElement" + "(" + getElementType().toString() + ")";
}
@@ -18,21 +18,6 @@ public class PsiErrorElementImpl extends CompositePsiElement implements PsiError
return myErrorDescription;
}
public String getExpectedToken() {
//TODO: hack should be specified when error element is created. Just give it a try
if (myErrorDescription.indexOf("expected") >= 0) {
if (myErrorDescription.toLowerCase().indexOf("statement") >= 0) return "{}";
int startApos = myErrorDescription.indexOf("\'");
if (startApos >= 0) {
int stopApos = myErrorDescription.indexOf("\'", startApos + 1);
if (stopApos >= 0) {
return myErrorDescription.substring(startApos + 1, stopApos);
}
}
}
return null;
}
public void accept(PsiElementVisitor visitor){
visitor.visitErrorElement(this);
}