This commit is contained in:
Alexey Kudravtsev
2014-05-14 15:05:12 +04:00
parent 9accb24785
commit 4a8f5f889e
32 changed files with 125 additions and 74 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 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,7 +23,7 @@ import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull;
public class PsiDocTokenImpl extends LeafPsiElement implements PsiDocToken{
public PsiDocTokenImpl(IElementType type, CharSequence text) {
public PsiDocTokenImpl(@NotNull IElementType type, CharSequence text) {
super(type, text);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -27,6 +27,7 @@ import com.intellij.psi.impl.source.tree.java.PsiKeywordImpl;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.java.IJavaDocElementType;
import com.intellij.psi.tree.java.IJavaElementType;
import org.jetbrains.annotations.NotNull;
/**
* @author yole
@@ -35,7 +36,7 @@ public class CoreJavaASTFactory extends ASTFactory implements Constants {
private final DefaultASTFactory myDefaultASTFactory = ServiceManager.getService(DefaultASTFactory.class);
@Override
public LeafElement createLeaf(final IElementType type, final CharSequence text) {
public LeafElement createLeaf(@NotNull final IElementType type, final CharSequence text) {
if (type == C_STYLE_COMMENT || type == END_OF_LINE_COMMENT) {
return myDefaultASTFactory.createComment(type, text);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 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,7 +23,7 @@ import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull;
public class PsiJavaTokenImpl extends LeafPsiElement implements PsiJavaToken{
public PsiJavaTokenImpl(IElementType type, CharSequence text) {
public PsiJavaTokenImpl(@NotNull IElementType type, CharSequence text) {
super(type, text);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -27,7 +27,7 @@ import org.jetbrains.annotations.NotNull;
import java.lang.reflect.Field;
public class PsiKeywordImpl extends LeafPsiElement implements PsiKeyword, PsiJavaToken {
public PsiKeywordImpl(IElementType type, CharSequence text) {
public PsiKeywordImpl(@NotNull IElementType type, CharSequence text) {
super(type, text);
}
@@ -25,6 +25,7 @@
package org.jetbrains.lang.manifest.psi.impl;
import com.intellij.psi.impl.source.tree.LeafPsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.lang.manifest.psi.ManifestToken;
import org.jetbrains.lang.manifest.psi.ManifestTokenType;
@@ -32,7 +33,7 @@ import org.jetbrains.lang.manifest.psi.ManifestTokenType;
* @author Robert F. Beeger (robert@beeger.net)
*/
public class ManifestTokenImpl extends LeafPsiElement implements ManifestToken {
public ManifestTokenImpl(ManifestTokenType type, CharSequence text) {
public ManifestTokenImpl(@NotNull ManifestTokenType type, CharSequence text) {
super(type, text);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2014 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(final IElementType type, final CharSequence text) {
public LeafElement createLeaf(@NotNull final IElementType type, final CharSequence text) {
final Language lang = type.getLanguage();
final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(lang);
if (parserDefinition != null) {
@@ -61,7 +61,7 @@ public class CoreASTFactory extends ASTFactory implements DefaultASTFactory {
}
@Override
public LeafElement createComment(IElementType type, CharSequence text) {
public LeafElement createComment(@NotNull IElementType type, CharSequence text) {
return new PsiCoreCommentImpl(type, text);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -46,7 +46,7 @@ public abstract class ASTFactory {
}
@Nullable
public LeafElement createLeaf(final IElementType type, final CharSequence text) {
public LeafElement createLeaf(@NotNull IElementType type, final CharSequence text) {
return null;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -20,17 +20,19 @@
package com.intellij.lang;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull;
public class TokenWrapper extends IElementType {
private final IElementType myDelegate;
private final String myValue;
public TokenWrapper(IElementType delegate, CharSequence value) {
public TokenWrapper(@NotNull IElementType delegate, CharSequence value) {
super("Wrapper", delegate.getLanguage(), false);
myDelegate = delegate;
myValue = value.toString();
}
@NotNull
public IElementType getDelegate() {
return myDelegate;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -30,7 +30,7 @@ import org.jetbrains.annotations.Nullable;
public class Factory {
private Factory() {}
public static LeafElement createSingleLeafElement(IElementType type, CharSequence buffer, int startOffset, int endOffset, CharTable table, PsiManager manager, PsiFile originalFile) {
public static LeafElement createSingleLeafElement(@NotNull IElementType type, CharSequence buffer, int startOffset, int endOffset, CharTable table, PsiManager manager, PsiFile originalFile) {
DummyHolder dummyHolder = DummyHolderFactory.createHolder(manager, table, type.getLanguage());
dummyHolder.setOriginalFile(originalFile);
@@ -43,7 +43,7 @@ public class Factory {
return newElement;
}
public static LeafElement createSingleLeafElement(IElementType type, CharSequence buffer, int startOffset, int endOffset, CharTable table, PsiManager manager, boolean generatedFlag) {
public static LeafElement createSingleLeafElement(@NotNull IElementType type, CharSequence buffer, int startOffset, int endOffset, CharTable table, PsiManager manager, boolean generatedFlag) {
final FileElement holderElement = DummyHolderFactory.createHolder(manager, table, type.getLanguage()).getTreeElement();
final LeafElement newElement = ASTFactory.leaf(type, holderElement.getCharTable().intern(
buffer, startOffset, endOffset));
@@ -52,11 +52,11 @@ public class Factory {
return newElement;
}
public static LeafElement createSingleLeafElement(IElementType type, CharSequence buffer, CharTable table, PsiManager manager) {
public static LeafElement createSingleLeafElement(@NotNull IElementType type, CharSequence buffer, CharTable table, PsiManager manager) {
return createSingleLeafElement(type, buffer, 0, buffer.length(), table, manager);
}
public static LeafElement createSingleLeafElement(IElementType type, CharSequence buffer, int startOffset, int endOffset, @Nullable CharTable table, PsiManager manager) {
public static LeafElement createSingleLeafElement(@NotNull IElementType type, CharSequence buffer, int startOffset, int endOffset, @Nullable CharTable table, PsiManager manager) {
return createSingleLeafElement(type, buffer, startOffset, endOffset, table, manager, true);
}
@@ -65,7 +65,7 @@ public class Factory {
}
@NotNull
public static CompositeElement createCompositeElement(final IElementType type,
public static CompositeElement createCompositeElement(@NotNull IElementType type,
final CharTable charTableByTree,
final PsiManager manager) {
final FileElement treeElement = DummyHolderFactory.createHolder(manager, null, charTableByTree).getTreeElement();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -28,12 +28,13 @@ import org.jetbrains.annotations.NotNull;
public class ForeignLeafPsiElement extends LeafPsiElement {
private final ForeignLeafType myForeignType;
public ForeignLeafPsiElement(ForeignLeafType type, CharSequence text) {
public ForeignLeafPsiElement(@NotNull ForeignLeafType type, CharSequence text) {
super(dereferenceElementType(type.getDelegate()), text);
myForeignType = type;
}
private static IElementType dereferenceElementType(IElementType type) {
@NotNull
private static IElementType dereferenceElementType(@NotNull IElementType type) {
while ( type instanceof TokenWrapper)
type = (( TokenWrapper ) type ).getDelegate();
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -37,7 +37,7 @@ public abstract class LeafElement extends TreeElement {
private final CharSequence myText;
protected LeafElement(IElementType type, CharSequence text) {
protected LeafElement(@NotNull IElementType type, CharSequence text) {
super(type);
myText = text;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -41,12 +41,12 @@ import org.jetbrains.annotations.NotNull;
public class LeafPsiElement extends LeafElement implements PsiElement, NavigationItem {
private static final Logger LOG = Logger.getInstance("#com.intellij.psi.impl.source.tree.LeafPsiElement");
public LeafPsiElement(IElementType type, CharSequence text) {
public LeafPsiElement(@NotNull IElementType type, CharSequence text) {
super(type, text);
}
@Deprecated
public LeafPsiElement(IElementType type, CharSequence buffer, int startOffset, int endOffset, CharTable table) {
public LeafPsiElement(@NotNull IElementType type, CharSequence buffer, int startOffset, int endOffset, CharTable table) {
super(type, table.intern(buffer, startOffset, endOffset));
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 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(IElementType type, CharSequence text) {
public OwnBufferLeafPsiElement(@NotNull IElementType type, CharSequence text) {
super(type, text);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 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,13 +22,14 @@ package com.intellij.psi.impl.source.tree;
import com.intellij.lang.ASTFactory;
import com.intellij.psi.PlainTextTokenTypes;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class PlainTextASTFactory extends ASTFactory {
@Override
@Nullable
public LeafElement createLeaf(final IElementType type, CharSequence text) {
public LeafElement createLeaf(@NotNull final IElementType type, CharSequence text) {
if (type == PlainTextTokenTypes.PLAIN_TEXT) {
return new PsiPlainTextImpl(text);
}
@@ -1,3 +1,18 @@
/*
* Copyright 2000-2014 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.psi.impl.source.tree;
import com.intellij.psi.PsiComment;
@@ -11,7 +26,7 @@ import org.jetbrains.annotations.NotNull;
* @author yole
*/
public class PsiCoreCommentImpl extends LeafPsiElement implements PsiComment {
public PsiCoreCommentImpl(IElementType type, CharSequence text) {
public PsiCoreCommentImpl(@NotNull IElementType type, CharSequence text) {
super(type, text);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -40,7 +40,7 @@ public abstract class TreeElement extends ElementBase implements ASTNode, Clonea
private final IElementType myType;
private volatile int myStartOffsetInParent = -1;
public TreeElement(IElementType type) {
public TreeElement(@NotNull IElementType type) {
myType = type;
}
@@ -390,6 +390,7 @@ public abstract class TreeElement extends ElementBase implements ASTNode, Clonea
}
@Override
@NotNull
public IElementType getElementType() {
return myType;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 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,6 +18,7 @@ package com.intellij.psi.stubs;
import com.intellij.psi.PsiNamedElement;
import com.intellij.util.io.StringRef;
import org.jetbrains.annotations.NotNull;
/**
* @author yole
@@ -25,12 +26,12 @@ import com.intellij.util.io.StringRef;
public abstract class NamedStubBase<T extends PsiNamedElement> extends StubBase<T> implements NamedStub<T> {
private final StringRef myName;
protected NamedStubBase(StubElement parent, IStubElementType elementType, StringRef name) {
protected NamedStubBase(StubElement parent, @NotNull IStubElementType elementType, StringRef name) {
super(parent, elementType);
myName = name;
}
protected NamedStubBase(final StubElement parent, final IStubElementType elementType, final String name) {
protected NamedStubBase(final StubElement parent, @NotNull IStubElementType elementType, final String name) {
this(parent, elementType, StringRef.fromString(name));
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -19,10 +19,11 @@ import com.intellij.core.CoreASTFactory;
import com.intellij.psi.impl.source.tree.LeafElement;
import com.intellij.psi.impl.source.tree.PsiCommentImpl;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull;
public class DefaultASTFactoryImpl extends CoreASTFactory implements DefaultASTFactory {
@Override
public LeafElement createComment(IElementType type, CharSequence text) {
public LeafElement createComment(@NotNull IElementType type, CharSequence text) {
return new PsiCommentImpl(type, text);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -24,7 +24,7 @@ import org.jetbrains.annotations.NotNull;
* @author peter
*/
public class OuterLanguageElementImpl extends LeafPsiElement implements OuterLanguageElement {
public OuterLanguageElementImpl(IElementType type, CharSequence text) {
public OuterLanguageElementImpl(@NotNull IElementType type, CharSequence text) {
super(type, text);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -51,10 +51,10 @@ public class TemplateDataElementType extends IFileElementType implements ITempla
public static final LanguageExtension<TreePatcher> TREE_PATCHER = new LanguageExtension<TreePatcher>("com.intellij.lang.treePatcher", new SimpleTreePatcher());
private final IElementType myTemplateElementType;
private final IElementType myOuterElementType;
@NotNull private final IElementType myTemplateElementType;
@NotNull private final IElementType myOuterElementType;
public TemplateDataElementType(@NonNls String debugName, Language language, IElementType templateElementType, IElementType outerElementType) {
public TemplateDataElementType(@NonNls String debugName, Language language, @NotNull IElementType templateElementType, @NotNull IElementType outerElementType) {
super(debugName, language);
myTemplateElementType = templateElementType;
myOuterElementType = outerElementType;
@@ -188,7 +188,7 @@ public class TemplateDataElementType extends IFileElementType implements ITempla
}
protected OuterLanguageElementImpl createOuterLanguageElement(final Lexer lexer, final CharTable table,
final IElementType outerElementType) {
@NotNull IElementType outerElementType) {
final CharSequence buffer = lexer.getBufferSequence();
final int tokenStart = lexer.getTokenStart();
if (tokenStart < 0 || tokenStart > buffer.length()) {
@@ -27,6 +27,7 @@ import com.intellij.openapi.util.Key;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.tree.AstBufferUtil;
import com.intellij.psi.impl.source.tree.Factory;
import com.intellij.psi.infos.CandidateInfo;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.tree.IElementType;
@@ -92,7 +93,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static com.intellij.psi.impl.source.tree.Factory.createSingleLeafElement;
import static org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes.*;
import static org.jetbrains.plugins.groovy.lang.lexer.TokenSets.RELATIONS;
import static org.jetbrains.plugins.groovy.lang.lexer.TokenSets.SHIFT_SIGNS;
@@ -410,10 +410,12 @@ public class PsiImplUtil {
if (qName == null) return null;
final List<OrderEntry> orderEntries = idx.getOrderEntriesForFile(vFile);
PsiClass original = facade.findClass(qName, new GlobalSearchScope(facade.getProject()) {
@Override
public int compare(@NotNull VirtualFile file1, @NotNull VirtualFile file2) {
return 0;
}
@Override
public boolean contains(@NotNull VirtualFile file) {
// order for file and vFile has non empty intersection.
List<OrderEntry> entries = idx.getOrderEntriesForFile(file);
@@ -425,10 +427,12 @@ public class PsiImplUtil {
return false;
}
@Override
public boolean isSearchInModuleContent(@NotNull Module aModule) {
return false;
}
@Override
public boolean isSearchInLibraries() {
return true;
}
@@ -535,7 +539,7 @@ public class PsiImplUtil {
}
final String substring = text.substring(second);
container.getNode()
.replaceChild(node, createSingleLeafElement(type, substring, 0, substring.length(), null, container.getManager()));
.replaceChild(node, Factory.createSingleLeafElement(type, substring, 0, substring.length(), null, container.getManager()));
return;
}
else {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -44,7 +44,7 @@ public class GrFieldStub extends StubBase<GrField> implements NamedStub<GrField>
StringRef name,
final String[] annotations,
String[] namedParameters,
final IStubElementType elemType,
@NotNull IStubElementType elemType,
byte flags, @Nullable String typeText) {
super(parent, elemType);
myName = name;
@@ -54,6 +54,7 @@ public class GrFieldStub extends StubBase<GrField> implements NamedStub<GrField>
myTypeText = typeText;
}
@Override
@NotNull
public String getName() {
return StringRef.toString(myName);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 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,6 +18,7 @@ package org.jetbrains.plugins.groovy.lang.psi.stubs;
import com.intellij.psi.stubs.IStubElementType;
import com.intellij.psi.stubs.StubBase;
import com.intellij.psi.stubs.StubElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.imports.GrImportStatement;
@@ -33,7 +34,7 @@ public class GrImportStatementStub extends StubBase<GrImportStatement> implement
private final String myAliasName;
public GrImportStatementStub(StubElement parent,
IStubElementType elementType,
@NotNull IStubElementType elementType,
@Nullable String referenceText,
@Nullable String aliasName,
byte flags) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -40,8 +40,8 @@ public class GrMethodStub extends StubBase<GrMethod> implements NamedStub<GrMeth
public GrMethodStub(StubElement parent,
StringRef name,
final String[] annotations,
final @NotNull String[] namedParameters,
final GrMethodElementType elementType,
@NotNull final String[] namedParameters,
@NotNull GrMethodElementType elementType,
@Nullable String typeText,
byte flags) {
super(parent, elementType);
@@ -52,6 +52,7 @@ public class GrMethodStub extends StubBase<GrMethod> implements NamedStub<GrMeth
myFlags = flags;
}
@Override
@NotNull public String getName() {
return StringRef.toString(myName);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -19,6 +19,7 @@ import com.intellij.psi.stubs.IStubElementType;
import com.intellij.psi.stubs.StubBase;
import com.intellij.psi.stubs.StubElement;
import gnu.trove.TObjectIntIterator;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList;
import org.jetbrains.plugins.groovy.lang.psi.impl.auxiliary.modifiers.GrModifierListImpl;
@@ -28,7 +29,7 @@ import org.jetbrains.plugins.groovy.lang.psi.impl.auxiliary.modifiers.GrModifier
public class GrModifierListStub extends StubBase<GrModifierList> implements StubElement<GrModifierList> {
private final int myFlags;
public GrModifierListStub(StubElement parent, IStubElementType elementType, int flags) {
public GrModifierListStub(StubElement parent, @NotNull IStubElementType elementType, int flags) {
super(parent, elementType);
this.myFlags = flags;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -19,12 +19,13 @@ import com.intellij.psi.stubs.IStubElementType;
import com.intellij.psi.stubs.StubBase;
import com.intellij.psi.stubs.StubElement;
import com.intellij.util.io.StringRef;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.lang.psi.api.toplevel.packaging.GrPackageDefinition;
public class GrPackageDefinitionStub extends StubBase<GrPackageDefinition> implements StubElement<GrPackageDefinition> {
private final StringRef myPackageName;
public GrPackageDefinitionStub(StubElement parent, IStubElementType elementType, StringRef packageName) {
public GrPackageDefinitionStub(StubElement parent, @NotNull IStubElementType elementType, StringRef packageName) {
super(parent, elementType);
this.myPackageName = packageName;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 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,6 +18,7 @@ package org.jetbrains.plugins.groovy.lang.psi.stubs;
import com.intellij.psi.stubs.IStubElementType;
import com.intellij.psi.stubs.StubBase;
import com.intellij.psi.stubs.StubElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrReferenceList;
/**
@@ -27,7 +28,7 @@ public class GrReferenceListStub extends StubBase<GrReferenceList> implements St
private final String[] myRefNames;
public GrReferenceListStub(final StubElement parentStub, IStubElementType elemtType, final String[] refNames) {
public GrReferenceListStub(final StubElement parentStub, @NotNull IStubElementType elemtType, final String[] refNames) {
super(parentStub, elemtType);
myRefNames = refNames;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2014 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,6 +21,7 @@ import com.intellij.psi.stubs.NamedStub;
import com.intellij.psi.stubs.StubBase;
import com.intellij.psi.stubs.StubElement;
import com.intellij.util.io.StringRef;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrAnonymousClassDefinition;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
@@ -45,7 +46,7 @@ public class GrTypeDefinitionStub extends StubBase<GrTypeDefinition> implements
public GrTypeDefinitionStub(StubElement parent,
final String name,
final String[] supers,
final IStubElementType elementType,
@NotNull IStubElementType elementType,
final String qualifiedName,
String[] annotations,
byte flags) {
@@ -61,6 +62,7 @@ public class GrTypeDefinitionStub extends StubBase<GrTypeDefinition> implements
return mySuperClasses;
}
@Override
public String getName() {
return StringRef.toString(myName);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -20,12 +20,14 @@ import com.intellij.lang.properties.parsing.PropertiesTokenTypes;
import com.intellij.psi.impl.source.tree.*;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.IFileElementType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @author cdr
*/
public class PropertiesASTFactory extends ASTFactory {
@Override
@Nullable
public CompositeElement createComposite(final IElementType type) {
if (type instanceof IFileElementType) {
@@ -34,8 +36,9 @@ public class PropertiesASTFactory extends ASTFactory {
return new CompositeElement(type);
}
@Override
@Nullable
public LeafElement createLeaf(final IElementType type, CharSequence text) {
public LeafElement createLeaf(@NotNull final IElementType type, CharSequence text) {
if (type == PropertiesTokenTypes.VALUE_CHARACTERS) {
return new PropertyValueImpl(type, text);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 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,15 +26,17 @@ import org.jetbrains.annotations.NotNull;
* @author cdr
*/
public class PropertyValueImpl extends LeafPsiElement {
public PropertyValueImpl(IElementType type, CharSequence text) {
public PropertyValueImpl(@NotNull IElementType type, CharSequence text) {
super(type, text);
}
@Override
@NotNull
public PsiReference[] getReferences() {
return ReferenceProvidersRegistry.getReferencesFromProviders(this, PropertyValueImpl.class);
}
@Override
public PsiReference getReference() {
PsiReference[] references = getReferences();
return references.length == 0 ? null : references[0];
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 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,10 +29,12 @@ import com.intellij.psi.templateLanguages.ITemplateDataElementType;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.ILazyParseableElementType;
import com.intellij.psi.tree.xml.IXmlLeafElementType;
import org.jetbrains.annotations.NotNull;
import static com.intellij.psi.xml.XmlElementType.*;
public class XmlASTFactory extends ASTFactory {
@Override
public CompositeElement createComposite(final IElementType type) {
if (type == XML_TAG) {
return new XmlTagImpl();
@@ -133,7 +135,8 @@ public class XmlASTFactory extends ASTFactory {
return null;
}
public LeafElement createLeaf(final IElementType type, CharSequence text) {
@Override
public LeafElement createLeaf(@NotNull final IElementType type, CharSequence text) {
if (type instanceof IXmlLeafElementType) {
if (type == XML_REAL_WHITE_SPACE) {
return new PsiWhiteSpaceImpl(text);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2014 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.
@@ -31,14 +31,16 @@ import org.jetbrains.annotations.NotNull;
* @author ik
*/
public class XmlTokenImpl extends LeafPsiElement implements XmlToken, Navigatable {
public XmlTokenImpl(IElementType type, CharSequence text) {
public XmlTokenImpl(@NotNull IElementType type, CharSequence text) {
super(type, text);
}
@Override
public boolean processElements(PsiElementProcessor processor, PsiElement place) {
return false;
}
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof XmlElementVisitor) {
((XmlElementVisitor)visitor).visitXmlToken(this);
@@ -57,10 +59,12 @@ public class XmlTokenImpl extends LeafPsiElement implements XmlToken, Navigatabl
// Implementation specific
@Override
public IElementType getTokenType() {
return getElementType();
}
@Override
@NotNull
public PsiReference[] getReferences() {
final IElementType elementType = getElementType();
@@ -79,6 +83,7 @@ public class XmlTokenImpl extends LeafPsiElement implements XmlToken, Navigatabl
return super.getReferences();
}
@Override
public void navigate(boolean requestFocus) {
Navigatable descriptor = PsiNavigationSupport.getInstance().getDescriptor(this);
if (descriptor != null) {
@@ -86,10 +91,12 @@ public class XmlTokenImpl extends LeafPsiElement implements XmlToken, Navigatabl
}
}
@Override
public boolean canNavigate() {
return getTokenType() == XmlTokenType.XML_NAME && PsiNavigationSupport.getInstance().canNavigate(this);
}
@Override
public boolean canNavigateToSource() {
return canNavigate();
}