mirror of
https://github.com/coteditor/CotEditor.git
synced 2024-09-11 11:25:57 +03:00
Use table for syntax validation result
This commit is contained in:
parent
f37b6f1cb0
commit
ab91035c20
@ -8,7 +8,9 @@ Change Log
|
||||
### Improvements
|
||||
|
||||
- Change not to highlight occurrences of the selection when there are more than 100.
|
||||
- Now, syntax style validation is automatically start when the pane switched to “Valitation”.
|
||||
- Update validation pane in the syntax style editor:
|
||||
- Now, validation is performed automatically when the pane switched to “Valitation”.
|
||||
|
||||
|
||||
### Fixes
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
<controllerPlaceholder storyboardName="SyntaxValidationView" id="h9E-mw-xBs" sceneMemberID="viewController"/>
|
||||
<customObject id="cOp-wY-5Yv" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="1296" y="97"/>
|
||||
<point key="canvasLocation" x="1296" y="119"/>
|
||||
</scene>
|
||||
<!--SyntaxOutlineEditView-->
|
||||
<scene sceneID="SbB-kN-1fX">
|
||||
@ -65,7 +65,7 @@
|
||||
<controllerPlaceholder storyboardName="SyntaxInfoEditView" id="Acd-43-iJP" sceneMemberID="viewController"/>
|
||||
<customObject id="VCx-Ca-MEt" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="1289" y="58"/>
|
||||
<point key="canvasLocation" x="1289" y="81"/>
|
||||
</scene>
|
||||
<!--SyntaxFileMappingEditView-->
|
||||
<scene sceneID="dqI-HU-kqQ">
|
||||
@ -364,6 +364,6 @@ DQ
|
||||
</resources>
|
||||
<inferredMetricsTieBreakers>
|
||||
<segue reference="evB-SF-2md"/>
|
||||
<segue reference="oWW-tk-Ap2"/>
|
||||
<segue reference="zM9-LR-mh8"/>
|
||||
</inferredMetricsTieBreakers>
|
||||
</document>
|
||||
|
@ -14,42 +14,8 @@
|
||||
<rect key="frame" x="0.0" y="0.0" width="450" height="340"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<subviews>
|
||||
<scrollView horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" translatesAutoresizingMaskIntoConstraints="NO" id="R3h-vn-LqF">
|
||||
<rect key="frame" x="12" y="12" width="426" height="291"/>
|
||||
<clipView key="contentView" id="IWP-KU-odZ">
|
||||
<rect key="frame" x="1" y="1" width="424" height="289"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textView editable="NO" importsGraphics="NO" richText="NO" verticallyResizable="YES" usesFontPanel="YES" findStyle="bar" incrementalSearchingEnabled="YES" usesRuler="YES" id="Wdj-BP-SpZ">
|
||||
<rect key="frame" x="0.0" y="0.0" width="424" height="289"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
<size key="minSize" width="424" height="289"/>
|
||||
<size key="maxSize" width="426" height="10000000"/>
|
||||
<color key="insertionPointColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
||||
<userDefinedRuntimeAttributes>
|
||||
<userDefinedRuntimeAttribute type="size" keyPath="textContainerInset">
|
||||
<size key="value" width="4" height="6"/>
|
||||
</userDefinedRuntimeAttribute>
|
||||
</userDefinedRuntimeAttributes>
|
||||
<connections>
|
||||
<binding destination="0x1-oE-Hn6" name="value" keyPath="result" id="Qsv-dL-MVk"/>
|
||||
</connections>
|
||||
</textView>
|
||||
</subviews>
|
||||
</clipView>
|
||||
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="YES" id="uCl-3b-64W">
|
||||
<rect key="frame" x="-100" y="-100" width="87" height="18"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
<scroller key="verticalScroller" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="udZ-qb-RXt">
|
||||
<rect key="frame" x="409" y="1" width="16" height="289"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
</scrollView>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Iou-wI-Hw7">
|
||||
<rect key="frame" x="34" y="311" width="144" height="17"/>
|
||||
<rect key="frame" x="30" y="315" width="144" height="17"/>
|
||||
<textFieldCell key="cell" lineBreakMode="clipping" title="VALIDATION MESSAGE" id="xyN-YF-VuY">
|
||||
<font key="font" usesAppearanceFont="YES"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
@ -60,27 +26,166 @@
|
||||
</connections>
|
||||
</textField>
|
||||
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="ZQE-Vk-Dls">
|
||||
<rect key="frame" x="12" y="312" width="16" height="16"/>
|
||||
<rect key="frame" x="12" y="316" width="16" height="16"/>
|
||||
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="NSStatusAvailable" id="Las-EU-Zwm"/>
|
||||
<connections>
|
||||
<binding destination="0x1-oE-Hn6" name="value" keyPath="statusImage" id="Dof-tr-w5v"/>
|
||||
</connections>
|
||||
</imageView>
|
||||
<scrollView autohidesScrollers="YES" horizontalLineScroll="45" horizontalPageScroll="10" verticalLineScroll="45" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1nv-B9-u5j">
|
||||
<rect key="frame" x="12" y="12" width="426" height="295"/>
|
||||
<clipView key="contentView" id="KLI-Xb-J6D">
|
||||
<rect key="frame" x="1" y="1" width="424" height="293"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" selectionHighlightStyle="none" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" rowHeight="43" rowSizeStyle="automatic" viewBased="YES" id="kiS-FF-tvd">
|
||||
<rect key="frame" x="0.0" y="0.0" width="424" height="293"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<size key="intercellSpacing" width="3" height="2"/>
|
||||
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
|
||||
<tableColumns>
|
||||
<tableColumn width="421" minWidth="40" maxWidth="1000" id="hFj-1b-cNy">
|
||||
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Type">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
|
||||
</tableHeaderCell>
|
||||
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" title="Text Cell" id="IKy-ee-cEi">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
|
||||
<prototypeCellViews>
|
||||
<tableCellView id="v53-HN-2Ah">
|
||||
<rect key="frame" x="1" y="1" width="421" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="nJD-cM-uUf">
|
||||
<rect key="frame" x="25" y="22" width="35" height="17"/>
|
||||
<textFieldCell key="cell" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Type" id="FZs-ra-kr1">
|
||||
<font key="font" metaFont="systemSemibold" size="13"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
<connections>
|
||||
<binding destination="v53-HN-2Ah" name="value" keyPath="objectValue.localizedType" id="cGG-y0-zEL"/>
|
||||
</connections>
|
||||
</textField>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="s4B-hc-j2A">
|
||||
<rect key="frame" x="30" y="4" width="389" height="14"/>
|
||||
<textFieldCell key="cell" controlSize="small" lineBreakMode="truncatingTail" selectable="YES" title="Failure reason." id="wMe-Bz-f7x">
|
||||
<font key="font" metaFont="smallSystem"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
<connections>
|
||||
<binding destination="v53-HN-2Ah" name="value" keyPath="objectValue.failureReason" id="ZuM-Et-Nan"/>
|
||||
</connections>
|
||||
</textField>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="eK7-2v-tsV">
|
||||
<rect key="frame" x="2" y="22" width="23" height="17"/>
|
||||
<textFieldCell key="cell" lineBreakMode="clipping" title="⚠️" id="rVB-57-xcy">
|
||||
<font key="font" usesAppearanceFont="YES"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="vbu-QJ-zeu">
|
||||
<rect key="frame" x="68" y="22" width="58" height="17"/>
|
||||
<textFieldCell key="cell" lineBreakMode="clipping" selectable="YES" title="^foobar$" id="8nz-I2-dL1">
|
||||
<font key="font" usesAppearanceFont="YES"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
<connections>
|
||||
<binding destination="v53-HN-2Ah" name="value" keyPath="objectValue.string" id="RiW-Ov-PiY"/>
|
||||
</connections>
|
||||
</textField>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="1wg-FE-xkW">
|
||||
<rect key="frame" x="56" y="22" width="8" height="17"/>
|
||||
<textFieldCell key="cell" lineBreakMode="clipping" title=":" id="3Ek-Hr-eIx">
|
||||
<font key="font" usesAppearanceFont="YES"/>
|
||||
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ucl-fe-QlC">
|
||||
<rect key="frame" x="130" y="22" width="88" height="17"/>
|
||||
<textFieldCell key="cell" lineBreakMode="clipping" title="(Begin String)" id="aWr-K6-iuS">
|
||||
<font key="font" usesAppearanceFont="YES"/>
|
||||
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
|
||||
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
<connections>
|
||||
<binding destination="v53-HN-2Ah" name="displayPatternValue1" keyPath="objectValue.localizedRole" id="BQG-xB-fwr">
|
||||
<dictionary key="options">
|
||||
<string key="NSDisplayPattern">(%{value1}@)</string>
|
||||
</dictionary>
|
||||
</binding>
|
||||
</connections>
|
||||
</textField>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstAttribute="trailing" secondItem="s4B-hc-j2A" secondAttribute="trailing" constant="4" id="0hg-ot-cbE"/>
|
||||
<constraint firstItem="eK7-2v-tsV" firstAttribute="leading" secondItem="v53-HN-2Ah" secondAttribute="leading" constant="4" id="1qq-RR-wy1"/>
|
||||
<constraint firstItem="ucl-fe-QlC" firstAttribute="leading" secondItem="vbu-QJ-zeu" secondAttribute="trailing" constant="8" symbolic="YES" id="8nT-BH-xOT"/>
|
||||
<constraint firstItem="s4B-hc-j2A" firstAttribute="top" secondItem="nJD-cM-uUf" secondAttribute="bottom" constant="4" id="9RQ-hZ-t5y"/>
|
||||
<constraint firstItem="s4B-hc-j2A" firstAttribute="leading" secondItem="v53-HN-2Ah" secondAttribute="leading" constant="32" id="Bmb-5c-jHP"/>
|
||||
<constraint firstAttribute="bottom" secondItem="s4B-hc-j2A" secondAttribute="bottom" constant="4" id="EtE-3I-L27"/>
|
||||
<constraint firstItem="1wg-FE-xkW" firstAttribute="firstBaseline" secondItem="nJD-cM-uUf" secondAttribute="firstBaseline" id="JQ2-tG-k07"/>
|
||||
<constraint firstItem="nJD-cM-uUf" firstAttribute="leading" secondItem="eK7-2v-tsV" secondAttribute="trailing" constant="4" id="Klm-t1-BHx"/>
|
||||
<constraint firstItem="vbu-QJ-zeu" firstAttribute="firstBaseline" secondItem="nJD-cM-uUf" secondAttribute="firstBaseline" id="MrT-Qn-rIT"/>
|
||||
<constraint firstItem="nJD-cM-uUf" firstAttribute="top" secondItem="v53-HN-2Ah" secondAttribute="top" constant="4" id="Q0u-Al-CMl"/>
|
||||
<constraint firstItem="nJD-cM-uUf" firstAttribute="firstBaseline" secondItem="eK7-2v-tsV" secondAttribute="firstBaseline" id="YB2-jn-9LG"/>
|
||||
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="ucl-fe-QlC" secondAttribute="trailing" constant="4" id="b1F-QJ-68Z"/>
|
||||
<constraint firstItem="vbu-QJ-zeu" firstAttribute="leading" secondItem="1wg-FE-xkW" secondAttribute="trailing" constant="8" symbolic="YES" id="ct8-xd-rkt"/>
|
||||
<constraint firstItem="ucl-fe-QlC" firstAttribute="firstBaseline" secondItem="nJD-cM-uUf" secondAttribute="firstBaseline" id="eqv-AO-2Oa"/>
|
||||
<constraint firstItem="1wg-FE-xkW" firstAttribute="leading" secondItem="nJD-cM-uUf" secondAttribute="trailing" id="jla-zX-m8r"/>
|
||||
</constraints>
|
||||
<connections>
|
||||
<outlet property="textField" destination="nJD-cM-uUf" id="RAp-ge-Cbj"/>
|
||||
</connections>
|
||||
</tableCellView>
|
||||
</prototypeCellViews>
|
||||
</tableColumn>
|
||||
</tableColumns>
|
||||
<connections>
|
||||
<binding destination="D6H-P7-Yf6" name="content" keyPath="arrangedObjects" id="nxz-sl-vMq"/>
|
||||
</connections>
|
||||
</tableView>
|
||||
</subviews>
|
||||
</clipView>
|
||||
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="oTE-UX-hYc">
|
||||
<rect key="frame" x="1" y="274" width="424" height="16"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
<scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="Z0f-yo-any">
|
||||
<rect key="frame" x="224" y="17" width="15" height="102"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
</scrollView>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstItem="R3h-vn-LqF" firstAttribute="top" secondItem="Iou-wI-Hw7" secondAttribute="bottom" constant="8" symbolic="YES" id="1tF-jf-0kE"/>
|
||||
<constraint firstAttribute="trailing" secondItem="R3h-vn-LqF" secondAttribute="trailing" constant="12" id="7hM-Hs-DFA"/>
|
||||
<constraint firstAttribute="trailing" secondItem="1nv-B9-u5j" secondAttribute="trailing" constant="12" id="9uy-PW-Qlv"/>
|
||||
<constraint firstAttribute="bottom" secondItem="1nv-B9-u5j" secondAttribute="bottom" constant="12" id="BNh-XZ-4C8"/>
|
||||
<constraint firstItem="1nv-B9-u5j" firstAttribute="top" secondItem="Iou-wI-Hw7" secondAttribute="bottom" constant="8" symbolic="YES" id="Bnv-Og-a7U"/>
|
||||
<constraint firstItem="Iou-wI-Hw7" firstAttribute="centerY" secondItem="ZQE-Vk-Dls" secondAttribute="centerY" id="CNp-Uo-MLc"/>
|
||||
<constraint firstItem="R3h-vn-LqF" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" constant="12" id="JPb-Xh-czK"/>
|
||||
<constraint firstItem="Iou-wI-Hw7" firstAttribute="leading" secondItem="ZQE-Vk-Dls" secondAttribute="trailing" constant="8" symbolic="YES" id="Nva-Kw-pGa"/>
|
||||
<constraint firstItem="Iou-wI-Hw7" firstAttribute="leading" secondItem="ZQE-Vk-Dls" secondAttribute="trailing" constant="4" id="Nva-Kw-pGa"/>
|
||||
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="Iou-wI-Hw7" secondAttribute="trailing" constant="20" symbolic="YES" id="d6J-hm-Nnp"/>
|
||||
<constraint firstAttribute="bottom" secondItem="R3h-vn-LqF" secondAttribute="bottom" constant="12" id="en7-C0-egD"/>
|
||||
<constraint firstItem="Iou-wI-Hw7" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" constant="12" id="o5R-Rg-51E"/>
|
||||
<constraint firstItem="Iou-wI-Hw7" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" constant="8" id="o5R-Rg-51E"/>
|
||||
<constraint firstItem="1nv-B9-u5j" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" constant="12" id="smK-lJ-ePu"/>
|
||||
<constraint firstItem="ZQE-Vk-Dls" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" constant="12" id="ttj-7Z-ZcK"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</viewController>
|
||||
<customObject id="Oke-qj-VSe" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
|
||||
<arrayController objectClassName="SyntaxStyleValidator.StyleError" editable="NO" avoidsEmptySelection="NO" id="D6H-P7-Yf6">
|
||||
<connections>
|
||||
<binding destination="0x1-oE-Hn6" name="contentArray" keyPath="errors" id="Co2-l6-78K"/>
|
||||
</connections>
|
||||
</arrayController>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="111" y="97"/>
|
||||
</scene>
|
||||
|
@ -171,6 +171,10 @@ final class SyntaxEditViewController: NSViewController, NSTextFieldDelegate, NST
|
||||
|
||||
self.style.setDictionary(style)
|
||||
self.isRestoreble = false
|
||||
|
||||
// update validation result if displayed
|
||||
let tabViewController = self.tabViewController!
|
||||
(tabViewController.tabViewItems[tabViewController.selectedTabViewItemIndex].viewController as? SyntaxValidationViewController)?.validateStyle()
|
||||
}
|
||||
|
||||
|
||||
|
@ -29,7 +29,7 @@ import Foundation
|
||||
final class SyntaxStyleValidator {
|
||||
|
||||
/// model object for syntax validation result
|
||||
struct StyleError: LocalizedError {
|
||||
final class StyleError: NSObject, LocalizedError {
|
||||
|
||||
enum ErrorKind {
|
||||
case duplicated
|
||||
@ -46,7 +46,18 @@ final class SyntaxStyleValidator {
|
||||
let kind: ErrorKind
|
||||
let type: String
|
||||
let role: Role
|
||||
let string: String
|
||||
@objc let string: String
|
||||
|
||||
|
||||
init(kind: ErrorKind, type: String, role: Role, string: String) {
|
||||
|
||||
self.kind = kind
|
||||
self.type = type
|
||||
self.role = role
|
||||
self.string = string
|
||||
|
||||
super.init()
|
||||
}
|
||||
|
||||
|
||||
var errorDescription: String? {
|
||||
@ -55,7 +66,7 @@ final class SyntaxStyleValidator {
|
||||
}
|
||||
|
||||
|
||||
var failureReason: String? {
|
||||
@objc var failureReason: String? {
|
||||
|
||||
switch self.kind {
|
||||
case .duplicated:
|
||||
@ -70,7 +81,13 @@ final class SyntaxStyleValidator {
|
||||
}
|
||||
|
||||
|
||||
private var localizedRole: String {
|
||||
@objc var localizedType: String {
|
||||
|
||||
return self.type.localized
|
||||
}
|
||||
|
||||
|
||||
@objc var localizedRole: String {
|
||||
|
||||
switch self.role {
|
||||
case .begin:
|
||||
|
@ -29,9 +29,10 @@ final class SyntaxValidationViewController: NSViewController {
|
||||
|
||||
// MARK: Private Properties
|
||||
|
||||
@objc private dynamic var errors: [SyntaxStyleValidator.StyleError] = []
|
||||
|
||||
@objc private dynamic var statusImage: NSImage?
|
||||
@objc private dynamic var message = ""
|
||||
@objc private dynamic var result = ""
|
||||
|
||||
|
||||
|
||||
@ -40,11 +41,21 @@ final class SyntaxValidationViewController: NSViewController {
|
||||
|
||||
override func viewWillAppear() {
|
||||
|
||||
// update validation result
|
||||
let style = self.representedObject as! SyntaxManager.StyleDictionary
|
||||
let errors = SyntaxStyleValidator.validate(style)
|
||||
super.viewWillAppear()
|
||||
|
||||
self.display(errors: errors)
|
||||
self.validateStyle()
|
||||
}
|
||||
|
||||
|
||||
|
||||
// MARK: Public Methods
|
||||
|
||||
func validateStyle() {
|
||||
|
||||
let style = self.representedObject as! SyntaxManager.StyleDictionary
|
||||
|
||||
self.errors = SyntaxStyleValidator.validate(style)
|
||||
self.updateMessage()
|
||||
}
|
||||
|
||||
|
||||
@ -52,31 +63,21 @@ final class SyntaxValidationViewController: NSViewController {
|
||||
// MARK: Private Methods
|
||||
|
||||
/// insert the results to text view
|
||||
private func display(errors: [SyntaxStyleValidator.StyleError]) {
|
||||
private func updateMessage() {
|
||||
|
||||
let imageName = errors.isEmpty ? NSImage.statusAvailableName : NSImage.statusUnavailableName
|
||||
let imageName = self.errors.isEmpty ? NSImage.statusAvailableName : NSImage.statusUnavailableName
|
||||
self.statusImage = NSImage(named: imageName)
|
||||
|
||||
self.message = {
|
||||
switch errors.count {
|
||||
switch self.errors.count {
|
||||
case 0:
|
||||
return "No error was found.".localized
|
||||
return "No error found.".localized
|
||||
case 1:
|
||||
return "An error was found!".localized
|
||||
return "An error found!".localized
|
||||
default:
|
||||
return String(format: "%i errors were found!".localized, errors.count)
|
||||
}
|
||||
}()
|
||||
|
||||
self.result = errors
|
||||
.map { error -> String in
|
||||
guard let failureReason = error.failureReason else {
|
||||
return error.localizedDescription
|
||||
}
|
||||
return error.localizedDescription + "\n\t> " + failureReason
|
||||
}
|
||||
.map { "⚠️ " + $0 }
|
||||
.joined(separator: "\n\n")
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -410,9 +410,9 @@
|
||||
"Syntax Validation" = "Syntaxvalidierung";
|
||||
|
||||
// Syntax style validation results
|
||||
"No error was found." = "Kein Fehler wurde gefunden.";
|
||||
"An error was found!" = "Ein Fehler wurde gefunden.";
|
||||
"%i errors were found!" = "%i Fehler wurden gefunden.";
|
||||
"No error found." = "Kein Fehler wurde gefunden.";
|
||||
"An error found!" = "Ein Fehler wurde gefunden.";
|
||||
"%i errors found!" = "%i Fehler wurden gefunden.";
|
||||
|
||||
|
||||
|
||||
|
@ -411,9 +411,9 @@
|
||||
"Syntax Validation" = "Validazione sintassi";
|
||||
|
||||
// Syntax style validation results
|
||||
"No error was found." = "Nessun errore rilevato.";
|
||||
"An error was found!" = "Trovato un errore.";
|
||||
"%i errors were found!" = "Trovati %i errori.";
|
||||
"No error found." = "Nessun errore rilevato.";
|
||||
"An error found!" = "Trovato un errore.";
|
||||
"%i errors found!" = "Trovati %i errori.";
|
||||
|
||||
|
||||
|
||||
|
@ -411,9 +411,9 @@
|
||||
"Syntax Validation" = "シンタックスの検証";
|
||||
|
||||
// Syntax style validation results
|
||||
"No error was found." = "エラーはありませんでした。";
|
||||
"An error was found!" = "エラーがありました!";
|
||||
"%i errors were found!" = "%i個のエラーがありました!";
|
||||
"No error found." = "エラーはありません。";
|
||||
"An error found!" = "エラーがあります!";
|
||||
"%i errors found!" = "%i個のエラーがあります!";
|
||||
|
||||
|
||||
|
||||
@ -462,7 +462,7 @@
|
||||
"End string" = "終了文字列";
|
||||
"Regular expression" = "正規表現";
|
||||
"The same word is registered multiple times." = "重複して登録されています。";
|
||||
"Regular Expression Error: " = "正規表現エラー:";
|
||||
"Regular Expression Error: " = "正規表現エラー: ";
|
||||
|
||||
|
||||
|
||||
|
@ -411,9 +411,9 @@
|
||||
"Syntax Validation" = "Validação da Sintaxe";
|
||||
|
||||
// Syntax style validation results
|
||||
"No error was found." = "Nenhum erro encontrado.";
|
||||
"An error was found!" = "1 erro encontrado!";
|
||||
"%i errors were found!" = "%i erros encontrados!";
|
||||
"No error found." = "Nenhum erro encontrado.";
|
||||
"An error found!" = "1 erro encontrado!";
|
||||
"%i errors found!" = "%i erros encontrados!";
|
||||
|
||||
|
||||
|
||||
|
@ -411,9 +411,9 @@
|
||||
"Syntax Validation" = "语法验证";
|
||||
|
||||
// Syntax style validation results
|
||||
"No error was found." = "没有发现错误";
|
||||
"An error was found!" = "发现 1 个错误";
|
||||
"%i errors were found!" = "发现 %i 个错误";
|
||||
"No error found." = "没有发现错误";
|
||||
"An error found!" = "发现 1 个错误";
|
||||
"%i errors found!" = "发现 %i 个错误";
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user