Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SourceEditorModels module #16

Merged
merged 10 commits into from Oct 5, 2020
Merged

SourceEditorModels module #16

merged 10 commits into from Oct 5, 2020

Conversation

miguelangel-dev
Copy link
Member

@miguelangel-dev miguelangel-dev commented Aug 19, 2020

This PR extracts common Commands model from nef-plugin and nef, in a new module called SourceEditorModels - reducing the duplicity of the code.

It keeps sync both modules (plugin and related app), and remove any string check. Also, it removes these declarations from Info.plist, making the commands typed.

See the entry-class SourceEditorExtension for more information.

minor changes
@miguelangel-dev miguelangel-dev changed the title Source Editor Models SourceEditorModels module Aug 19, 2020
nef-models/Command.swift Outdated Show resolved Hide resolved
nef-plugin/EditorError.swift Outdated Show resolved Hide resolved
nef-plugin/EditorError.swift Outdated Show resolved Hide resolved
nef-plugin/EditorError.swift Outdated Show resolved Hide resolved
nef-plugin/SourceEditorCommand.swift Outdated Show resolved Hide resolved
@miguelangel-dev miguelangel-dev force-pushed the commands_shared_module branch 2 times, most recently from 5a72d17 to 63a6d46 Compare August 20, 2020 08:42
Co-authored-by: Tomás Ruiz-López <truizlop@gmail.com>

Update nef-plugin/EditorError.swift

result: adding discardableResult to fold
nef-plugin/AppScheme.swift Outdated Show resolved Hide resolved
nef-plugin/SourceEditorExtension.swift Outdated Show resolved Hide resolved
nef-plugin/Utils/Result+Extensions.swift Outdated Show resolved Hide resolved
nef/AppDelegate.swift Outdated Show resolved Hide resolved
nef-models/Command+URLQueryItem.swift Outdated Show resolved Hide resolved
nef-models/MenuEditorCommand.swift Outdated Show resolved Hide resolved

import Foundation

enum EditorError: Int, Error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any need to make this an Int backed enum?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, Xcode requires throw errors as NSError and we need setup an error code - you can find the use in terminateError

nef-plugin/SourceEditorExtension.swift Outdated Show resolved Hide resolved
nef-plugin/Utils/Result+Extensions.swift Outdated Show resolved Hide resolved
nef/Command.swift Outdated Show resolved Hide resolved
nef/Extensions/URL+Extension.swift Show resolved Hide resolved
Comment on lines 8 to 15
case .exportSnippetToFile:
return URLQueryItem(name: key, value: code)
case .exportSnippetToClipboard:
return URLQueryItem(name: key, value: code)
case .markdownPage:
return URLQueryItem(name: key, value: code)
case .playgroundBook:
return URLQueryItem(name: key, value: code)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 4 could be grouped as a single case, as you do below with preferences and about.

@miguelangel-dev miguelangel-dev merged commit 16e164b into master Oct 5, 2020
@miguelangel-dev miguelangel-dev deleted the commands_shared_module branch October 5, 2020 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants