Mwjames has uploaded a new change for review.
https://gerrit.wikimedia.org/r/76279
Change subject: Some minor renaming
......................................................................
Some minor renaming
Probably not the last of its kind but finding somekind of appropriate
name is alwasy a ...
Change-Id: I6251f0e07716ee500457aa6e91a48dc7f386f697
---
M SemanticMediaWiki.hooks.php
R includes/BasePropertyAnnotator.php
M includes/ParserData.php
M includes/ParserTextProcessor.php
R includes/PropertyChangeNotifier.php
R includes/RedirectPropertyAnnotator.php
M includes/Setup.php
R tests/phpunit/includes/BasePropertyAnnotatorTest.php
R tests/phpunit/includes/PropertyChangeNotifierTest.php
R tests/phpunit/includes/RedirectPropertyAnnotatorTest.php
10 files changed, 83 insertions(+), 91 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SemanticMediaWiki
refs/changes/79/76279/1
diff --git a/SemanticMediaWiki.hooks.php b/SemanticMediaWiki.hooks.php
index 80808be..b7b0314 100644
--- a/SemanticMediaWiki.hooks.php
+++ b/SemanticMediaWiki.hooks.php
@@ -499,7 +499,7 @@
$settings = \SMW\Settings::newFromGlobals();
$parserData = new SMW\ParserData( $parser->getTitle(),
$parser->getOutput() );
- $complementor = new \SMW\PropertyAnnotationComplementor(
$parserData->getData(), $settings );
+ $complementor = new \SMW\BasePropertyAnnotator(
$parserData->getData(), $settings );
$complementor->attach( $parserData );
$complementor->addCategories(
$parser->getOutput()->getCategoryLinks() );
@@ -646,7 +646,7 @@
$settings = \SMW\Settings::newFromGlobals();
$parserData = new SMW\ParserData( $wikiPage->getTitle(),
$parserOutput );
- $complementor = new \SMW\PropertyAnnotationComplementor(
$parserData->getData(), $settings );
+ $complementor = new \SMW\BasePropertyAnnotator(
$parserData->getData(), $settings );
$complementor->attach( $parserData );
$complementor->addSpecialProperties( $wikiPage, $revision,
$user );
diff --git a/includes/PropertyAnnotationComplementor.php
b/includes/BasePropertyAnnotator.php
similarity index 95%
rename from includes/PropertyAnnotationComplementor.php
rename to includes/BasePropertyAnnotator.php
index 790ec1a..bb69be0 100644
--- a/includes/PropertyAnnotationComplementor.php
+++ b/includes/BasePropertyAnnotator.php
@@ -12,8 +12,7 @@
use User;
/**
- * Class acting as agent that complements property annotations during
- * the store update
+ * Class that adss base property annotations (predefined, categories etc.)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -40,12 +39,11 @@
*/
/**
- * Class acting as agent that complements property annotations during
- * the store update
+ * Class that adss base property annotations (predefined, categories etc.)S
*
- * @ingroup SMW
+ * @ingroup Annotator
*/
-class PropertyAnnotationComplementor extends Subject {
+class BasePropertyAnnotator extends Subject {
/** @var SemanticData */
protected $semanticData;
diff --git a/includes/ParserData.php b/includes/ParserData.php
index 5ea128c..00786ab 100644
--- a/includes/ParserData.php
+++ b/includes/ParserData.php
@@ -407,7 +407,7 @@
if ( $processSemantics ) {
$user = \User::newFromId( $revision->getUser() );
- $complementor = new PropertyAnnotationComplementor(
$this->semanticData, Settings::newFromGlobals() );
+ $complementor = new BasePropertyAnnotator(
$this->semanticData, Settings::newFromGlobals() );
$complementor->attach( $this );
$complementor->addSpecialProperties( $wikiPage,
$revision, $user );
@@ -419,9 +419,9 @@
// Comparison must happen *before* the storage update;
// even finding uses of a property fails after its type was
changed.
if ( $this->updateJobs ) {
- $disparityDetector = new PropertyDisparityDetector(
$store, $this->semanticData, Settings::newFromGlobals() );
- $disparityDetector->attach( new ChangeObserver() );
- $disparityDetector->detectDisparity();
+ $changeNotifier = new PropertyChangeNotifier( $store,
$this->semanticData, Settings::newFromGlobals() );
+ $changeNotifier->attach( new ChangeObserver() );
+ $changeNotifier->detectChanges();
}
// Actually store semantic data, or at least clear it if needed
diff --git a/includes/ParserTextProcessor.php b/includes/ParserTextProcessor.php
index bbafd02..af02187 100644
--- a/includes/ParserTextProcessor.php
+++ b/includes/ParserTextProcessor.php
@@ -116,9 +116,9 @@
// Attest if semantic data should be processed
$this->isEnabled = NamespaceExaminer::newFromArray(
$this->settings->get( 'smwgNamespacesWithSemanticLinks' ) )->isSemanticEnabled(
$title->getNamespace() );
- // Build redirect
- $redirect = new RedirectBuilder( $this->parserData->getData() );
- $redirect->canBuild( $this->isEnabled )->build( $text );
+ // Annotate redirects
+ $redirect = new RedirectPropertyAnnotator(
$this->parserData->getData() );
+ $redirect->isEnabled( $this->isEnabled )->annotate( $text );
// Parse links to extract semantic properties
$linksInValues = $this->settings->get( 'smwgLinksInValues' );
diff --git a/includes/PropertyDisparityDetector.php
b/includes/PropertyChangeNotifier.php
similarity index 94%
rename from includes/PropertyDisparityDetector.php
rename to includes/PropertyChangeNotifier.php
index e14bf06..f0997a0 100644
--- a/includes/PropertyDisparityDetector.php
+++ b/includes/PropertyChangeNotifier.php
@@ -3,7 +3,7 @@
namespace SMW;
/**
- * Class that detects a disparity between the property object and its store
data
+ * Class that detects a change between a property and its store data
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -30,11 +30,11 @@
*/
/**
- * Class that detects a disparity between the property object and its store
data
+ * Class that detects a change between a property and its store data
*
* @ingroup SMW
*/
-class PropertyDisparityDetector extends Subject implements TitleProvider {
+class PropertyChangeNotifier extends Subject implements TitleProvider {
/** @var Store */
protected $store;
@@ -91,7 +91,7 @@
*
* @return PropertyDisparityFinder
*/
- public function detectDisparity() {
+ public function detectChanges() {
Profiler::In( __METHOD__, true );
if ( $this->semanticData->getSubject()->getNamespace() ===
SMW_NS_PROPERTY ) {
diff --git a/includes/utilities/RedirectBuilder.php
b/includes/RedirectPropertyAnnotator.php
similarity index 73%
rename from includes/utilities/RedirectBuilder.php
rename to includes/RedirectPropertyAnnotator.php
index 4dcfc6b..af70e9e 100644
--- a/includes/utilities/RedirectBuilder.php
+++ b/includes/RedirectPropertyAnnotator.php
@@ -2,14 +2,11 @@
namespace SMW;
-use SMWSemanticData;
-
use ContentHandler;
use Title;
/**
- * Process and builds a '_REDI' property where a redirect
- * object is availavle
+ * Adds a '_REDI' property annotation where a redirect is being indicated
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -35,26 +32,24 @@
*/
/**
- * Process and builds a '_REDI' property where a redirect
- * object is availavle
+ * Adds a '_REDI' property annotation where a redirect is being indicated
*
- * @ingroup Utility
- * @ingroup Builder
+ * @ingroup Annotator
*/
-class RedirectBuilder {
+class RedirectPropertyAnnotator {
- /** @var SMWSemanticData */
+ /** @var SemanticData */
protected $semanticData = null;
/** @var boolean */
- protected $canBuild = true;
+ protected $isEnabled = true;
/**
* @since 1.9
*
- * @param SMWSemanticData $semanticData
+ * @param SemanticData $semanticData
*/
- public function __construct( SMWSemanticData $semanticData ) {
+ public function __construct( SemanticData $semanticData ) {
$this->semanticData = $semanticData;
}
@@ -64,12 +59,12 @@
*
* @since 1.9
*
- * @param boolean $canBuild
+ * @param boolean $canAnnotate
*
- * @return RedirectBuilder
+ * @return RedirectPropertyAnnotator
*/
- public function canBuild( $canBuild = true ) {
- $this->canBuild = $canBuild;
+ public function isEnabled( $enabled = true ) {
+ $this->isEnabled = $enabled;
return $this;
}
@@ -79,8 +74,8 @@
*
* @par Example:
* @code
- * $redirect = new RedirectBuilder( $semanticData );
- * $redirect->canBuild( true )->build( $text );
+ * $redirect = new RedirectPropertyAnnotator( $semanticData );
+ * $redirect->isEnabled( true )->annotate( $text );
* @endcode
*
* @since 1.9
@@ -89,13 +84,13 @@
*
* @return string
*/
- public function build( /* ... */ ) {
+ public function annotate( /* ... */ ) {
$argument = func_get_arg( 0 );
- if ( $this->canBuild && is_string( $argument ) ) {
+ if ( $this->isEnabled && is_string( $argument ) ) {
$title = $this->buildFromText( $argument );
- } else if ( $this->canBuild && $argument instanceof Title ) {
+ } else if ( $this->isEnabled && $argument instanceof Title ) {
$title = $argument;
} else {
$title = null;
diff --git a/includes/Setup.php b/includes/Setup.php
index 7fe0d7b..76296ee 100644
--- a/includes/Setup.php
+++ b/includes/Setup.php
@@ -141,9 +141,10 @@
$wgAutoloadClasses['SMWParseData'] = $incDir .
'SMW_ParseData.php';
$wgAutoloadClasses['SMW\IParserData'] = $incDir .
'ParserData.php';
$wgAutoloadClasses['SMW\ParserData'] = $incDir .
'ParserData.php';
- $wgAutoloadClasses['SMW\PropertyDisparityDetector'] = $incDir .
'PropertyDisparityDetector.php';
- $wgAutoloadClasses['SMW\PropertyAnnotationComplementor'] = $incDir .
'PropertyAnnotationComplementor.php';
+ $wgAutoloadClasses['SMW\PropertyChangeNotifier'] = $incDir .
'PropertyChangeNotifier.php';
+ $wgAutoloadClasses['SMW\BasePropertyAnnotator'] = $incDir .
'BasePropertyAnnotator.php';
+ $wgAutoloadClasses['SMW\RedirectPropertyAnnotator'] = $incDir .
'RedirectPropertyAnnotator.php';
$wgAutoloadClasses['SMW\Subobject'] = $incDir .
'Subobject.php';
$wgAutoloadClasses['SMW\RecurringEvents'] = $incDir .
'RecurringEvents.php';
@@ -164,7 +165,6 @@
$wgAutoloadClasses['SMW\ArrayAccessor'] = $incDir .
'/utilities/ArrayAccessor.php';
$wgAutoloadClasses['SMW\MessageReporter'] = $incDir .
'/utilities/MessageReporter.php';
$wgAutoloadClasses['SMW\ObservableMessageReporter'] = $incDir .
'/utilities/MessageReporter.php';
- $wgAutoloadClasses['SMW\RedirectBuilder'] = $incDir .
'/utilities/RedirectBuilder.php';
$wgAutoloadClasses['SMW\ParserOutputGenerator'] = $incDir .
'/utilities/ParserOutputGenerator.php';
$wgAutoloadClasses['SMW\ChangeObserver'] = $incDir .
'/utilities/ChangeObserver.php';
$wgAutoloadClasses['SMW\TitleProvider'] = $incDir .
'/utilities/MediaWikiInterfaceProvider.php';
diff --git a/tests/phpunit/includes/PropertyAnnotationComplementorTest.php
b/tests/phpunit/includes/BasePropertyAnnotatorTest.php
similarity index 93%
rename from tests/phpunit/includes/PropertyAnnotationComplementorTest.php
rename to tests/phpunit/includes/BasePropertyAnnotatorTest.php
index 658676c..5ac9875 100644
--- a/tests/phpunit/includes/PropertyAnnotationComplementorTest.php
+++ b/tests/phpunit/includes/BasePropertyAnnotatorTest.php
@@ -2,12 +2,12 @@
namespace SMW\Test;
-use SMW\PropertyAnnotationComplementor;
+use SMW\BasePropertyAnnotator;
use SMW\SemanticData;
use SMW\DIProperty;
/**
- * Tests for the PropertyAnnotationComplementor class
+ * Tests for the BasePropertyAnnotator class
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -33,14 +33,14 @@
*/
/**
- * @covers \SMW\PropertyAnnotationComplementor
+ * @covers \SMW\BasePropertyAnnotator
*
* @ingroup Test
*
* @group SMW
* @group SMWExtension
*/
-class PropertyAnnotationComplementorTest extends ParserTestCase {
+class BasePropertyAnnotatorTest extends ParserTestCase {
/** boolean */
protected $observerStatus = null;
@@ -51,7 +51,7 @@
* @return string|false
*/
public function getClass() {
- return '\SMW\PropertyAnnotationComplementor';
+ return '\SMW\BasePropertyAnnotator';
}
/**
@@ -79,22 +79,22 @@
}
/**
- * Helper method that returns a PropertyAnnotationComplementor object
+ * Helper method that returns a BasePropertyAnnotator object
*
* @param SemanticData $semanticData
* @param array $settings
*
- * @return PropertyAnnotationComplementor
+ * @return BasePropertyAnnotator
*/
private function getInstance( SemanticData $semanticData = null,
$settings = array() ) {
- return new PropertyAnnotationComplementor(
+ return new BasePropertyAnnotator(
$semanticData === null ?
$this->newMockObject()->getMockSemanticData() : $semanticData,
$this->getSettings( $settings )
);
}
/**
- * @test PropertyAnnotationComplementor::__construct
+ * @test BasePropertyAnnotator::__construct
*
* @since 1.9
*/
@@ -103,7 +103,7 @@
}
/**
- * @test PropertyAnnotationComplementor::addCategories
+ * @test BasePropertyAnnotator::addCategories
* @dataProvider categoriesDataProvider
*
* @since 1.9
@@ -127,7 +127,7 @@
}
/**
- * @test PropertyAnnotationComplementor::addCategories
+ * @test BasePropertyAnnotator::addCategories
* @dataProvider categoriesDataProvider
*
* @since 1.9
@@ -159,7 +159,7 @@
}
/**
- * @test PropertyAnnotationComplementor::addCategories
+ * @test BasePropertyAnnotator::addCategories
* @dataProvider categoriesDataProvider
*
* @since 1.9
@@ -189,7 +189,7 @@
}
/**
- * @test PropertyAnnotationComplementor::addDefaultSort
+ * @test BasePropertyAnnotator::addDefaultSort
* @dataProvider defaultSortDataProvider
*
* @since 1.9
@@ -222,7 +222,7 @@
}
/**
- * @test PropertyAnnotationComplementor::addSpecialProperties
+ * @test BasePropertyAnnotator::addSpecialProperties
* @dataProvider specialPropertiesDataProvider
*
* @since 1.9
diff --git a/tests/phpunit/includes/PropertyDisparityDetectorTest.php
b/tests/phpunit/includes/PropertyChangeNotifierTest.php
similarity index 87%
rename from tests/phpunit/includes/PropertyDisparityDetectorTest.php
rename to tests/phpunit/includes/PropertyChangeNotifierTest.php
index 979393b..722d68c 100644
--- a/tests/phpunit/includes/PropertyDisparityDetectorTest.php
+++ b/tests/phpunit/includes/PropertyChangeNotifierTest.php
@@ -2,13 +2,13 @@
namespace SMW\Test;
-use SMW\PropertyDisparityDetector;
+use SMW\PropertyChangeNotifier;
use SMW\DIProperty;
use Title;
/**
- * Tests for the PropertyDisparityDetector class
+ * Tests for the PropertyChangeNotifier class
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -34,14 +34,14 @@
*/
/**
- * @covers \SMW\PropertyDisparityDetector
+ * @covers \SMW\PropertyChangeNotifier
*
* @ingroup Test
*
* @group SMW
* @group SMWExtension
*/
-class PropertyDisparityDetectorTest extends SemanticMediaWikiTestCase {
+class PropertyChangeNotifierTest extends SemanticMediaWikiTestCase {
/** @var DIWikiPage[] */
protected $storeValues;
@@ -52,11 +52,11 @@
* @return string|false
*/
public function getClass() {
- return '\SMW\PropertyDisparityDetector';
+ return '\SMW\PropertyChangeNotifier';
}
/**
- * Helper method that returns a PropertyDisparityDetector object
+ * Helper method that returns a PropertyChangeNotifier object
*
* @since 1.9
*
@@ -64,7 +64,7 @@
* @param $data
* @param $setting
*
- * @return PropertyDisparityDetector
+ * @return PropertyChangeNotifier
*/
private function getInstance( $store = array(), $data = array(),
$setting = null ) {
@@ -74,11 +74,11 @@
'smwgDeclarationProperties' => $setting === null ?
array( '_PVAL' ): $setting
) );
- return new PropertyDisparityDetector( $mockStore, $mockData,
$settings );
+ return new PropertyChangeNotifier( $mockStore, $mockData,
$settings );
}
/**
- * @test PropertyDisparityDetector::__construct
+ * @test PropertyChangeNotifier::__construct
*
* @since 1.9
*/
@@ -87,7 +87,7 @@
}
/**
- * @test PropertyDisparityDetector::detectDisparity
+ * @test PropertyChangeNotifier::detectChanges
* @dataProvider dataItemDataProvider
*
* @since 1.9
@@ -109,7 +109,7 @@
$instance = $this->getInstance( $store, $data, $settings );
$observer = new MockChangeObserver( $instance );
- $this->assertInstanceOf( $this->getClass(),
$instance->detectDisparity() );
+ $this->assertInstanceOf( $this->getClass(),
$instance->detectChanges() );
$this->assertEquals( $subject->getTitle(),
$instance->getTitle() );
$this->assertEquals( $expected['change'],
$instance->hasDisparity() );
diff --git a/tests/phpunit/includes/utilities/RedirectBuilderTest.php
b/tests/phpunit/includes/RedirectPropertyAnnotatorTest.php
similarity index 68%
rename from tests/phpunit/includes/utilities/RedirectBuilderTest.php
rename to tests/phpunit/includes/RedirectPropertyAnnotatorTest.php
index 9c93cb5..c5375de 100644
--- a/tests/phpunit/includes/utilities/RedirectBuilderTest.php
+++ b/tests/phpunit/includes/RedirectPropertyAnnotatorTest.php
@@ -2,13 +2,12 @@
namespace SMW\Test;
-use SMW\RedirectBuilder;
+use SMW\RedirectPropertyAnnotator;
use SMW\DIProperty;
-
-use SMWSemanticData;
+use SMW\SemanticData;
/**
- * Tests for the RedirectBuilder class
+ * Tests for the RedirectPropertyAnnotator class
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -34,14 +33,14 @@
*/
/**
- * @covers \SMW\RedirectBuilder
+ * @covers \SMW\RedirectPropertyAnnotator
*
* @ingroup Test
*
* @group SMW
* @group SMWExtension
*/
-class RedirectBuilderTest extends SemanticMediaWikiTestCase {
+class RedirectPropertyAnnotatorTest extends SemanticMediaWikiTestCase {
/**
* Returns the name of the class to be tested
@@ -49,24 +48,24 @@
* @return string|false
*/
public function getClass() {
- return '\SMW\RedirectBuilder';
+ return '\SMW\RedirectPropertyAnnotator';
}
/**
- * Helper method that returns a RedirectBuilder object
+ * Helper method that returns a RedirectPropertyAnnotator object
*
* @since 1.9
*
* @param $data
*
- * @return RedirectBuilder
+ * @return RedirectPropertyAnnotator
*/
- private function getInstance( SMWSemanticData $data = null ) {
- return new RedirectBuilder( $data === null ?
$this->newMockObject()->getMockSemanticData() : $data );
+ private function getInstance( SemanticData $data = null ) {
+ return new RedirectPropertyAnnotator( $data === null ?
$this->newMockObject()->getMockSemanticData() : $data );
}
/**
- * @test RedirectBuilder::__construct
+ * @test RedirectPropertyAnnotator::__construct
*
* @since 1.9
*/
@@ -75,7 +74,7 @@
}
/**
- * @test RedirectBuilder::build
+ * @test RedirectPropertyAnnotator::annotate
* @dataProvider redirectsDataProvider
*
* @since 1.9
@@ -85,10 +84,10 @@
*/
public function testBuild( $test, $expected ) {
- $semanticData = new SMWSemanticData( $this->getSubject() );
+ $semanticData = new SemanticData( $this->getSubject() );
$instance = $this->getInstance( $semanticData );
- $instance->canBuild( $test['canBuild'] )->build( $test['build']
);
+ $instance->isEnabled( $test['isEnabled'] )->annotate(
$test['text'] );
$this->assertSemanticData( $semanticData, $expected );
}
@@ -105,7 +104,7 @@
// #0 Title
$provider[] = array(
- array( 'build' => $title, 'canBuild' => true ),
+ array( 'text' => $title, 'isEnabled' => true ),
array(
'propertyCount' => 1,
'propertyKey' => '_REDI',
@@ -115,7 +114,7 @@
// #1 Disabled
$provider[] = array(
- array( 'build' => $title, 'canBuild' => false ),
+ array( 'text' => $title, 'isEnabled' => false ),
array(
'propertyCount' => 0,
)
@@ -123,7 +122,7 @@
// #2 Free text
$provider[] = array(
- array( 'build' => '#REDIRECT [[:Lala]]', 'canBuild' =>
true ),
+ array( 'text' => '#REDIRECT [[:Lala]]', 'isEnabled' =>
true ),
array(
'propertyCount' => 1,
'propertyKey' => '_REDI',
@@ -133,7 +132,7 @@
// #3 Free text
$provider[] = array(
- array( 'build' => '#REDIRECT [[Lala]]', 'canBuild' =>
true ),
+ array( 'text' => '#REDIRECT [[Lala]]', 'isEnabled' =>
true ),
array(
'propertyCount' => 1,
'propertyKey' => '_REDI',
@@ -143,7 +142,7 @@
// #4 Disabled free text
$provider[] = array(
- array( 'build' => '#REDIRECT [[:Lala]]', 'canBuild' =>
false ),
+ array( 'text' => '#REDIRECT [[:Lala]]', 'isEnabled' =>
false ),
array(
'propertyCount' => 0,
)
@@ -151,7 +150,7 @@
// #5 Invalid free text
$provider[] = array(
- array( 'build' => '#REDIR [[:Lala]]', 'canBuild' =>
true ),
+ array( 'text' => '#REDIR [[:Lala]]', 'isEnabled' =>
true ),
array(
'propertyCount' => 0,
)
@@ -159,7 +158,7 @@
// #6 Empty
$provider[] = array(
- array( 'build' => '', 'canBuild' => true ),
+ array( 'text' => '', 'isEnabled' => true ),
array(
'propertyCount' => 0,
)
--
To view, visit https://gerrit.wikimedia.org/r/76279
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6251f0e07716ee500457aa6e91a48dc7f386f697
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SemanticMediaWiki
Gerrit-Branch: master
Gerrit-Owner: Mwjames <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits