Supported converting member properties to extensions
Additionally, we now generate <selection>throw UnsupportedOperationException()</selection> when a missing body is added
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.lang.psi;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface JetCallableDeclaration extends JetNamedDeclaration, JetTypeParameterListOwner {
|
||||
@Nullable
|
||||
JetParameterList getValueParameterList();
|
||||
|
||||
@Nullable
|
||||
JetTypeReference getReceiverTypeRef();
|
||||
|
||||
@Nullable
|
||||
JetTypeReference getReturnTypeRef();
|
||||
}
|
||||
@@ -16,17 +16,7 @@
|
||||
|
||||
package org.jetbrains.jet.lang.psi;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface JetFunction extends JetTypeParameterListOwner, JetDeclarationWithBody {
|
||||
@Nullable
|
||||
JetParameterList getValueParameterList();
|
||||
|
||||
@Nullable
|
||||
JetTypeReference getReceiverTypeRef();
|
||||
|
||||
@Nullable
|
||||
JetTypeReference getReturnTypeRef();
|
||||
public interface JetFunction extends JetDeclarationWithBody, JetCallableDeclaration {
|
||||
|
||||
boolean isLocal();
|
||||
}
|
||||
|
||||
@@ -39,7 +39,8 @@ import static org.jetbrains.jet.JetNodeTypes.PROPERTY_ACCESSOR;
|
||||
import static org.jetbrains.jet.JetNodeTypes.PROPERTY_DELEGATE;
|
||||
import static org.jetbrains.jet.lexer.JetTokens.*;
|
||||
|
||||
public class JetProperty extends JetTypeParameterListOwnerStub<PsiJetPropertyStub> implements JetVariableDeclaration {
|
||||
public class JetProperty extends JetTypeParameterListOwnerStub<PsiJetPropertyStub> implements JetVariableDeclaration,
|
||||
JetCallableDeclaration {
|
||||
public JetProperty(@NotNull ASTNode node) {
|
||||
super(node);
|
||||
}
|
||||
@@ -98,6 +99,13 @@ public class JetProperty extends JetTypeParameterListOwnerStub<PsiJetPropertyStu
|
||||
} else return super.getUseScope();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JetParameterList getValueParameterList() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public JetTypeReference getReceiverTypeRef() {
|
||||
ASTNode node = getNode().getFirstChildNode();
|
||||
@@ -114,6 +122,12 @@ public class JetProperty extends JetTypeParameterListOwnerStub<PsiJetPropertyStu
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JetTypeReference getReturnTypeRef() {
|
||||
return getTypeRef();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public JetTypeReference getTypeRef() {
|
||||
|
||||
@@ -167,7 +167,7 @@ public class JetPsiFactory {
|
||||
return createDeclaration(project, text, JetProperty.class);
|
||||
}
|
||||
|
||||
private static <T> T createDeclaration(Project project, String text, Class<T> clazz) {
|
||||
public static <T> T createDeclaration(Project project, String text, Class<T> clazz) {
|
||||
JetFile file = createFile(project, text);
|
||||
List<JetDeclaration> dcls = file.getDeclarations();
|
||||
assert dcls.size() == 1 : dcls.size() + " declarations in " + text;
|
||||
|
||||
Reference in New Issue
Block a user