mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
CIDR: code fragments
CIDR-debugger: value type resolving
This commit is contained in:
@@ -42,8 +42,4 @@ public class IFileElementType extends ILazyParseableElementType {
|
||||
final PsiParser parser = LanguageParserDefinitions.INSTANCE.forLanguage(getLanguage()).createParser(project);
|
||||
return parser.parse(this, builder).getFirstChildNode();
|
||||
}
|
||||
|
||||
//public boolean isParsable(CharSequence buffer, final Project project) {
|
||||
// return true;
|
||||
//}
|
||||
}
|
||||
|
||||
@@ -175,6 +175,26 @@ public class PsiTreeUtil {
|
||||
return parents;
|
||||
}
|
||||
|
||||
@Nullable public static <T extends PsiElement> T findChildOfType(@NotNull final PsiElement element, @NotNull final Class<T> aClass) {
|
||||
return findChildOfType(element, aClass, true);
|
||||
}
|
||||
|
||||
@Nullable public static <T extends PsiElement> T findChildOfType(@NotNull final PsiElement element, @NotNull final Class<T> aClass, final boolean strict) {
|
||||
PsiElementProcessor.FindElement<PsiElement> processor = new PsiElementProcessor.FindElement<PsiElement>() {
|
||||
@Override
|
||||
public boolean execute(PsiElement each) {
|
||||
if (strict && each == element) return true;
|
||||
if (instanceOf(aClass, each)) {
|
||||
return setFound(each);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
PsiTreeUtil.processElements(element, processor);
|
||||
return (T)processor.getFoundElement();
|
||||
}
|
||||
|
||||
@Nullable public static <T extends PsiElement> T getChildOfType(@NotNull PsiElement element, @NotNull Class<T> aClass) {
|
||||
for(PsiElement child = element.getFirstChild(); child != null; child = child.getNextSibling()){
|
||||
if (instanceOf(aClass, child)) return (T)child;
|
||||
|
||||
@@ -66,27 +66,6 @@ public abstract class PsiFileBase extends PsiFileImpl {
|
||||
return myLanguage;
|
||||
}
|
||||
|
||||
protected final FileElement createFileElement(final CharSequence docText) {
|
||||
//final ParserDefinition parserDefinition = myLanguage.getParserDefinition();
|
||||
//if (parserDefinition != null && parserDefinition.createParser(getProject()) != PsiUtil.NULL_PARSER) {
|
||||
// return _createFileElement(docText, myLanguage, getProject(), parserDefinition);
|
||||
//}
|
||||
return super.createFileElement(docText);
|
||||
}
|
||||
|
||||
//private static FileElement _createFileElement(final CharSequence docText,
|
||||
// final Language language,
|
||||
// Project project,
|
||||
// final ParserDefinition parserDefinition) {
|
||||
// final PsiParser parser = parserDefinition.createParser(project);
|
||||
// final IElementType root = parserDefinition.getFileNodeType();
|
||||
// final PsiBuilderImpl builder = new PsiBuilderImpl(language, project, null, docText);
|
||||
// final FileElement fileRoot = (FileElement)parser.parse(root, builder);
|
||||
// LOG.assertTrue(fileRoot.getElementType() == root,
|
||||
// "Parsing file text returns rootElement with type different from declared in parser definition");
|
||||
// return fileRoot;
|
||||
//}
|
||||
|
||||
public void accept(@NotNull PsiElementVisitor visitor) {
|
||||
visitor.visitFile(this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user