use of com.intellij.lang.javascript.psi.ecmal4.JSClass in project intellij-plugins by JetBrains.
the class ActionScriptResolveTest method testResolve26.
@JSTestOptions({ JSTestOption.WithIndex })
public void testResolve26() throws Exception {
String fileText = "dynamic class Object {}\n" + "package {\n" + "\timport flash.display.Sprite;\n" + "\tpublic class DoubleInterfaceResolve extends Sprite {\n" + "\t}\n" + "}\n" + "import flash.display.Sprite;\n" + "class FooView extends Sprite {\n" + "}\n" + "\n" + "interface ItfA {\n" + " function f():It<ref>fB;\n" + "}\n" + "interface ItfB {}";
PsiReference ref = configureByFileText(fileText, "sample.js2");
PsiElement resolved = ref.resolve();
assertTrue(resolved instanceof JSClass);
}
use of com.intellij.lang.javascript.psi.ecmal4.JSClass in project intellij-plugins by JetBrains.
the class ActionScriptResolveTest method checkResolvedToClass.
private static void checkResolvedToClass(final ResolveResult[] resolveResults) {
assertEquals(1, resolveResults.length);
final PsiElement realElement = getElement(resolveResults[0]);
assertTrue(realElement instanceof JSClass);
assertEquals("B", ((JSClass) realElement).getName());
}
use of com.intellij.lang.javascript.psi.ecmal4.JSClass in project intellij-plugins by JetBrains.
the class ActionScriptTypeEvaluator method evaluateNewExpressionTypes.
@Override
protected void evaluateNewExpressionTypes(JSNewExpression newExpression, @NotNull JSEvaluateContext.JSEvaluationPlace place) {
JSExpression methodExpr = newExpression.getMethodExpression();
if (methodExpr != null) {
if (methodExpr instanceof JSArrayLiteralExpression) {
JSTypeSource source = JSTypeSourceFactory.createTypeSource(methodExpr);
JSType type = JSNamedType.createType(VECTOR_CLASS_NAME, source, JSContext.INSTANCE);
PsiElement arrayInitializingType = newExpression.getArrayInitializingType();
if (arrayInitializingType != null) {
JSType argType = JSTypeUtils.createType(JSImportHandlingUtil.resolveTypeName(arrayInitializingType.getText(), newExpression), source);
type = new JSGenericTypeImpl(source, type, argType);
}
addType(type, methodExpr);
} else {
JSType type = JSAnyType.get(methodExpr, false);
if (methodExpr instanceof JSReferenceExpression) {
PsiElement resolve = ((JSReferenceExpression) methodExpr).resolve();
if (JSResolveUtil.isConstructorFunction(resolve) && resolve.getParent() instanceof JSClass) {
resolve = resolve.getParent();
}
if (resolve instanceof JSClass || resolve == null) {
JSType typeFromText = JSTypeUtils.createType(methodExpr.getText(), JSTypeSourceFactory.createTypeSource(methodExpr, false));
if (typeFromText != null)
type = typeFromText;
}
}
addType(type, methodExpr);
}
}
}
use of com.intellij.lang.javascript.psi.ecmal4.JSClass in project intellij-plugins by JetBrains.
the class ActionScriptTypeHelper method isAssignableToNamedType.
@Override
public boolean isAssignableToNamedType(@NotNull JSTypeImpl lOpType, @NotNull JSType rOpType, @Nullable ProcessingContext processingContext) {
//noinspection unchecked
Map<Key, Object> cachesMap = processingContext != null ? (Map<Key, Object>) processingContext.get(this) : null;
PsiElement type = ourResolvedTypeKey.get(cachesMap);
JSClass clazz = null;
if (type == null) {
type = lOpType.resolveClass();
ourResolvedTypeKey.set(cachesMap, type != null ? type : PsiUtilCore.NULL_PSI_ELEMENT);
} else if (type == PsiUtilCore.NULL_PSI_ELEMENT) {
type = null;
}
if (type instanceof JSClass)
clazz = (JSClass) type;
JSClass jsClass = rOpType.resolveClass();
if (jsClass == null && rOpType instanceof JSTypeImpl || rOpType instanceof JSSpecialNamedTypeImpl) {
return areNamedTypesAssignable(lOpType, (JSNamedType) rOpType, processingContext);
}
if (jsClass != null && clazz != null) {
return JSInheritanceUtil.isParentClass(jsClass, clazz, false, jsClass);
}
if (clazz == null) {
return false;
}
return true;
}
use of com.intellij.lang.javascript.psi.ecmal4.JSClass in project intellij-plugins by JetBrains.
the class FlexMoveClassProcessor method findUsages.
@NotNull
@Override
protected UsageInfo[] findUsages() {
Collection<UsageInfo> result = Collections.synchronizedCollection(new ArrayList<UsageInfo>());
result.addAll(Arrays.asList(super.findUsages()));
for (JSQualifiedNamedElement element : myElements) {
if (element instanceof JSClass) {
JSRefactoringUtil.addConstructorUsages((JSClass) element, result);
}
TextOccurrencesUtil.findNonCodeUsages(element, element.getQualifiedName(), mySearchInComments, mySearchInNonJavaFiles, StringUtil.getQualifiedName(myTargetPackage, element.getName()), result);
}
return result.toArray(new UsageInfo[result.size()]);
}
Aggregations