1
1
package org .scalaide .core .internal .jdt .model
2
2
3
- import scala .collection .immutable .Seq
3
+ import scala .tools .eclipse .contribution .weaving .jdt .IScalaElement
4
+ import scala .tools .eclipse .contribution .weaving .jdt .ui .IMethodOverrideInfo
5
+ import scala .tools .nsc .Global
4
6
5
7
import org .eclipse .jdt .core .IField
6
8
import org .eclipse .jdt .core .IJavaElement
@@ -11,6 +13,7 @@ import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants
11
13
import org .eclipse .jdt .internal .core .JavaElement
12
14
import org .eclipse .jdt .internal .core .JavaElementInfo
13
15
import org .eclipse .jdt .internal .core .LocalVariable
16
+ import org .eclipse .jdt .internal .core .OpenableElementInfo
14
17
import org .eclipse .jdt .internal .core .SourceConstructorInfo
15
18
import org .eclipse .jdt .internal .core .SourceField
16
19
import org .eclipse .jdt .internal .core .SourceFieldElementInfo
@@ -19,15 +22,11 @@ import org.eclipse.jdt.internal.core.SourceMethodElementInfo
19
22
import org .eclipse .jdt .internal .core .SourceMethodInfo
20
23
import org .eclipse .jdt .internal .core .SourceType
21
24
import org .eclipse .jdt .internal .core .SourceTypeElementInfo
22
- import org .eclipse .jdt .internal .core .OpenableElementInfo
23
25
import org .eclipse .jdt .internal .core .TypeParameterElementInfo
24
26
import org .eclipse .jface .resource .ImageDescriptor
25
-
27
+ import org . scalaide . core . internal . compiler . ScalaPresentationCompiler
26
28
import org .scalaide .ui .ScalaImages
27
- import scala .tools .eclipse .contribution .weaving .jdt .IScalaElement
28
- import scala .tools .eclipse .contribution .weaving .jdt .ui .IMethodOverrideInfo
29
29
import org .scalaide .util .internal .ReflectionUtils
30
- import scala .tools .nsc .Global
31
30
32
31
trait ScalaElement extends JavaElement with IScalaElement {
33
32
def getElementInfo : AnyRef
@@ -56,7 +55,7 @@ trait ScalaElement extends JavaElement with IScalaElement {
56
55
57
56
trait ScalaFieldElement extends ScalaElement
58
57
59
- class ScalaSourceTypeElement (parent : JavaElement , name : String , declaringType : Option [Global # Type ])
58
+ class ScalaSourceTypeElement (parent : JavaElement , name : String , declaringType : Option [Global # Type ])( implicit pc : ScalaPresentationCompiler )
60
59
extends SourceType (parent, name) with ScalaElement {
61
60
62
61
def getCorrespondingElement (element : IJavaElement ): Option [IJavaElement ] = {
@@ -81,42 +80,44 @@ class ScalaSourceTypeElement(parent: JavaElement, name: String, declaringType: O
81
80
}
82
81
83
82
override def getFullyQualifiedName : String =
84
- declaringType.map { declaringType =>
85
- val pkgSym = declaringType.typeSymbol.enclosingPackage
86
- if (pkgSym.isEmptyPackage)
87
- super .getFullyQualifiedName
88
- else {
89
- val pkg = pkgSym.javaClassName
90
- pkg + " ." + getTypeQualifiedName('$' , /* showParameters =*/ false )
91
- }
83
+ declaringType.flatMap { typ =>
84
+ pc.asyncExec {
85
+ val pkgSym = typ.typeSymbol.enclosingPackage
86
+ if (pkgSym.isEmptyPackage)
87
+ super .getFullyQualifiedName
88
+ else {
89
+ val pkg = pkgSym.javaClassName
90
+ pkg + " ." + getTypeQualifiedName('$' , /* showParameters =*/ false )
91
+ }
92
+ }.get.left.toOption
92
93
}.getOrElse(super .getFullyQualifiedName)
93
94
}
94
95
95
- class ScalaClassElement (parent : JavaElement , name : String , synthetic : Boolean , declaringType : Option [Global # Type ])
96
+ class ScalaClassElement (parent : JavaElement , name : String , synthetic : Boolean , declaringType : Option [Global # Type ])( implicit pc : ScalaPresentationCompiler )
96
97
extends ScalaSourceTypeElement (parent, name, declaringType) {
97
98
override def getImageDescriptor = ScalaImages .SCALA_CLASS
98
99
override def isVisible = ! synthetic
99
100
}
100
101
101
- class ScalaAnonymousClassElement (parent : JavaElement , name : String , declaringType : Option [Global # Type ])
102
+ class ScalaAnonymousClassElement (parent : JavaElement , name : String , declaringType : Option [Global # Type ])( implicit pc : ScalaPresentationCompiler )
102
103
extends ScalaClassElement (parent, name, false , declaringType) {
103
104
override def getLabelText (flags : Long ) = if (name != null ) " new " + name + " {...}" else " new {...}"
104
105
}
105
106
106
- class ScalaTraitElement (parent : JavaElement , name : String , declaringType : Option [Global # Type ])
107
+ class ScalaTraitElement (parent : JavaElement , name : String , declaringType : Option [Global # Type ])( implicit pc : ScalaPresentationCompiler )
107
108
extends ScalaSourceTypeElement (parent, name, declaringType) {
108
109
override def getImageDescriptor = ScalaImages .SCALA_TRAIT
109
110
}
110
111
111
- class ScalaModuleElement (parent : JavaElement , name : String , synthetic : Boolean , declaringType : Option [Global # Type ])
112
+ class ScalaModuleElement (parent : JavaElement , name : String , synthetic : Boolean , declaringType : Option [Global # Type ])( implicit pc : ScalaPresentationCompiler )
112
113
extends ScalaSourceTypeElement (parent, name + " $" , declaringType) {
113
114
override def scalaName = name
114
115
override def getLabelText (flags : Long ) = name
115
116
override def getImageDescriptor = ScalaImages .SCALA_OBJECT
116
117
override def isVisible = ! synthetic
117
118
}
118
119
119
- class ScalaPackageModuleElement (parent : JavaElement , name : String , synthetic : Boolean , declaringType : Option [Global # Type ])
120
+ class ScalaPackageModuleElement (parent : JavaElement , name : String , synthetic : Boolean , declaringType : Option [Global # Type ])( implicit pc : ScalaPresentationCompiler )
120
121
extends ScalaModuleElement (parent, name, synthetic, declaringType) {
121
122
override def getImageDescriptor = ScalaImages .SCALA_PACKAGE_OBJECT
122
123
}
@@ -158,7 +159,7 @@ class ScalaVarElement(parent: JavaElement, name: String, display: String)
158
159
override def getLabelText (flags : Long ) = display
159
160
}
160
161
161
- class ScalaTypeElement (parent : JavaElement , name : String , display : String , declaringType : Option [Global # Type ])
162
+ class ScalaTypeElement (parent : JavaElement , name : String , display : String , declaringType : Option [Global # Type ])( implicit pc : ScalaPresentationCompiler )
162
163
extends ScalaSourceTypeElement (parent, name, declaringType) {
163
164
override def getLabelText (flags : Long ) = display
164
165
override def getImageDescriptor = ScalaImages .SCALA_TYPE
0 commit comments