Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Intellij Community
Commits
6fb11dde
Commit
6fb11dde
authored
6 years ago
by
Nicolay Mitropolsky
Browse files
Options
Download
Email Patches
Plain Diff
[uast] warnings cleanup
parent
cb8bfc92
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
uast/uast-common/src/com/intellij/patterns/uast/UastPatterns.kt
+1
-1
...ast-common/src/com/intellij/patterns/uast/UastPatterns.kt
uast/uast-common/src/org/jetbrains/uast/UastContext.kt
+2
-0
uast/uast-common/src/org/jetbrains/uast/UastContext.kt
uast/uast-common/src/org/jetbrains/uast/UastLanguagePlugin.kt
+1
-0
.../uast-common/src/org/jetbrains/uast/UastLanguagePlugin.kt
uast/uast-common/src/org/jetbrains/uast/baseElements/UElement.kt
+1
-1
...st-common/src/org/jetbrains/uast/baseElements/UElement.kt
uast/uast-common/src/org/jetbrains/uast/declarations/UClass.kt
+1
-1
...uast-common/src/org/jetbrains/uast/declarations/UClass.kt
uast/uast-common/src/org/jetbrains/uast/declarations/UDeclaration.kt
+1
-0
...ommon/src/org/jetbrains/uast/declarations/UDeclaration.kt
uast/uast-common/src/org/jetbrains/uast/expressions/uastLiteralUtils.kt
+1
-0
...on/src/org/jetbrains/uast/expressions/uastLiteralUtils.kt
uast/uast-java/src/org/jetbrains/uast/java/JavaAbstractUElement.kt
+1
-1
...-java/src/org/jetbrains/uast/java/JavaAbstractUElement.kt
uast/uast-java/src/org/jetbrains/uast/java/declarations/JavaUClass.kt
+4
-1
...va/src/org/jetbrains/uast/java/declarations/JavaUClass.kt
uast/uast-java/src/org/jetbrains/uast/java/declarations/JavaUClassInitializer.kt
+2
-0
...jetbrains/uast/java/declarations/JavaUClassInitializer.kt
uast/uast-java/src/org/jetbrains/uast/java/declarations/JavaUMethod.kt
+3
-1
...a/src/org/jetbrains/uast/java/declarations/JavaUMethod.kt
uast/uast-java/src/org/jetbrains/uast/java/declarations/JavaUVariable.kt
+7
-0
...src/org/jetbrains/uast/java/declarations/JavaUVariable.kt
uast/uast-tests/src/org/jetbrains/uast/test/common/IdentifiersTestBase.kt
+1
-2
...src/org/jetbrains/uast/test/common/IdentifiersTestBase.kt
uast/uast-tests/src/org/jetbrains/uast/test/env/AbstractUastTest.kt
+1
-0
...tests/src/org/jetbrains/uast/test/env/AbstractUastTest.kt
uast/uast-tests/test/org/jetbrains/uast/test/java/DetachedJavaUastTest.kt
+2
-1
...test/org/jetbrains/uast/test/java/DetachedJavaUastTest.kt
uast/uast-tests/test/org/jetbrains/uast/test/java/JavaUastApiTest.kt
+12
-12
...ests/test/org/jetbrains/uast/test/java/JavaUastApiTest.kt
uast/uast-tests/test/org/jetbrains/uast/test/java/JavaUastPerformanceTest.kt
+1
-1
...t/org/jetbrains/uast/test/java/JavaUastPerformanceTest.kt
uast/uast-tests/test/org/jetbrains/uast/test/java/UastVisitorAdapterTest.kt
+1
-2
...st/org/jetbrains/uast/test/java/UastVisitorAdapterTest.kt
with
43 additions
and
24 deletions
+43
-24
uast/uast-common/src/com/intellij/patterns/uast/UastPatterns.kt
+
1
-
1
View file @
6fb11dde
...
...
@@ -65,7 +65,7 @@ open class UElementPattern<T : UElement, Self : UElementPattern<T, Self>>(clazz:
override
fun
accepts
(
t
:
T
,
context
:
ProcessingContext
?):
Boolean
=
filter
.
invoke
(
t
,
context
)
})
fun
filter
(
filter
:
(
T
)
->
Boolean
):
Self
=
filterWithContext
{
t
,
processingContext
->
filter
(
t
)
}
fun
filter
(
filter
:
(
T
)
->
Boolean
):
Self
=
filterWithContext
{
t
,
_
->
filter
(
t
)
}
fun
withUastParent
(
parentPattern
:
ElementPattern
<
out
UElement
>):
Self
=
filter
{
it
.
uastParent
?.
let
{
parentPattern
.
accepts
(
it
)
}
?:
false
}
...
...
This diff is collapsed.
Click to expand it.
uast/uast-common/src/org/jetbrains/uast/UastContext.kt
+
2
-
0
View file @
6fb11dde
...
...
@@ -118,8 +118,10 @@ fun PsiElement?.toUElement(): UElement? = this?.let { doConvertElementWithParent
* Converts the element to an UAST element of the given type. Returns null if the PSI element type does not correspond
* to the given UAST element type.
*/
@Suppress
(
"UNCHECKED_CAST"
)
fun
<
T
:
UElement
>
PsiElement
?.
toUElement
(
cls
:
Class
<
out
T
>):
T
?
=
this
?.
let
{
doConvertElementWithParent
(
this
,
cls
)
as
T
?
}
@Suppress
(
"UNCHECKED_CAST"
)
fun
<
T
:
UElement
>
PsiElement
?.
toUElementOfExpectedTypes
(
vararg
clss
:
Class
<
out
T
>):
T
?
=
this
?.
let
{
ServiceManager
.
getService
(
project
,
UastContext
::
class
.
java
)
...
...
This diff is collapsed.
Click to expand it.
uast/uast-common/src/org/jetbrains/uast/UastLanguagePlugin.kt
+
1
-
0
View file @
6fb11dde
...
...
@@ -91,6 +91,7 @@ interface UastLanguagePlugin {
fun
isExpressionValueUsed
(
element
:
UExpression
):
Boolean
@JvmDefault
@Suppress
(
"UNCHECKED_CAST"
)
fun
<
T
:
UElement
>
convertElementWithParent
(
element
:
PsiElement
,
requiredTypes
:
Array
<
out
Class
<
out
T
>>):
T
?
=
when
{
requiredTypes
.
isEmpty
()
->
convertElementWithParent
(
element
,
null
)
...
...
This diff is collapsed.
Click to expand it.
uast/uast-common/src/org/jetbrains/uast/baseElements/UElement.kt
+
1
-
1
View file @
6fb11dde
...
...
@@ -132,7 +132,7 @@ val UElement?.sourcePsiElement: PsiElement?
@ApiStatus
.
Experimental
@Suppress
Warnings
(
"unchecked
"
)
@Suppress
(
"UNCHECKED_CAST
"
)
fun
<
T
:
PsiElement
>
UElement
?.
getAsJavaPsiElement
(
clazz
:
Class
<
T
>):
T
?
=
this
?.
javaPsi
?.
takeIf
{
clazz
.
isAssignableFrom
(
it
.
javaClass
)
}
as
?
T
...
...
This diff is collapsed.
Click to expand it.
uast/uast-common/src/org/jetbrains/uast/declarations/UClass.kt
+
1
-
1
View file @
6fb11dde
...
...
@@ -87,7 +87,7 @@ interface UClass : UDeclaration, PsiClass {
append
(
superTypes
.
joinToString
{
it
.
asRenderString
()
})
}
appendln
(
" {"
)
uastDeclarations
.
forEachIndexed
{
index
,
declaration
->
uastDeclarations
.
forEachIndexed
{
_
,
declaration
->
appendln
(
declaration
.
asRenderString
().
withMargin
)
}
append
(
"}"
)
...
...
This diff is collapsed.
Click to expand it.
uast/uast-common/src/org/jetbrains/uast/declarations/UDeclaration.kt
+
1
-
0
View file @
6fb11dde
...
...
@@ -69,6 +69,7 @@ fun UElement?.getContainingDeclaration(): UDeclaration? = this?.withContainingEl
fun
<
T
:
UElement
>
UElement
?.
getContainingDeclaration
(
cls
:
Class
<
out
T
>):
T
?
{
val
element
=
this
?.
withContainingElements
?.
drop
(
1
)
?.
filterIsInstance
<
UDeclaration
>()
?.
firstOrNull
()
return
if
(
element
!=
null
&&
cls
.
isInstance
(
element
))
{
@Suppress
(
"UNCHECKED_CAST"
)
element
as
T
}
else
{
null
...
...
This diff is collapsed.
Click to expand it.
uast/uast-common/src/org/jetbrains/uast/expressions/uastLiteralUtils.kt
+
1
-
0
View file @
6fb11dde
...
...
@@ -72,6 +72,7 @@ fun UElement?.isInjectionHost(): Boolean = this is UInjectionHost || (this is UE
* @return literal text if the receiver is a valid [String] literal, null otherwise.
*/
@Deprecated
(
"doesn't support UInjectionHost, most likely it is not what you want"
,
ReplaceWith
(
"UExpression.evaluateString()"
))
@Suppress
(
"Deprecation"
)
fun
UElement
.
getValueIfStringLiteral
():
String
?
=
if
(
isStringLiteral
())
(
this
as
ULiteralExpression
).
value
as
String
else
null
...
...
This diff is collapsed.
Click to expand it.
uast/uast-java/src/org/jetbrains/uast/java/JavaAbstractUElement.kt
+
1
-
1
View file @
6fb11dde
...
...
@@ -73,7 +73,7 @@ private fun JavaAbstractUElement.unwrapSwitch(uParent: UElement): UElement {
is
JavaUBlockExpression
->
{
val
sourcePsi
=
codeBlockParent
.
sourcePsi
if
(
sourcePsi
is
PsiBlockStatement
&&
sourcePsi
.
parent
is
PsiSwitchLabeledRuleStatement
)
if
(
sourcePsi
.
parent
is
PsiSwitchLabeledRuleStatement
)
(
codeBlockParent
.
uastParent
as
?
JavaUSwitchEntry
)
?.
let
{
return
it
.
body
}
}
...
...
This diff is collapsed.
Click to expand it.
uast/uast-java/src/org/jetbrains/uast/java/declarations/JavaUClass.kt
+
4
-
1
View file @
6fb11dde
...
...
@@ -21,7 +21,7 @@ import org.jetbrains.uast.*
import
org.jetbrains.uast.java.internal.JavaUElementWithComments
abstract
class
AbstractJavaUClass
(
givenParent
:
UElement
?)
:
JavaAbstractUElement
(
givenParent
),
UClass
TypeSpecific
,
JavaUElementWithComments
,
UAnchorOwner
,
UDeclarationEx
{
givenParent
),
UClass
,
JavaUElementWithComments
,
UAnchorOwner
,
UDeclarationEx
{
abstract
override
val
javaPsi
:
PsiClass
...
...
@@ -76,6 +76,8 @@ class JavaUClass private constructor(override val sourcePsi: PsiClass, val given
JavaUClass
(
psi
,
containingElement
)
}
}
override
fun
getOriginalElement
():
PsiElement
?
=
sourcePsi
.
originalElement
}
class
JavaUAnonymousClass
(
...
...
@@ -105,4 +107,5 @@ class JavaUAnonymousClass(
override
fun
getInitializers
():
Array
<
UClassInitializer
>
=
super
<
AbstractJavaUClass
>.
getInitializers
()
override
fun
getMethods
():
Array
<
UMethod
>
=
super
<
AbstractJavaUClass
>.
getMethods
()
override
fun
getInnerClasses
():
Array
<
UClass
>
=
super
<
AbstractJavaUClass
>.
getInnerClasses
()
override
fun
getOriginalElement
():
PsiElement
?
=
sourcePsi
.
originalElement
}
This diff is collapsed.
Click to expand it.
uast/uast-java/src/org/jetbrains/uast/java/declarations/JavaUClassInitializer.kt
+
2
-
0
View file @
6fb11dde
...
...
@@ -17,6 +17,7 @@
package
org.jetbrains.uast.java
import
com.intellij.psi.PsiClassInitializer
import
com.intellij.psi.PsiElement
import
org.jetbrains.uast.*
import
org.jetbrains.uast.java.internal.JavaUElementWithComments
...
...
@@ -41,4 +42,5 @@ class JavaUClassInitializer(
override
fun
equals
(
other
:
Any
?):
Boolean
=
this
===
other
override
fun
hashCode
():
Int
=
sourcePsi
.
hashCode
()
override
fun
getOriginalElement
():
PsiElement
?
=
sourcePsi
.
originalElement
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
uast/uast-java/src/org/jetbrains/uast/java/declarations/JavaUMethod.kt
+
3
-
1
View file @
6fb11dde
...
...
@@ -3,6 +3,7 @@
package
org.jetbrains.uast.java
import
com.intellij.psi.PsiAnnotationMethod
import
com.intellij.psi.PsiElement
import
com.intellij.psi.PsiMethod
import
com.intellij.psi.PsiNameIdentifierOwner
import
org.jetbrains.uast.*
...
...
@@ -11,7 +12,7 @@ import org.jetbrains.uast.java.internal.JavaUElementWithComments
open
class
JavaUMethod
(
override
val
sourcePsi
:
PsiMethod
,
uastParent
:
UElement
?
)
:
JavaAbstractUElement
(
uastParent
),
UMethod
TypeSpecific
,
JavaUElementWithComments
,
UAnchorOwner
,
PsiMethod
by
sourcePsi
{
)
:
JavaAbstractUElement
(
uastParent
),
UMethod
,
JavaUElementWithComments
,
UAnchorOwner
,
PsiMethod
by
sourcePsi
{
@Suppress
(
"OverridingDeprecatedMember"
)
...
...
@@ -47,6 +48,7 @@ open class JavaUMethod(
sourcePsi
.
returnTypeElement
?.
let
{
JavaUTypeReferenceExpression
(
it
,
this
)
}
}
override
fun
getOriginalElement
():
PsiElement
?
=
sourcePsi
.
originalElement
}
class
JavaUAnnotationMethod
(
...
...
This diff is collapsed.
Click to expand it.
uast/uast-java/src/org/jetbrains/uast/java/declarations/JavaUVariable.kt
+
7
-
0
View file @
6fb11dde
...
...
@@ -68,6 +68,7 @@ open class JavaUVariable(
}
}
}
override
fun
getOriginalElement
():
PsiElement
?
=
sourcePsi
.
originalElement
}
open
class
JavaUParameter
(
...
...
@@ -80,6 +81,7 @@ open class JavaUParameter(
get
()
=
javaPsi
override
val
javaPsi
:
PsiParameter
=
sourcePsi
override
fun
getOriginalElement
():
PsiElement
?
=
sourcePsi
.
originalElement
}
open
class
JavaUField
(
...
...
@@ -91,6 +93,7 @@ open class JavaUField(
get
()
=
javaPsi
override
val
javaPsi
:
PsiField
=
unwrap
<
UField
,
PsiField
>(
sourcePsi
)
override
fun
getOriginalElement
():
PsiElement
?
=
sourcePsi
.
originalElement
}
open
class
JavaULocalVariable
(
...
...
@@ -111,6 +114,8 @@ open class JavaULocalVariable(
}
}
override
fun
getOriginalElement
():
PsiElement
?
=
sourcePsi
.
originalElement
}
open
class
JavaUEnumConstant
(
...
...
@@ -175,4 +180,6 @@ open class JavaUEnumConstant(
override
val
identifier
:
String
get
()
=
sourcePsi
.
containingClass
?.
name
?:
"<error>"
}
override
fun
getOriginalElement
():
PsiElement
?
=
sourcePsi
.
originalElement
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
uast/uast-tests/src/org/jetbrains/uast/test/common/IdentifiersTestBase.kt
+
1
-
2
View file @
6fb11dde
...
...
@@ -5,7 +5,6 @@ package org.jetbrains.uast.test.common
import
com.intellij.psi.PsiCodeBlock
import
com.intellij.psi.PsiElement
import
com.intellij.psi.PsiFile
import
junit.framework.TestCase
import
org.jetbrains.uast.*
import
kotlin.reflect.KClass
...
...
@@ -50,6 +49,6 @@ open class UElementToParentMap(shouldIndent: (PsiElement) -> Boolean,
}
fun
IndentedPrintingVisitor
.
visitUFileAndGetResult
(
uFile
:
UFile
):
String
{
(
uFile
.
sourcePsi
as
PsiFile
)
.
accept
(
this
)
uFile
.
sourcePsi
.
accept
(
this
)
return
result
}
This diff is collapsed.
Click to expand it.
uast/uast-tests/src/org/jetbrains/uast/test/env/AbstractUastTest.kt
+
1
-
0
View file @
6fb11dde
...
...
@@ -49,6 +49,7 @@ fun <T> UElement.findElementByText(refText: String, cls: Class<T>): T {
accept
(
object
:
UastVisitor
{
override
fun
visitElement
(
node
:
UElement
):
Boolean
{
if
(
cls
.
isInstance
(
node
)
&&
node
.
sourcePsi
?.
text
==
refText
)
{
@Suppress
(
"UNCHECKED_CAST"
)
matchingElements
.
add
(
node
as
T
)
}
return
false
...
...
This diff is collapsed.
Click to expand it.
uast/uast-tests/test/org/jetbrains/uast/test/java/DetachedJavaUastTest.kt
+
2
-
1
View file @
6fb11dde
...
...
@@ -60,4 +60,5 @@ class DetachedJavaUastTest : AbstractJavaUastTest() {
}
private
infix
fun
Class
<
out
PsiElement
>.
through
(
detacher
:
(
PsiElementFactory
,
String
,
PsiElement
)
->
PsiElement
)
:
Pair
<
Class
<
PsiElement
>,
(
PsiElementFactory
,
String
,
PsiElement
)
-
>
PsiElement
>
=
(
this
as
Class
<
PsiElement
>)
to
detacher
:
Pair
<
Class
<
PsiElement
>,
(
PsiElementFactory
,
String
,
PsiElement
)
-
>
PsiElement
>
=
@Suppress
(
"UNCHECKED_CAST"
)
(
this
as
Class
<
PsiElement
>)
to
detacher
This diff is collapsed.
Click to expand it.
uast/uast-tests/test/org/jetbrains/uast/test/java/JavaUastApiTest.kt
+
12
-
12
View file @
6fb11dde
...
...
@@ -33,7 +33,7 @@ class JavaUastApiTest : AbstractJavaUastTest() {
@Test
fun
testTypeReference
()
{
doTest
(
"Simple/TypeReference.java"
)
{
name
,
file
->
doTest
(
"Simple/TypeReference.java"
)
{
_
,
file
->
val
localVar
=
file
.
findElementByText
<
ULocalVariable
>(
"String s;"
)
val
typeRef
=
localVar
.
typeReference
assertNotNull
(
typeRef
)
...
...
@@ -42,14 +42,14 @@ class JavaUastApiTest : AbstractJavaUastTest() {
@Test
fun
testFields
()
{
doTest
(
"Simple/Field.java"
)
{
name
,
file
->
doTest
(
"Simple/Field.java"
)
{
_
,
file
->
assertEquals
(
1
,
file
.
classes
[
0
].
fields
.
size
)
}
}
@Test
fun
testPackageInfo
()
{
doTest
(
"Simple/package-info.java"
)
{
name
,
file
->
doTest
(
"Simple/package-info.java"
)
{
_
,
file
->
val
index2
=
file
.
sourcePsi
.
text
.
indexOf
(
"foo"
)
val
literal
=
PsiTreeUtil
.
getParentOfType
(
file
.
sourcePsi
.
findElementAt
(
index2
),
PsiLiteralExpression
::
class
.
java
)
!!
val
uLiteral
=
literal
.
toUElement
()
!!
...
...
@@ -62,7 +62,7 @@ class JavaUastApiTest : AbstractJavaUastTest() {
@Test
fun
testCallExpression
()
{
doTest
(
"Simple/CallExpression.java"
)
{
name
,
file
->
doTest
(
"Simple/CallExpression.java"
)
{
_
,
file
->
val
index
=
file
.
sourcePsi
.
text
.
indexOf
(
"format"
)
val
callExpression
=
PsiTreeUtil
.
getParentOfType
(
file
.
sourcePsi
.
findElementAt
(
index
),
PsiCallExpression
::
class
.
java
)
!!
assertNotNull
(
callExpression
.
toUElementOfType
<
UCallExpression
>())
...
...
@@ -79,7 +79,7 @@ class JavaUastApiTest : AbstractJavaUastTest() {
@Test
fun
testCallExpressionAlternatives
()
{
doTest
(
"Simple/CallExpression.java"
)
{
name
,
file
->
doTest
(
"Simple/CallExpression.java"
)
{
_
,
file
->
val
index
=
file
.
sourcePsi
.
text
.
indexOf
(
"format"
)
val
callExpression
=
PsiTreeUtil
.
getParentOfType
(
file
.
sourcePsi
.
findElementAt
(
index
),
PsiCallExpression
::
class
.
java
)
!!
...
...
@@ -108,7 +108,7 @@ class JavaUastApiTest : AbstractJavaUastTest() {
@Test
fun
testCallExpressionArguments
()
{
doTest
(
"Simple/CallExpression.java"
)
{
name
,
file
->
doTest
(
"Simple/CallExpression.java"
)
{
_
,
file
->
fun
assertArguments
(
argumentsInPositionalOrder
:
List
<
String
?>?,
refText
:
String
)
=
file
.
findElementByTextFromPsi
<
UCallExpression
>(
refText
).
let
{
call
->
if
(
call
!
is
UCallExpressionEx
)
throw
AssertionError
(
"${call.javaClass} is not a UCallExpressionEx"
)
...
...
@@ -131,7 +131,7 @@ class JavaUastApiTest : AbstractJavaUastTest() {
@Test
fun
testFunctionalInterfaceType
()
{
doTest
(
"Simple/FunctionalInterfaceType.java"
)
{
name
,
file
->
doTest
(
"Simple/FunctionalInterfaceType.java"
)
{
_
,
file
->
val
lambda
=
file
.
findElementByText
<
ULambdaExpression
>(
"() -> { }"
)
assertEquals
(
lambda
.
functionalInterfaceType
?.
canonicalText
,
...
...
@@ -141,7 +141,7 @@ class JavaUastApiTest : AbstractJavaUastTest() {
@Test
fun
testReceiverType
()
{
doTest
(
"Simple/ReceiverType.java"
)
{
name
,
file
->
doTest
(
"Simple/ReceiverType.java"
)
{
_
,
file
->
assertEquals
(
"Test"
,
file
.
findElementByText
<
UCallExpression
>(
"foo(1)"
).
receiverType
?.
canonicalText
)
assertEquals
(
"Test"
,
file
.
findElementByText
<
UCallExpression
>(
"fooBase(1)"
).
receiverType
?.
canonicalText
)
assertEquals
(
"Test"
,
file
.
findElementByText
<
UCallExpression
>(
"this.barBase(1)"
).
receiverType
?.
canonicalText
)
...
...
@@ -175,7 +175,7 @@ class JavaUastApiTest : AbstractJavaUastTest() {
@Test
fun
testSuperTypes
()
{
doTest
(
"Simple/SuperTypes.java"
)
{
name
,
file
->
doTest
(
"Simple/SuperTypes.java"
)
{
_
,
file
->
val
testClass
=
file
.
findElementByTextFromPsi
<
UIdentifier
>(
"Test"
).
uastParent
as
UClass
assertEquals
(
"base class"
,
"A"
,
testClass
.
superClass
?.
qualifiedName
)
assertEquals
(
"base classes"
,
listOf
(
"A"
,
"B"
),
testClass
.
uastSuperTypes
.
map
{
it
.
getQualifiedName
()
})
...
...
@@ -184,7 +184,7 @@ class JavaUastApiTest : AbstractJavaUastTest() {
@Test
fun
testSuperTypesForAnonymous
()
{
doTest
(
"Simple/Anonymous.java"
)
{
name
,
file
->
doTest
(
"Simple/Anonymous.java"
)
{
_
,
file
->
val
testClass
=
file
.
findElementByTextFromPsi
<
UElement
>(
"""Runnable() {
public void run() {
...
...
@@ -197,13 +197,13 @@ class JavaUastApiTest : AbstractJavaUastTest() {
}
@Test
fun
testCanFindAWayFromBrokenSwitch
()
=
doTest
(
"BrokenCode/Switch.java"
)
{
name
,
file
->
fun
testCanFindAWayFromBrokenSwitch
()
=
doTest
(
"BrokenCode/Switch.java"
)
{
_
,
file
->
val
testClass
=
file
.
findElementByTextFromPsi
<
UElement
>(
"""return;"""
)
TestCase
.
assertEquals
(
7
,
testClass
.
withContainingElements
.
count
())
}
@Test
fun
testDefaultConstructorRef
()
=
doTest
(
"Simple/ComplexCalls.java"
)
{
name
,
file
->
fun
testDefaultConstructorRef
()
=
doTest
(
"Simple/ComplexCalls.java"
)
{
_
,
file
->
val
call
=
file
.
findElementByTextFromPsi
<
UCallExpression
>(
"new A()"
)
TestCase
.
assertEquals
(
UastCallKind
.
CONSTRUCTOR_CALL
,
call
.
kind
)
TestCase
.
assertEquals
(
null
,
call
.
resolve
())
...
...
This diff is collapsed.
Click to expand it.
uast/uast-tests/test/org/jetbrains/uast/test/java/JavaUastPerformanceTest.kt
+
1
-
1
View file @
6fb11dde
...
...
@@ -42,7 +42,7 @@ class JavaUastPerformanceTest : LightCodeInsightFixtureTestCase() {
}
}
"""
.
trimIndent
())
val
nonCachedWalk
=
EachPsiToUastWalker
().
apply
{
EachPsiToUastWalker
().
apply
{
PlatformTestUtil
.
startPerformanceTest
(
"convert each element to uast first time"
,
2000
)
{
clazz
.
accept
(
this
)
TestCase
.
assertEquals
(
expectedUElementsCount
,
totalCount
)
...
...
This diff is collapsed.
Click to expand it.
uast/uast-tests/test/org/jetbrains/uast/test/java/UastVisitorAdapterTest.kt
+
1
-
2
View file @
6fb11dde
...
...
@@ -2,7 +2,6 @@
package
org.jetbrains.uast.test.java
import
com.intellij.psi.PsiElement
import
com.intellij.psi.PsiFile
import
com.intellij.psi.SyntaxTraverser
import
com.intellij.uast.UastVisitorAdapter
import
junit.framework.TestCase
...
...
@@ -14,7 +13,7 @@ import org.junit.Test
class
UastVisitorAdapterTest
:
AbstractJavaUastTest
()
{
override
fun
check
(
testName
:
String
,
file
:
UFile
)
{
val
psiFile
=
file
.
sourcePsi
as
PsiFile
val
psiFile
=
file
.
sourcePsi
val
toList
=
SyntaxTraverser
.
psiTraverser
(
psiFile
).
toList
()
val
listSources
=
mutableSetOf
<
PsiElement
>()
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help