// Path: com.reprezen.swagedit.core/src/com/reprezen/swagedit/core/hyperlinks/JsonFileHyperlink.java
// public abstract class JsonFileHyperlink implements IHyperlink {
// 
//     private final IRegion linkRegion;
//     private final String label;
//     private final IFile file;
//     private final JsonPointer pointer;
// 
//     public JsonFileHyperlink(IRegion linkRegion, String label, IFile file, JsonPointer pointer) {
//         this.linkRegion = linkRegion;
//         this.label = label;
//         this.file = file;
//         this.pointer = pointer;
//     }
//     
//     protected abstract JsonDocument createDocument();
// 
//     @Override
//     public IRegion getHyperlinkRegion() {
//         return linkRegion;
//     }
// 
//     @Override
//     public String getTypeLabel() {
//         return label;
//     }
// 
//     @Override
//     public String getHyperlinkText() {
//         return label;
//     }
// 
//     @Override
//     public void open() {
//         if (file == null || !file.exists()) {
//             return;
//         }
// 
//         try {
//             DocumentUtils.openAndReveal(file, getTarget());
//         } catch (Exception e) {
//             // TODO
//         }
//     }
// 
//     private IRegion getTarget() throws CoreException {
//         JsonDocument doc = null;
//         try {
//             String content = DocumentUtils.getDocumentContent(file.getLocation());
//             doc = createDocument();
//             doc.set(content);
//         } catch (IOException e) {
//             return null;
//         }
//         return doc.getRegion(pointer);
//     }
// 
// }
// 
// Path: com.reprezen.swagedit.core/src/com/reprezen/swagedit/core/hyperlinks/ReferenceHyperlinkDetector.java
// public abstract class ReferenceHyperlinkDetector extends AbstractJsonHyperlinkDetector {
// 
//     protected final JsonReferenceFactory factory = new JsonReferenceFactory();
// 
//     protected abstract JsonFileHyperlink createFileHyperlink(IRegion linkRegion, String label, IFile file,
//             JsonPointer pointer);
// 
//     @Override
//     protected abstract boolean canDetect(JsonPointer pointer);
// 
//     @Override
//     protected IHyperlink[] doDetect(JsonDocument doc, ITextViewer viewer, HyperlinkInfo info, JsonPointer pointer) {
//         URI baseURI = getBaseURI();
// 
//         AbstractNode node = doc.getModel().find(pointer);
//         JsonReference reference = getFactory().createSimpleReference(getBaseURI(), node);
//         if (reference == null) {
//             reference = getFactory().create(node);
//         }
// 
//         if (reference.isInvalid() || reference.isMissing(doc, getBaseURI())) {
//             return null;
//         }
// 
//         if (reference.isLocal()) {
//             IRegion target = doc.getRegion(reference.getPointer());
//             if (target == null) {
//                 return null;
//             }
//             return new IHyperlink[] {
//                     new SwaggerHyperlink(reference.getPointer().toString(), viewer, info.region, target) };
//         } else {
//             URI resolved;
//             try {
//                 resolved = baseURI.resolve(reference.getUri());
//             } catch (IllegalArgumentException e) {
//                 // the given string violates RFC 2396
//                 return null;
//             }
//             IFile file = DocumentUtils.getWorkspaceFile(resolved);
//             if (file != null && file.exists()) {
//                 return new IHyperlink[] { createFileHyperlink(info.region, info.text, file, reference.getPointer()) };
//             }
//         }
// 
//         return null;
//     }
// 
//     protected FileEditorInput getActiveEditor() {
//         return DocumentUtils.getActiveEditorInput();
//     }
// 
//     protected URI getBaseURI() {
//         FileEditorInput editor = getActiveEditor();
// 
//         return editor != null ? editor.getURI() : null;
//     }
// 
//     protected JsonReferenceFactory getFactory() {
//         return factory;
//     }
// 
// }


import org.eclipse.core.resources.IFile;
import org.eclipse.jface.text.IRegion;
import com.fasterxml.jackson.core.JsonPointer;
import com.reprezen.swagedit.core.hyperlinks.JsonFileHyperlink;
import com.reprezen.swagedit.core.hyperlinks.ReferenceHyperlinkDetector;
/*******************************************************************************
 * Copyright (c) 2016 ModelSolv, Inc. and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    ModelSolv, Inc. - initial API and implementation and/or initial documentation
 *******************************************************************************/
package com.reprezen.swagedit.openapi3.hyperlinks;



public class LinkOperationRefHyperlinkDetector extends ReferenceHyperlinkDetector {

    @Override
    protected JsonFileHyperlink createFileHyperlink(IRegion linkRegion, String label, IFile file, JsonPointer pointer) {
// Path: com.reprezen.swagedit.core/src/com/reprezen/swagedit/core/hyperlinks/JsonFileHyperlink.java
// public abstract class JsonFileHyperlink implements IHyperlink {
// 
//     private final IRegion linkRegion;
//     private final String label;
//     private final IFile file;
//     private final JsonPointer pointer;
// 
//     public JsonFileHyperlink(IRegion linkRegion, String label, IFile file, JsonPointer pointer) {
//         this.linkRegion = linkRegion;
//         this.label = label;
//         this.file = file;
//         this.pointer = pointer;
//     }
//     
//     protected abstract JsonDocument createDocument();
// 
//     @Override
//     public IRegion getHyperlinkRegion() {
//         return linkRegion;
//     }
// 
//     @Override
//     public String getTypeLabel() {
//         return label;
//     }
// 
//     @Override
//     public String getHyperlinkText() {
//         return label;
//     }
// 
//     @Override
//     public void open() {
//         if (file == null || !file.exists()) {
//             return;
//         }
// 
//         try {
//             DocumentUtils.openAndReveal(file, getTarget());
//         } catch (Exception e) {
//             // TODO
//         }
//     }
// 
//     private IRegion getTarget() throws CoreException {
//         JsonDocument doc = null;
//         try {
//             String content = DocumentUtils.getDocumentContent(file.getLocation());
//             doc = createDocument();
//             doc.set(content);
//         } catch (IOException e) {
//             return null;
//         }
//         return doc.getRegion(pointer);
//     }
// 
// }
// 
// Path: com.reprezen.swagedit.core/src/com/reprezen/swagedit/core/hyperlinks/ReferenceHyperlinkDetector.java
// public abstract class ReferenceHyperlinkDetector extends AbstractJsonHyperlinkDetector {
// 
//     protected final JsonReferenceFactory factory = new JsonReferenceFactory();
// 
//     protected abstract JsonFileHyperlink createFileHyperlink(IRegion linkRegion, String label, IFile file,
//             JsonPointer pointer);
// 
//     @Override
//     protected abstract boolean canDetect(JsonPointer pointer);
// 
//     @Override
//     protected IHyperlink[] doDetect(JsonDocument doc, ITextViewer viewer, HyperlinkInfo info, JsonPointer pointer) {
//         URI baseURI = getBaseURI();
// 
//         AbstractNode node = doc.getModel().find(pointer);
//         JsonReference reference = getFactory().createSimpleReference(getBaseURI(), node);
//         if (reference == null) {
//             reference = getFactory().create(node);
//         }
// 
//         if (reference.isInvalid() || reference.isMissing(doc, getBaseURI())) {
//             return null;
//         }
// 
//         if (reference.isLocal()) {
//             IRegion target = doc.getRegion(reference.getPointer());
//             if (target == null) {
//                 return null;
//             }
//             return new IHyperlink[] {
//                     new SwaggerHyperlink(reference.getPointer().toString(), viewer, info.region, target) };
//         } else {
//             URI resolved;
//             try {
//                 resolved = baseURI.resolve(reference.getUri());
//             } catch (IllegalArgumentException e) {
//                 // the given string violates RFC 2396
//                 return null;
//             }
//             IFile file = DocumentUtils.getWorkspaceFile(resolved);
//             if (file != null && file.exists()) {
//                 return new IHyperlink[] { createFileHyperlink(info.region, info.text, file, reference.getPointer()) };
//             }
//         }
// 
//         return null;
//     }
// 
//     protected FileEditorInput getActiveEditor() {
//         return DocumentUtils.getActiveEditorInput();
//     }
// 
//     protected URI getBaseURI() {
//         FileEditorInput editor = getActiveEditor();
// 
//         return editor != null ? editor.getURI() : null;
//     }
// 
//     protected JsonReferenceFactory getFactory() {
//         return factory;
//     }
// 
// }


// Path: com.reprezen.swagedit.openapi3/src/com/reprezen/swagedit/openapi3/hyperlinks/LinkOperationRefHyperlinkDetector.java
import org.eclipse.core.resources.IFile;
import org.eclipse.jface.text.IRegion;
import com.fasterxml.jackson.core.JsonPointer;
import com.reprezen.swagedit.core.hyperlinks.JsonFileHyperlink;
import com.reprezen.swagedit.core.hyperlinks.ReferenceHyperlinkDetector;

/*******************************************************************************
 * Copyright (c) 2016 ModelSolv, Inc. and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    ModelSolv, Inc. - initial API and implementation and/or initial documentation
 *******************************************************************************/
package com.reprezen.swagedit.openapi3.hyperlinks;



public class LinkOperationRefHyperlinkDetector extends ReferenceHyperlinkDetector {

    @Override
    protected JsonFileHyperlink createFileHyperlink(IRegion linkRegion, String label, IFile file, JsonPointer pointer) {
        return new OpenApi3FileHyperlink(linkRegion, label, file, pointer);