mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
Move decoration into mod.rs 🔙
This commit is contained in:
parent
bc1b4216a8
commit
3e791e3337
@ -4,17 +4,9 @@
|
|||||||
//! layout on a best effort process, generating diagnostics for incorrect
|
//! layout on a best effort process, generating diagnostics for incorrect
|
||||||
//! things.
|
//! things.
|
||||||
|
|
||||||
#[cfg(feature = "serialize")]
|
|
||||||
use serde::Serialize;
|
|
||||||
|
|
||||||
use crate::syntax::SpanVec;
|
|
||||||
|
|
||||||
/// A list of spanned diagnostics.
|
|
||||||
pub type Diagnostics = SpanVec<Diagnostic>;
|
|
||||||
|
|
||||||
/// A diagnostic that arose in parsing or layouting.
|
/// A diagnostic that arose in parsing or layouting.
|
||||||
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd)]
|
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd)]
|
||||||
#[cfg_attr(feature = "serialize", derive(Serialize))]
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
|
||||||
pub struct Diagnostic {
|
pub struct Diagnostic {
|
||||||
/// How severe / important the diagnostic is.
|
/// How severe / important the diagnostic is.
|
||||||
pub level: Level,
|
pub level: Level,
|
||||||
@ -24,7 +16,7 @@ pub struct Diagnostic {
|
|||||||
|
|
||||||
/// How severe / important a diagnostic is.
|
/// How severe / important a diagnostic is.
|
||||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
||||||
#[cfg_attr(feature = "serialize", derive(Serialize))]
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
|
||||||
#[cfg_attr(feature = "serialize", serde(rename_all = "camelCase"))]
|
#[cfg_attr(feature = "serialize", serde(rename_all = "camelCase"))]
|
||||||
pub enum Level {
|
pub enum Level {
|
||||||
Warning,
|
Warning,
|
||||||
|
@ -46,11 +46,11 @@ use std::pin::Pin;
|
|||||||
|
|
||||||
use crate::compute::scope::Scope;
|
use crate::compute::scope::Scope;
|
||||||
use crate::compute::value::Value;
|
use crate::compute::value::Value;
|
||||||
use crate::diagnostic::Diagnostics;
|
use crate::diagnostic::Diagnostic;
|
||||||
use crate::font::SharedFontLoader;
|
use crate::font::SharedFontLoader;
|
||||||
use crate::layout::{Commands, MultiLayout};
|
use crate::layout::{Commands, MultiLayout};
|
||||||
use crate::style::{LayoutStyle, PageStyle, TextStyle};
|
use crate::style::{LayoutStyle, PageStyle, TextStyle};
|
||||||
use crate::syntax::{Decorations, Offset, Pos, SyntaxTree};
|
use crate::syntax::{Decoration, Offset, Pos, SpanVec, SyntaxTree};
|
||||||
|
|
||||||
/// Transforms source code into typesetted layouts.
|
/// Transforms source code into typesetted layouts.
|
||||||
///
|
///
|
||||||
@ -166,9 +166,9 @@ impl Pass<Value> {
|
|||||||
#[derive(Debug, Default, Clone, Eq, PartialEq)]
|
#[derive(Debug, Default, Clone, Eq, PartialEq)]
|
||||||
pub struct Feedback {
|
pub struct Feedback {
|
||||||
/// Diagnostics about the source code.
|
/// Diagnostics about the source code.
|
||||||
pub diagnostics: Diagnostics,
|
pub diagnostics: SpanVec<Diagnostic>,
|
||||||
/// Decorations of the source code for semantic syntax highlighting.
|
/// Decorations of the source code for semantic syntax highlighting.
|
||||||
pub decorations: Decorations,
|
pub decorations: SpanVec<Decoration>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Feedback {
|
impl Feedback {
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
//! Decorations for semantic syntax highlighting.
|
|
||||||
|
|
||||||
#[cfg(feature = "serialize")]
|
|
||||||
use serde::Serialize;
|
|
||||||
|
|
||||||
use super::span::SpanVec;
|
|
||||||
|
|
||||||
/// A list of spanned decorations.
|
|
||||||
pub type Decorations = SpanVec<Decoration>;
|
|
||||||
|
|
||||||
/// Decorations for semantic syntax highlighting.
|
|
||||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
|
||||||
#[cfg_attr(feature = "serialize", derive(Serialize))]
|
|
||||||
#[cfg_attr(feature = "serialize", serde(rename_all = "camelCase"))]
|
|
||||||
pub enum Decoration {
|
|
||||||
/// Text in italics.
|
|
||||||
Italic,
|
|
||||||
/// Text in bold.
|
|
||||||
Bold,
|
|
||||||
/// A valid, successfully resolved name.
|
|
||||||
Resolved,
|
|
||||||
/// An invalid, unresolved name.
|
|
||||||
Unresolved,
|
|
||||||
/// The key part of a key-value entry in a table.
|
|
||||||
TableKey,
|
|
||||||
}
|
|
@ -1,11 +1,26 @@
|
|||||||
//! Syntax types.
|
//! Syntax types.
|
||||||
|
|
||||||
mod decoration;
|
|
||||||
mod span;
|
mod span;
|
||||||
mod token;
|
mod token;
|
||||||
mod tree;
|
mod tree;
|
||||||
|
|
||||||
pub use decoration::*;
|
|
||||||
pub use span::*;
|
pub use span::*;
|
||||||
pub use token::*;
|
pub use token::*;
|
||||||
pub use tree::*;
|
pub use tree::*;
|
||||||
|
|
||||||
|
/// Decorations for semantic syntax highlighting.
|
||||||
|
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
||||||
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
|
||||||
|
#[cfg_attr(feature = "serialize", serde(rename_all = "camelCase"))]
|
||||||
|
pub enum Decoration {
|
||||||
|
/// Text in italics.
|
||||||
|
Italic,
|
||||||
|
/// Text in bold.
|
||||||
|
Bold,
|
||||||
|
/// A valid, successfully resolved name.
|
||||||
|
Resolved,
|
||||||
|
/// An invalid, unresolved name.
|
||||||
|
Unresolved,
|
||||||
|
/// The key part of a key-value entry in a table.
|
||||||
|
TableKey,
|
||||||
|
}
|
||||||
|
@ -6,9 +6,6 @@ use std::ops::{Add, Sub};
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
|
|
||||||
#[cfg(feature = "serialize")]
|
|
||||||
use serde::Serialize;
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
thread_local! {
|
thread_local! {
|
||||||
static CMP_SPANS: Cell<bool> = Cell::new(true);
|
static CMP_SPANS: Cell<bool> = Cell::new(true);
|
||||||
@ -34,7 +31,7 @@ impl<T> Offset for SpanVec<T> {
|
|||||||
|
|
||||||
/// A value with the span it corresponds to in the source code.
|
/// A value with the span it corresponds to in the source code.
|
||||||
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
||||||
#[cfg_attr(feature = "serialize", derive(Serialize))]
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
|
||||||
pub struct Spanned<T> {
|
pub struct Spanned<T> {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
pub v: T,
|
pub v: T,
|
||||||
@ -92,7 +89,7 @@ impl<T: Debug> Debug for Spanned<T> {
|
|||||||
|
|
||||||
/// Locates a slice of source code.
|
/// Locates a slice of source code.
|
||||||
#[derive(Copy, Clone, Ord, PartialOrd, Hash)]
|
#[derive(Copy, Clone, Ord, PartialOrd, Hash)]
|
||||||
#[cfg_attr(feature = "serialize", derive(Serialize))]
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
|
||||||
pub struct Span {
|
pub struct Span {
|
||||||
/// The inclusive start position.
|
/// The inclusive start position.
|
||||||
pub start: Pos,
|
pub start: Pos,
|
||||||
@ -164,7 +161,7 @@ impl Debug for Span {
|
|||||||
|
|
||||||
/// Zero-indexed line-column position in source code.
|
/// Zero-indexed line-column position in source code.
|
||||||
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
||||||
#[cfg_attr(feature = "serialize", derive(Serialize))]
|
#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
|
||||||
pub struct Pos {
|
pub struct Pos {
|
||||||
/// The zero-indexed line.
|
/// The zero-indexed line.
|
||||||
pub line: usize,
|
pub line: usize,
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
use std::fmt::{self, Debug, Formatter};
|
use std::fmt::{self, Debug, Formatter};
|
||||||
|
|
||||||
use super::decoration::Decoration;
|
|
||||||
use super::span::{SpanVec, Spanned};
|
use super::span::{SpanVec, Spanned};
|
||||||
|
use super::Decoration;
|
||||||
use crate::color::RgbaColor;
|
use crate::color::RgbaColor;
|
||||||
use crate::compute::table::{SpannedEntry, Table};
|
use crate::compute::table::{SpannedEntry, Table};
|
||||||
use crate::compute::value::{TableValue, Value};
|
use crate::compute::value::{TableValue, Value};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user