本文整理汇总了Java中com.intellij.psi.PsiInvalidElementAccessException类的典型用法代码示例。如果您正苦于以下问题:Java PsiInvalidElementAccessException类的具体用法?Java PsiInvalidElementAccessException怎么用?Java PsiInvalidElementAccessException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PsiInvalidElementAccessException类属于com.intellij.psi包,在下文中一共展示了PsiInvalidElementAccessException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isValid
import com.intellij.psi.PsiInvalidElementAccessException; //导入依赖的package包/类
private static boolean isValid(JSObjectLiteralExpression expression) {
if (expression == null) {
return false;
}
try {
PsiFile file = expression.getContainingFile();
if (file == null) {
return false;
}
} catch (PsiInvalidElementAccessException e) {
return false;
}
JSProperty data = expression.findProperty("data");
if (data == null || data.getValue() == null) {
return false;
}
return true;
}
示例2: getExportsEndOffset
import com.intellij.psi.PsiInvalidElementAccessException; //导入依赖的package包/类
public static int getExportsEndOffset(PsiElement anyElementOnWeexScript, String name) {
JSObjectLiteralExpression exports = getExportsStatement(anyElementOnWeexScript);
if (exports != null) {
try {
PsiFile file = exports.getContainingFile();
if (file == null) {
return -1;
}
} catch (PsiInvalidElementAccessException e) {
return -1;
}
JSProperty data = exports.findProperty(name);
if (data == null || data.getValue() == null) {
return -1;
}
return data.getValue().getTextRange().getEndOffset() - 1;
}
return -1;
}
示例3: getNode
import com.intellij.psi.PsiInvalidElementAccessException; //导入依赖的package包/类
/**
* Ensures this element is AST-based. This is an expensive operation that might take significant time and allocate lots of objects,
* so it should be to be avoided if possible.
*
* @return an AST node corresponding to this element. If the element is currently operating via stubs,
* this causes AST to be loaded for the whole file and all stub-based PSI elements in this file (including the current one)
* to be switched from stub to AST. So, after this call {@link #getStub()} will return null.
*/
@Override
@NotNull
public ASTNode getNode() {
ASTNode node = myNode;
if (node == null) {
ApplicationManager.getApplication().assertReadAccessAllowed();
PsiFileImpl file = (PsiFileImpl)getContainingFile();
if (!file.isValid()) throw new PsiInvalidElementAccessException(this);
FileElement treeElement = file.getTreeElement();
if (treeElement != null && myNode == null) {
return notBoundInExistingAst(file, treeElement);
}
treeElement = file.calcTreeElement();
node = myNode;
if (node == null) {
return failedToBindStubToAst(file, treeElement);
}
}
return node;
}
示例4: resolveNameInFromImport
import com.intellij.psi.PsiInvalidElementAccessException; //导入依赖的package包/类
public static List<RatedResolveResult> resolveNameInFromImport(PyFromImportStatement importStatement, @NotNull QualifiedName qName) {
PsiFile file = importStatement.getContainingFile().getOriginalFile();
String name = qName.getComponents().get(0);
final List<PsiElement> candidates = importStatement.resolveImportSourceCandidates();
List<PsiElement> resultList = new ArrayList<PsiElement>();
for (PsiElement candidate : candidates) {
if (!candidate.isValid()) {
throw new PsiInvalidElementAccessException(candidate, "Got an invalid candidate from resolveImportSourceCandidates(): " + candidate.getClass());
}
if (candidate instanceof PsiDirectory) {
candidate = PyUtil.getPackageElement((PsiDirectory)candidate, importStatement);
}
PsiElement result = resolveChild(candidate, name, file, false, true);
if (result != null) {
if (!result.isValid()) {
throw new PsiInvalidElementAccessException(result, "Got an invalid candidate from resolveChild(): " + result.getClass());
}
resultList.add(result);
}
}
if (!resultList.isEmpty()) {
return rateResults(resultList);
}
return Collections.emptyList();
}
示例5: getNamespaceString
import com.intellij.psi.PsiInvalidElementAccessException; //导入依赖的package包/类
@NotNull
public static String getNamespaceString(@NotNull PsiElement element, boolean inParens) {
Qn namespace;
if (element instanceof SchemaTypeDef) {
SchemaTypeDef typeDef = (SchemaTypeDef) element;
namespace = typeDef.getNamespace();
} else {
namespace = NamespaceManager.getNamespace(element);
}
if (namespace != null) return inParens ? "(" + namespace.toString() + ')' : namespace.toString();
try {
PsiFile containingFile = element.getContainingFile();
if (containingFile == null) return "[invalid]";
return inParens ? "(" + containingFile.getName() + ')' : containingFile.getName();
} catch (PsiInvalidElementAccessException e) {
return "[invalid]"; // file not available
}
}
示例6: variantsViaQuery
import com.intellij.psi.PsiInvalidElementAccessException; //导入依赖的package包/类
@NotNull
private Object[] variantsViaQuery(@NotNull final Query<PsiClass> query) {
final List<LookupElement> variants = new LinkedList<LookupElement>();
final Project project = getElement().getProject();
for(final PsiClass klass : query.findAll()) {
if(klass == null) {
continue;
}
try {
variants.add(
LookupElementBuilder.create(klass).
withInsertHandler(QualifiedClassNameInsertHandler.INSTANCE).
withIcon(IconUtil.getIcon(klass.getContainingFile().getVirtualFile(), 0, project)).
withTypeText(klass.getContainingFile().getName()));
} catch(final PsiInvalidElementAccessException invalidElementAccess) {
LOG.error(invalidElementAccess);
}
}
return variants.toArray(new Object[variants.size()]);
}
示例7: getNode
import com.intellij.psi.PsiInvalidElementAccessException; //导入依赖的package包/类
@Override
@NotNull
public ASTNode getNode() {
ASTNode node = myNode;
if (node == null) {
ApplicationManager.getApplication().assertReadAccessAllowed();
PsiFileImpl file = (PsiFileImpl)getContainingFile();
if (!file.isValid()) throw new PsiInvalidElementAccessException(this);
FileElement treeElement = file.getTreeElement();
StubTree stubTree = file.getStubTree();
if (treeElement != null && myNode == null) {
return notBoundInExistingAst(file, treeElement, stubTree);
}
final FileElement fileElement = file.calcTreeElement();
node = myNode;
if (node == null) {
return failedToBindStubToAst(file, stubTree, fileElement);
}
}
return node;
}
示例8: getNode
import com.intellij.psi.PsiInvalidElementAccessException; //导入依赖的package包/类
/**
* Ensures this element is AST-based. This is an expensive operation that might take significant time and allocate lots of objects,
* so it should be to be avoided if possible.
*
* @return an AST node corresponding to this element. If the element is currently operating via stubs,
* this causes AST to be loaded for the whole file and all stub-based PSI elements in this file (including the current one)
* to be switched from stub to AST. So, after this call {@link #getStub()} will return null.
*/
@Override
@Nonnull
public ASTNode getNode() {
if (mySubstrateRef instanceof SubstrateRef.StubRef) {
ApplicationManager.getApplication().assertReadAccessAllowed();
PsiFileImpl file = (PsiFileImpl)getContainingFile();
if (!file.isValid()) throw new PsiInvalidElementAccessException(this);
FileElement treeElement = file.getTreeElement();
if (treeElement != null && mySubstrateRef instanceof SubstrateRef.StubRef) {
return notBoundInExistingAst(file, treeElement);
}
treeElement = file.calcTreeElement();
if (mySubstrateRef instanceof SubstrateRef.StubRef) {
return failedToBindStubToAst(file, treeElement);
}
}
return mySubstrateRef.getNode();
}
示例9: getManager
import com.intellij.psi.PsiInvalidElementAccessException; //导入依赖的package包/类
@Override
public PsiManagerEx getManager() {
Project project = ProjectCoreUtil.theOnlyOpenProject();
if (project != null) {
return PsiManagerEx.getInstanceEx(project);
}
PsiElement parent = this;
while (parent instanceof ASTDelegatePsiElement) {
parent = parent.getParent();
}
if (parent == null) {
throw new PsiInvalidElementAccessException(this);
}
return (PsiManagerEx)parent.getManager();
}
示例10: createInvalidRef
import com.intellij.psi.PsiInvalidElementAccessException; //导入依赖的package包/类
@Nonnull
static SubstrateRef createInvalidRef(@Nonnull final StubBasedPsiElementBase<?> psi) {
return new SubstrateRef() {
@Nonnull
@Override
public ASTNode getNode() {
throw new PsiInvalidElementAccessException(psi);
}
@Override
public boolean isValid() {
return false;
}
@Nonnull
@Override
public PsiFile getContainingFile() {
throw new PsiInvalidElementAccessException(psi);
}
};
}
示例11: safeGetLocale
import com.intellij.psi.PsiInvalidElementAccessException; //导入依赖的package包/类
private static Locale safeGetLocale(final @NotNull IProperty property) {
try {
PropertiesFile file = property.getPropertiesFile();
return file == null ? null : file.getLocale();
} catch (PsiInvalidElementAccessException e) {
return null;
}
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:9,代码来源:JspPropertyFoldingBuilder.java
示例12: getVarDeclaration
import com.intellij.psi.PsiInvalidElementAccessException; //导入依赖的package包/类
public static JSProperty getVarDeclaration(PsiElement anyElementOnWeexScript, String valueName) {
valueName = CodeUtil.getVarNameFromMustache(valueName);
JSObjectLiteralExpression exports = getExportsStatement(anyElementOnWeexScript);
vars.clear();
JSProperty ret = null;
if (exports != null) {
try {
PsiFile file = exports.getContainingFile();
if (file == null) {
return null;
}
} catch (PsiInvalidElementAccessException e) {
return null;
}
JSProperty data = exports.findProperty("data");
if (data == null || data.getValue() == null) {
return null;
}
for (PsiElement pe : data.getValue().getChildren()) {
if (pe instanceof JSProperty) {
String varName = ((JSProperty) pe).getName();
String varValue = getJSPropertyType((JSProperty) pe);
if (varName != null && varValue != null) {
vars.put(varName, varValue);
}
if (valueName.equals(varName)) {
ret = (JSProperty) pe;
}
}
}
}
return ret;
}
示例13: resolveExposed
import com.intellij.psi.PsiInvalidElementAccessException; //导入依赖的package包/类
@Nullable
public static PsiElement resolveExposed(PsiElement element, Function<ElmFile, PsiElement> resolveInFile) {
PsiFile file;
try {
file = element.getContainingFile();
} catch (PsiInvalidElementAccessException ex) {
return null;
}
return resolveExposed(file, resolveInFile);
}
示例14: getContainingFile
import com.intellij.psi.PsiInvalidElementAccessException; //导入依赖的package包/类
@Override
@NotNull
public PsiFile getContainingFile() {
StubElement stub = myStub;
if (stub != null) {
while (!(stub instanceof PsiFileStub)) {
stub = stub.getParentStub();
}
PsiFile psi = (PsiFile)stub.getPsi();
if (psi != null) {
return psi;
}
ApplicationManager.getApplication().assertReadAccessAllowed();
synchronized (PsiLock.LOCK) {
if (myStub != null) {
String reason = ((PsiFileStubImpl<?>)stub).getInvalidationReason();
PsiInvalidElementAccessException exception =
new PsiInvalidElementAccessException(this, "no psi for file stub " + stub + ", invalidation reason=" + reason, null);
if (PsiFileImpl.STUB_PSI_MISMATCH.equals(reason)) {
// we're between finding stub-psi mismatch and the next EDT spot where the file is reparsed and stub rebuilt
// see com.intellij.psi.impl.source.PsiFileImpl.rebuildStub()
// most likely it's just another highlighting thread accessing the same PSI concurrently and not yet canceled, so cancel it
throw new ProcessCanceledException(exception);
}
throw exception;
}
}
}
PsiFile file = super.getContainingFile();
if (file == null) {
throw new PsiInvalidElementAccessException(this);
}
return file;
}
示例15: getManager
import com.intellij.psi.PsiInvalidElementAccessException; //导入依赖的package包/类
@Override
public PsiManagerEx getManager() {
PsiElement parent = this;
while (parent instanceof ASTDelegatePsiElement) {
parent = parent.getParent();
}
if (parent == null) {
throw new PsiInvalidElementAccessException(this);
}
return (PsiManagerEx)parent.getManager();
}