This commit is contained in:
Alexey Kudravtsev
2015-04-29 13:00:05 +03:00
parent c8f734e70c
commit da334f7ab2
24 changed files with 89 additions and 71 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -25,16 +25,17 @@ import com.intellij.psi.PsiType;
import com.intellij.psi.impl.source.tree.ElementType;
import com.intellij.psi.impl.source.tree.JavaElementType;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class PsiExpressionCodeFragmentImpl extends PsiCodeFragmentImpl implements PsiExpressionCodeFragment {
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.PsiExpressionCodeFragmentImpl");
private PsiType myExpectedType;
public PsiExpressionCodeFragmentImpl(Project project,
public PsiExpressionCodeFragmentImpl(@NotNull Project project,
boolean isPhysical,
@NonNls String name,
CharSequence text,
@NotNull CharSequence text,
@Nullable final PsiType expectedType,
@Nullable PsiElement context) {
super(project, JavaElementType.EXPRESSION_TEXT, isPhysical, name, text, context);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -23,6 +23,7 @@ import com.intellij.psi.PsiJavaCodeReferenceElement;
import com.intellij.psi.impl.source.tree.CompositeElement;
import com.intellij.psi.impl.source.tree.JavaElementType;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
@@ -32,10 +33,10 @@ public class PsiJavaCodeReferenceCodeFragmentImpl extends PsiCodeFragmentImpl im
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.PsiJavaCodeReferenceCodeFragmentImpl");
private final boolean myIsClassesAccepted;
public PsiJavaCodeReferenceCodeFragmentImpl(final Project project,
public PsiJavaCodeReferenceCodeFragmentImpl(@NotNull Project project,
final boolean isPhysical,
@NonNls final String name,
final CharSequence text,
@NonNls @NotNull String name,
@NotNull CharSequence text,
boolean isClassesAccepted,
@Nullable PsiElement context) {
super(project, JavaElementType.REFERENCE_TEXT, isPhysical, name, text, context);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -36,7 +36,7 @@ public class CoreJavaASTFactory extends ASTFactory implements Constants {
private final DefaultASTFactory myDefaultASTFactory = ServiceManager.getService(DefaultASTFactory.class);
@Override
public LeafElement createLeaf(@NotNull final IElementType type, final CharSequence text) {
public LeafElement createLeaf(@NotNull final IElementType type, @NotNull final CharSequence text) {
if (type == C_STYLE_COMMENT || type == END_OF_LINE_COMMENT) {
return myDefaultASTFactory.createComment(type, text);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -60,7 +60,7 @@ public interface JavaDocElementType {
}
@Override
public ASTNode createNode(final CharSequence text) {
public ASTNode createNode(CharSequence text) {
return new LazyParseablePsiElement(this, text);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -105,7 +105,7 @@ public abstract class JavaParsingTestCase extends ParsingTestCase {
return new PsiJavaFileImpl(viewProvider) {
@NotNull
@Override
protected FileElement createFileElement(final CharSequence text) {
protected FileElement createFileElement(@NotNull final CharSequence text) {
return new FileElement(TEST_FILE_ELEMENT_TYPE, text);
}
};
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -39,30 +39,30 @@ public class LightVirtualFile extends LightVirtualFileBase {
this("");
}
public LightVirtualFile(@NonNls String name) {
public LightVirtualFile(@NonNls @NotNull String name) {
this(name, "");
}
public LightVirtualFile(@NonNls String name, CharSequence content) {
public LightVirtualFile(@NonNls @NotNull String name, @NotNull CharSequence content) {
this(name, null, content, LocalTimeCounter.currentTime());
}
public LightVirtualFile(final String name, final FileType fileType, final CharSequence text) {
public LightVirtualFile(@NotNull String name, final FileType fileType, @NotNull CharSequence text) {
this(name, fileType, text, LocalTimeCounter.currentTime());
}
public LightVirtualFile(VirtualFile original, final CharSequence text, long modificationStamp) {
public LightVirtualFile(VirtualFile original, @NotNull CharSequence text, long modificationStamp) {
this(original.getName(), original.getFileType(), text, modificationStamp);
setCharset(original.getCharset());
}
public LightVirtualFile(final String name, final FileType fileType, final CharSequence text, final long modificationStamp) {
public LightVirtualFile(@NotNull String name, final FileType fileType, @NotNull CharSequence text, final long modificationStamp) {
this(name, fileType, text, CharsetUtil.extractCharsetFromFileContent(null, null, fileType, text), modificationStamp);
}
public LightVirtualFile(final String name,
public LightVirtualFile(@NotNull String name,
final FileType fileType,
final CharSequence text,
@NotNull CharSequence text,
Charset charset,
final long modificationStamp) {
super(name, fileType, modificationStamp);
@@ -70,7 +70,7 @@ public class LightVirtualFile extends LightVirtualFileBase {
setCharset(charset);
}
public LightVirtualFile(final String name, final Language language, final CharSequence text) {
public LightVirtualFile(@NotNull String name, final Language language, @NotNull CharSequence text) {
super(name, null, LocalTimeCounter.currentTime());
setContent(text);
setLanguage(language);
@@ -121,16 +121,17 @@ public class LightVirtualFile extends LightVirtualFileBase {
return s.getBytes(charset.name());
}
public void setContent(Object requestor, CharSequence content, boolean fireEvent) {
public void setContent(Object requestor, @NotNull CharSequence content, boolean fireEvent) {
setContent(content);
setModificationStamp(LocalTimeCounter.currentTime());
}
private void setContent(CharSequence content) {
private void setContent(@NotNull CharSequence content) {
//StringUtil.assertValidSeparators(content);
myContent = content;
}
@NotNull
public CharSequence getContent() {
return myContent;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -48,7 +48,7 @@ public class CoreASTFactory extends ASTFactory implements DefaultASTFactory {
@Override
@NotNull
public LeafElement createLeaf(@NotNull final IElementType type, final CharSequence text) {
public LeafElement createLeaf(@NotNull final IElementType type, @NotNull final CharSequence text) {
final Language lang = type.getLanguage();
final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(lang);
if (parserDefinition != null) {
@@ -60,8 +60,9 @@ public class CoreASTFactory extends ASTFactory implements DefaultASTFactory {
return new LeafPsiElement(type, text);
}
@NotNull
@Override
public LeafElement createComment(@NotNull IElementType type, CharSequence text) {
public LeafElement createComment(@NotNull IElementType type, @NotNull CharSequence text) {
return new PsiCoreCommentImpl(type, text);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -21,8 +21,14 @@ import com.intellij.psi.impl.source.CharTableImpl;
import com.intellij.psi.impl.source.CodeFragmentElement;
import com.intellij.psi.impl.source.DummyHolderElement;
import com.intellij.psi.impl.source.codeStyle.CodeEditUtil;
import com.intellij.psi.impl.source.tree.*;
import com.intellij.psi.tree.*;
import com.intellij.psi.impl.source.tree.CompositeElement;
import com.intellij.psi.impl.source.tree.LazyParseableElement;
import com.intellij.psi.impl.source.tree.LeafElement;
import com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl;
import com.intellij.psi.tree.ICompositeElementType;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.ILazyParseableElementType;
import com.intellij.psi.tree.ILeafElementType;
import com.intellij.util.CharTable;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -46,14 +52,14 @@ public abstract class ASTFactory {
}
@Nullable
public LeafElement createLeaf(@NotNull IElementType type, final CharSequence text) {
public LeafElement createLeaf(@NotNull IElementType type, @NotNull CharSequence text) {
return null;
}
// factory methods
@NotNull
public static LazyParseableElement lazy(@NotNull final ILazyParseableElementType type, final CharSequence text) {
public static LazyParseableElement lazy(@NotNull final ILazyParseableElementType type, CharSequence text) {
final ASTNode node = type.createNode(text);
if (node != null) return (LazyParseableElement)node;
@@ -79,7 +85,7 @@ public abstract class ASTFactory {
}
@NotNull
public static LeafElement leaf(@NotNull final IElementType type, final CharSequence text) {
public static LeafElement leaf(@NotNull final IElementType type, @NotNull CharSequence text) {
if (type == TokenType.WHITE_SPACE) {
return new PsiWhiteSpaceImpl(text);
}
@@ -105,11 +111,7 @@ public abstract class ASTFactory {
}
public static class DefaultFactoryHolder {
public static final ASTFactory DEFAULT = def();
private static ASTFactory def() {
return (ASTFactory)ServiceManager.getService(DefaultASTFactory.class);
}
public static final ASTFactory DEFAULT = (ASTFactory)ServiceManager.getService(DefaultASTFactory.class);
private DefaultFactoryHolder() {
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -17,6 +17,7 @@ package com.intellij.lang;
import com.intellij.psi.impl.source.tree.LeafElement;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull;
/**
* Marker interface for retrieving the service which provides a default implementation of ASTFactory.
@@ -24,5 +25,6 @@ import com.intellij.psi.tree.IElementType;
* @author yole
*/
public interface DefaultASTFactory {
LeafElement createComment(IElementType type, CharSequence text);
@NotNull
LeafElement createComment(@NotNull IElementType type, @NotNull CharSequence text);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -25,7 +25,7 @@ import com.intellij.psi.tree.ILeafElementType;
import org.jetbrains.annotations.NotNull;
public class ForeignLeafType extends TokenWrapper implements ILeafElementType {
public ForeignLeafType(IElementType delegate, CharSequence value) {
public ForeignLeafType(@NotNull IElementType delegate, @NotNull CharSequence value) {
super(delegate, value);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -26,7 +26,7 @@ public class TokenWrapper extends IElementType {
private final IElementType myDelegate;
private final String myValue;
public TokenWrapper(@NotNull IElementType delegate, CharSequence value) {
public TokenWrapper(@NotNull IElementType delegate, @NotNull CharSequence value) {
super("Wrapper", delegate.getLanguage(), false);
myDelegate = delegate;
myValue = value.toString();
@@ -21,6 +21,7 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.progress.EmptyProgressIndicator;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.ProgressIndicatorProvider;
import com.intellij.openapi.project.Project;
@@ -150,6 +151,9 @@ public class PomModelImpl extends UserDataHolderBase implements PomModel {
transaction.run();
event = transaction.getAccumulatedEvent();
}
catch (ProcessCanceledException e) {
throw e;
}
catch(Exception e){
LOG.error(e);
return;
@@ -186,6 +190,9 @@ public class PomModelImpl extends UserDataHolderBase implements PomModel {
}
}
}
catch (ProcessCanceledException e) {
throw e;
}
catch (Throwable t) {
throwables.add(t);
}
@@ -193,6 +200,9 @@ public class PomModelImpl extends UserDataHolderBase implements PomModel {
try {
commitTransaction(transaction);
}
catch (ProcessCanceledException e) {
throw e;
}
catch (Throwable t) {
throwables.add(t);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -108,7 +108,8 @@ public class PsiFileFactoryImpl extends PsiFileFactory {
}
@Nullable
public PsiFile trySetupPsiForFile(final LightVirtualFile virtualFile, Language language,
public PsiFile trySetupPsiForFile(@NotNull LightVirtualFile virtualFile,
@NotNull Language language,
final boolean physical, final boolean markAsCopy) {
final FileViewProviderFactory factory = LanguageFileViewProviders.INSTANCE.forLanguage(language);
FileViewProvider viewProvider = factory != null ? factory.createFileViewProvider(virtualFile, language, myManager, physical) : null;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -18,9 +18,10 @@ package com.intellij.psi.impl.source;
import com.intellij.psi.TokenType;
import com.intellij.psi.impl.source.tree.FileElement;
import org.jetbrains.annotations.NotNull;
public class DummyHolderElement extends FileElement {
public DummyHolderElement(CharSequence text) {
public DummyHolderElement(@NotNull CharSequence text) {
super(TokenType.DUMMY_HOLDER, text);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -55,17 +55,13 @@ public class FileElement extends LazyParseableElement implements FileASTNode, Ge
final IFileElementType contentType = (IFileElementType)getElementType();
assert contentType instanceof ILightStubFileElementType:contentType;
LighterAST tree;
if (!isParsed()) {
return new FCTSBackedLighterAST(getCharTable(), ((ILightStubFileElementType<?>)contentType).parseContentsLight(this));
}
else {
tree = new TreeBackedLighterAST(this);
}
return tree;
return new TreeBackedLighterAST(this);
}
public FileElement(IElementType type, CharSequence text) {
public FileElement(@NotNull IElementType type, CharSequence text) {
super(type, text);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -35,7 +35,7 @@ import org.jetbrains.annotations.NotNull;
public class OwnBufferLeafPsiElement extends LeafElement implements PsiElement {
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.tree.LeafPsiElement");
public OwnBufferLeafPsiElement(@NotNull IElementType type, CharSequence text) {
public OwnBufferLeafPsiElement(@NotNull IElementType type, @NotNull CharSequence text) {
super(type, text);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -29,7 +29,7 @@ public class PlainTextASTFactory extends ASTFactory {
@Override
@Nullable
public LeafElement createLeaf(@NotNull final IElementType type, CharSequence text) {
public LeafElement createLeaf(@NotNull final IElementType type, @NotNull CharSequence text) {
if (type == PlainTextTokenTypes.PLAIN_TEXT) {
return new PsiPlainTextImpl(text);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -22,7 +22,7 @@ import com.intellij.psi.PsiPlainText;
import org.jetbrains.annotations.NotNull;
public class PsiPlainTextImpl extends OwnBufferLeafPsiElement implements PsiPlainText {
protected PsiPlainTextImpl(CharSequence text) {
protected PsiPlainTextImpl(@NotNull CharSequence text) {
super(PlainTextTokenTypes.PLAIN_TEXT, text);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -23,6 +23,7 @@ import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.IStubFileElementType;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
@@ -49,7 +50,7 @@ public abstract class SerializationManager {
}
final IElementType[] stubElementTypes = IElementType.enumerate(new IElementType.Predicate() {
@Override
public boolean matches(final IElementType type) {
public boolean matches(@NotNull final IElementType type) {
return type instanceof StubSerializer;
}
});
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -22,8 +22,9 @@ import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull;
public class DefaultASTFactoryImpl extends CoreASTFactory implements DefaultASTFactory {
@NotNull
@Override
public LeafElement createComment(@NotNull IElementType type, CharSequence text) {
public LeafElement createComment(@NotNull IElementType type, @NotNull CharSequence text) {
return new PsiCommentImpl(type, text);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -38,7 +38,7 @@ public class PropertiesASTFactory extends ASTFactory {
@Override
@Nullable
public LeafElement createLeaf(@NotNull final IElementType type, CharSequence text) {
public LeafElement createLeaf(@NotNull final IElementType type, @NotNull CharSequence text) {
if (type == PropertiesTokenTypes.KEY_CHARACTERS) {
return new PropertyKeyImpl(type, text);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -151,7 +151,7 @@ public class PythonFormattingModelBuilder implements FormattingModelBuilderEx, C
final PythonLanguage pythonLanguage = PythonLanguage.getInstance();
return TokenSet.create(IElementType.enumerate(new IElementType.Predicate() {
@Override
public boolean matches(IElementType type) {
public boolean matches(@NotNull IElementType type) {
return type != LAMBDA_KEYWORD && type.getLanguage().isKindOf(pythonLanguage);
}
}));
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@@ -136,7 +136,7 @@ public class XmlASTFactory extends ASTFactory {
}
@Override
public LeafElement createLeaf(@NotNull final IElementType type, CharSequence text) {
public LeafElement createLeaf(@NotNull final IElementType type, @NotNull CharSequence text) {
if (type instanceof IXmlLeafElementType) {
if (type == XML_REAL_WHITE_SPACE) {
return new PsiWhiteSpaceImpl(text);