2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 package com
.intellij
.psi
.impl
.java
.stubs
;
22 import com
.intellij
.lang
.ASTNode
;
23 import com
.intellij
.psi
.PsiParameter
;
24 import com
.intellij
.psi
.impl
.cache
.TypeInfo
;
25 import com
.intellij
.psi
.impl
.compiled
.ClsParameterImpl
;
26 import com
.intellij
.psi
.impl
.java
.stubs
.impl
.PsiParameterStubImpl
;
27 import com
.intellij
.psi
.impl
.source
.PsiParameterImpl
;
28 import com
.intellij
.psi
.impl
.source
.tree
.JavaElementType
;
29 import com
.intellij
.psi
.stubs
.IndexSink
;
30 import com
.intellij
.psi
.stubs
.StubElement
;
31 import com
.intellij
.psi
.stubs
.StubOutputStream
;
32 import com
.intellij
.psi
.stubs
.StubInputStream
;
33 import com
.intellij
.psi
.tree
.IElementType
;
34 import com
.intellij
.util
.io
.StringRef
;
36 import java
.io
.IOException
;
38 public class JavaParameterElementType
extends JavaStubElementType
<PsiParameterStub
, PsiParameter
> {
39 public JavaParameterElementType() {
43 public PsiParameter
createPsi(final PsiParameterStub stub
) {
44 if (isCompiled(stub
)) {
45 return new ClsParameterImpl(stub
);
48 return new PsiParameterImpl(stub
);
52 public PsiParameter
createPsi(final ASTNode node
) {
53 return new PsiParameterImpl(node
);
56 public PsiParameterStub
createStub(final PsiParameter psi
, final StubElement parentStub
) {
57 final TypeInfo type
= TypeInfo
.create(psi
.getTypeNoResolve(), psi
.getTypeElement());
58 return new PsiParameterStubImpl(parentStub
, psi
.getName(), type
, psi
.isVarArgs());
61 public void serialize(final PsiParameterStub stub
, final StubOutputStream dataStream
)
63 dataStream
.writeName(stub
.getName());
64 TypeInfo
.writeTYPE(dataStream
, stub
.getType(false));
65 dataStream
.writeBoolean(stub
.isParameterTypeEllipsis());
68 public PsiParameterStub
deserialize(final StubInputStream dataStream
, final StubElement parentStub
)
70 StringRef name
= dataStream
.readName();
71 TypeInfo type
= TypeInfo
.readTYPE(dataStream
, parentStub
);
72 boolean isEll
= dataStream
.readBoolean();
73 return new PsiParameterStubImpl(parentStub
, name
, type
, isEll
);
76 public boolean shouldCreateStub(final ASTNode node
) {
77 final IElementType type
= node
.getTreeParent().getElementType();
78 return type
== JavaElementType
.PARAMETER_LIST
;
81 public void indexStub(final PsiParameterStub stub
, final IndexSink sink
) {