-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
136 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<idea-plugin version="2"> | ||
<id>cn.nekocode.plugin.parcelablegenerator</id> | ||
<name>Parcelable Code Generator(for kotlin)</name> | ||
<version>0.6.1</version> | ||
<version>0.6.2</version> | ||
<vendor email="[email protected]" url="https://github.com/nekocode/android-parcelable-intellij-plugin-kotlin">nekocode</vendor> | ||
|
||
<description><![CDATA[ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/cn/nekocode/plugin/parcelablegenerator/typeserializers/NullableArraySerializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (C) 2016 Nekocode (https://github.com/nekocode) | ||
* | ||
* 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 cn.nekocode.plugin.parcelablegenerator.typeserializers; | ||
|
||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor; | ||
|
||
/** | ||
* Created by nekocode on 2017/4/22. | ||
*/ | ||
public class NullableArraySerializer extends TypeSerializer { | ||
|
||
public NullableArraySerializer(ValueParameterDescriptor field) { | ||
super(field); | ||
} | ||
|
||
public String readValue() { | ||
String type = field.getType().toString(); | ||
String typeProjection = field.getType().getArguments().get(0).getType().toString(); | ||
return "source.readArray(" + typeProjection.substring(0, typeProjection.length() -1) + "::class.java.classLoader) as " + type; | ||
} | ||
|
||
public String writeValue() { | ||
return "dest?.writeArray(" + field.getName() + ")"; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/cn/nekocode/plugin/parcelablegenerator/typeserializers/NullableStringSerializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (C) 2016 Nekocode (https://github.com/nekocode) | ||
* | ||
* 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 cn.nekocode.plugin.parcelablegenerator.typeserializers; | ||
|
||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor; | ||
|
||
/** | ||
* Created by nekocode on 2016/2/2. | ||
*/ | ||
public class NullableStringSerializer extends TypeSerializer { | ||
|
||
public NullableStringSerializer(ValueParameterDescriptor field) { | ||
super(field); | ||
} | ||
|
||
public String readValue() { | ||
return "source.readString()"; | ||
} | ||
|
||
public String writeValue() { | ||
return "dest?.writeString(" + field.getName() + ")"; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/cn/nekocode/plugin/parcelablegenerator/typeserializers/NullableValueSerializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (C) 2016 Nekocode (https://github.com/nekocode) | ||
* | ||
* 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 cn.nekocode.plugin.parcelablegenerator.typeserializers; | ||
|
||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor; | ||
|
||
/** | ||
* Created by nekocode on 2017/4/22. | ||
*/ | ||
public class NullableValueSerializer extends TypeSerializer { | ||
|
||
public NullableValueSerializer(ValueParameterDescriptor field) { | ||
super(field); | ||
} | ||
|
||
public String readValue() { | ||
String type = field.getType().toString(); | ||
return "source.readValue(" + type.substring(0, type.length() - 1) + "::class.java.classLoader) as " + type; | ||
} | ||
|
||
public String writeValue() { | ||
return "dest?.writeValue(" + field.getName() + ")"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters