-
Notifications
You must be signed in to change notification settings - Fork 7
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
Add include_file statement #74
Changes from 8 commits
79ef1e9
214aa8a
e3f773e
2a15e48
dd483e4
497328e
650dedf
f9d1e6e
53af53c
ed06f64
8ce7cf6
da4fbee
fe63a24
5bd1855
393213a
70631c3
39471ee
b9d959e
4735259
e306632
94cdb51
2bef7be
6b460e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package org.partiql.pig.domain.parser | ||
|
||
import java.io.FileInputStream | ||
import java.io.InputStream | ||
|
||
|
||
/** | ||
* A simple abstraction for opening [InputStream], allows for type domains to be loaded from a file system or an | ||
* in-memory data structure. The latter is useful for unit testing. | ||
*/ | ||
internal interface InputStreamSource { | ||
/** Opens an input stream for the given filename name. */ | ||
fun openInputStream(fileName: String): InputStream | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the path/file name implementation defined? E.g. Also, if this is relative to a given file, doesn't that imply we need a parameter here to model the "working directory?" |
||
|
||
/** An [InputStreamSource] that constructs [FileInputStream] instances. */ | ||
internal val FILE_SYSTEM_INPUT_STREAM_SOURCE = object : InputStreamSource { | ||
override fun openInputStream(fileName: String) = FileInputStream(fileName) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This implementation defines the file name in terms of current working directory of the JVM, does it not? (versus the file being operated on as your docs would imply) |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
dlurton marked this conversation as resolved.
Show resolved
Hide resolved
|
||
package org.partiql.pig.domain.parser | ||
|
||
import com.amazon.ionelement.api.IonLocation | ||
import com.amazon.ionelement.api.MetaContainer | ||
|
||
/** | ||
* Used to construct helpful error messages for the end-user, who will be able to know the file, line & column of | ||
dlurton marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* a given error. | ||
*/ | ||
data class SourceLocation(val path: String, val location: IonLocation) { | ||
override fun toString(): String { | ||
return "$path:$location" | ||
} | ||
} | ||
|
||
internal const val SOURCE_LOCATION_META_TAG = "\$pig_source_location" | ||
|
||
internal val MetaContainer.sourceLocation | ||
get() = this[SOURCE_LOCATION_META_TAG] as? SourceLocation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an interesting choice and seems needlessly complex--shouldn't it be relative to some import path (which could contain the directory of the file in question)? This could lead to some really confusing include paths with nested folder structures...