Throw when calling abstract methods; fix abstract return types

This commit is contained in:
ahocevar
2018-10-30 18:45:42 +01:00
parent 2adac0b3e7
commit 1cdd040c96
22 changed files with 273 additions and 85 deletions
+25 -8
View File
@@ -2,6 +2,7 @@
* @module ol/format/Feature
*/
import {assign} from '../obj.js';
import {abstract} from '../util.js';
import {get as getProjection, equivalent as equivalentProjection, transformExtent} from '../proj.js';
@@ -122,7 +123,9 @@ class FeatureFormat {
* @abstract
* @return {import("./FormatType.js").default} Format.
*/
getType() {}
getType() {
return abstract();
}
/**
* Read a single feature from a source.
@@ -132,7 +135,9 @@ class FeatureFormat {
* @param {ReadOptions=} opt_options Read options.
* @return {import("../Feature.js").FeatureLike} Feature.
*/
readFeature(source, opt_options) {}
readFeature(source, opt_options) {
return abstract();
}
/**
* Read all features from a source.
@@ -142,7 +147,9 @@ class FeatureFormat {
* @param {ReadOptions=} opt_options Read options.
* @return {Array<import("../Feature.js").FeatureLike>} Features.
*/
readFeatures(source, opt_options) {}
readFeatures(source, opt_options) {
return abstract();
}
/**
* Read a single geometry from a source.
@@ -152,7 +159,9 @@ class FeatureFormat {
* @param {ReadOptions=} opt_options Read options.
* @return {import("../geom/Geometry.js").default} Geometry.
*/
readGeometry(source, opt_options) {}
readGeometry(source, opt_options) {
return abstract();
}
/**
* Read the projection from a source.
@@ -161,7 +170,9 @@ class FeatureFormat {
* @param {Document|Node|Object|string} source Source.
* @return {import("../proj/Projection.js").default} Projection.
*/
readProjection(source) {}
readProjection(source) {
return abstract();
}
/**
* Encode a feature in this format.
@@ -171,7 +182,9 @@ class FeatureFormat {
* @param {WriteOptions=} opt_options Write options.
* @return {string} Result.
*/
writeFeature(feature, opt_options) {}
writeFeature(feature, opt_options) {
return abstract();
}
/**
* Encode an array of features in this format.
@@ -181,7 +194,9 @@ class FeatureFormat {
* @param {WriteOptions=} opt_options Write options.
* @return {string} Result.
*/
writeFeatures(features, opt_options) {}
writeFeatures(features, opt_options) {
return abstract();
}
/**
* Write a single geometry in this format.
@@ -191,7 +206,9 @@ class FeatureFormat {
* @param {WriteOptions=} opt_options Write options.
* @return {string} Result.
*/
writeGeometry(geometry, opt_options) {}
writeGeometry(geometry, opt_options) {
return abstract();
}
}
export default FeatureFormat;
+22 -7
View File
@@ -1,6 +1,7 @@
/**
* @module ol/format/JSONFeature
*/
import {abstract} from '../util.js';
import FeatureFormat from '../format/Feature.js';
import FormatType from '../format/FormatType.js';
@@ -59,7 +60,9 @@ class JSONFeature extends FeatureFormat {
* @protected
* @return {import("../Feature.js").default} Feature.
*/
readFeatureFromObject(object, opt_options) {}
readFeatureFromObject(object, opt_options) {
return abstract();
}
/**
* @abstract
@@ -68,7 +71,9 @@ class JSONFeature extends FeatureFormat {
* @protected
* @return {Array<import("../Feature.js").default>} Features.
*/
readFeaturesFromObject(object, opt_options) {}
readFeaturesFromObject(object, opt_options) {
return abstract();
}
/**
* Read a geometry.
@@ -90,7 +95,9 @@ class JSONFeature extends FeatureFormat {
* @protected
* @return {import("../geom/Geometry.js").default} Geometry.
*/
readGeometryFromObject(object, opt_options) {}
readGeometryFromObject(object, opt_options) {
return abstract();
}
/**
* Read the projection.
@@ -109,7 +116,9 @@ class JSONFeature extends FeatureFormat {
* @protected
* @return {import("../proj/Projection.js").default} Projection.
*/
readProjectionFromObject(object) {}
readProjectionFromObject(object) {
return abstract();
}
/**
* Encode a feature as string.
@@ -129,7 +138,9 @@ class JSONFeature extends FeatureFormat {
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @return {Object} Object.
*/
writeFeatureObject(feature, opt_options) {}
writeFeatureObject(feature, opt_options) {
return abstract();
}
/**
* Encode an array of features as string.
@@ -149,7 +160,9 @@ class JSONFeature extends FeatureFormat {
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @return {Object} Object.
*/
writeFeaturesObject(features, opt_options) {}
writeFeaturesObject(features, opt_options) {
return abstract();
}
/**
* Encode a geometry as string.
@@ -169,7 +182,9 @@ class JSONFeature extends FeatureFormat {
* @param {import("./Feature.js").WriteOptions=} opt_options Write options.
* @return {Object} Object.
*/
writeGeometryObject(geometry, opt_options) {}
writeGeometryObject(geometry, opt_options) {
return abstract();
}
}
+19 -6
View File
@@ -1,6 +1,7 @@
/**
* @module ol/format/TextFeature
*/
import {abstract} from '../util.js';
import FeatureFormat from '../format/Feature.js';
import FormatType from '../format/FormatType.js';
@@ -43,7 +44,9 @@ class TextFeature extends FeatureFormat {
* @protected
* @return {import("../Feature.js").default} Feature.
*/
readFeatureFromText(text, opt_options) {}
readFeatureFromText(text, opt_options) {
return abstract();
}
/**
* Read the features from the source.
@@ -64,7 +67,9 @@ class TextFeature extends FeatureFormat {
* @protected
* @return {Array<import("../Feature.js").default>} Features.
*/
readFeaturesFromText(text, opt_options) {}
readFeaturesFromText(text, opt_options) {
return abstract();
}
/**
* Read the geometry from the source.
@@ -85,7 +90,9 @@ class TextFeature extends FeatureFormat {
* @protected
* @return {import("../geom/Geometry.js").default} Geometry.
*/
readGeometryFromText(text, opt_options) {}
readGeometryFromText(text, opt_options) {
return abstract();
}
/**
* Read the projection from the source.
@@ -126,7 +133,9 @@ class TextFeature extends FeatureFormat {
* @protected
* @return {string} Text.
*/
writeFeatureText(feature, opt_options) {}
writeFeatureText(feature, opt_options) {
return abstract();
}
/**
* Encode an array of features as string.
@@ -147,7 +156,9 @@ class TextFeature extends FeatureFormat {
* @protected
* @return {string} Text.
*/
writeFeaturesText(features, opt_options) {}
writeFeaturesText(features, opt_options) {
return abstract();
}
/**
* Write a single geometry.
@@ -168,7 +179,9 @@ class TextFeature extends FeatureFormat {
* @protected
* @return {string} Text.
*/
writeGeometryText(geometry, opt_options) {}
writeGeometryText(geometry, opt_options) {
return abstract();
}
}
+4 -1
View File
@@ -1,6 +1,7 @@
/**
* @module ol/format/XMLFeature
*/
import {abstract} from '../util.js';
import {extend} from '../array.js';
import FeatureFormat from '../format/Feature.js';
import FormatType from '../format/FormatType.js';
@@ -122,7 +123,9 @@ class XMLFeature extends FeatureFormat {
* @protected
* @return {Array<import("../Feature.js").default>} Features.
*/
readFeaturesFromNode(node, opt_options) {}
readFeaturesFromNode(node, opt_options) {
return abstract();
}
/**
* @inheritDoc