Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: c490b0ea54cb0914cf8c7960b866eeeb1c1709e0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*******************************************************************************
 * Copyright (c) 2000, 2006 IBM Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.debug.internal.ui.sourcelookup;

import org.eclipse.debug.ui.sourcelookup.ISourceLookupResult;
import org.eclipse.ui.IEditorInput;

/**
 * The result of a source lookup contains the source element, editor id, and
 * editor input resolved for a debug artifact.
 *
 * @since 3.1
 */
public class SourceLookupResult implements ISourceLookupResult {

    /**
     * Element that source was resolved for.
     */
    private Object fArtifact;
    /**
     * Corresponding source element, or <code>null</code>
     * if unknown.
     */
    private Object fSourceElement;
    /**
     * Associated editor id, used to display the source element,
     * or <code>null</code> if unknown.
     */
    private String fEditorId;
    /**
     * Associated editor input, used to display the source element,
     * or <code>null</code> if unknown.
     */
    private IEditorInput fEditorInput;

    /**
     * Creates a source lookup result on the given artifact, source element,
     * editor id, and editor input.
     */
    public SourceLookupResult(Object artifact, Object sourceElement, String editorId, IEditorInput editorInput) {
        fArtifact = artifact;
        setSourceElement(sourceElement);
        setEditorId(editorId);
        setEditorInput(editorInput);
    }

    @Override
	public Object getArtifact() {
        return fArtifact;
    }

    @Override
	public Object getSourceElement() {
        return fSourceElement;
    }

    /**
     * Sets the source element resolved for the artifact that source
     * lookup was performed for, or <code>null</code> if a source element
     * was not resolved.
     *
     * @param element resolved source element or <code>null</code> if unknown
     */
    protected void setSourceElement(Object element) {
        fSourceElement = element;
    }

    @Override
	public String getEditorId() {
        return fEditorId;
    }

    /**
     * Sets the identifier of the editor used to display this source
     * lookup result's source element, or <code>null</code> if unknown.
     *
     * @param id the identifier of the editor used to display this source
     * lookup result's source element, or <code>null</code> if unknown
     */
    protected void setEditorId(String id) {
        fEditorId = id;
    }

    @Override
	public IEditorInput getEditorInput() {
        return fEditorInput;
    }

    /**
     * Sets the editor input used to display this source lookup
     * result's source element, or <code>null</code> if unknown.
     *
     * @param input the editor input used to display this source lookup
     * result's source element, or <code>null</code> if unknown
     */
    protected void setEditorInput(IEditorInput input) {
        fEditorInput = input;
    }

	/**
	 * Updates the artifact to refer to the given artifact
	 * if equal. For example, when a source lookup result is reused
	 * for the same stack frame, we still need to update in case
	 * the stack frame is not identical.
	 *
	 * @param artifact new artifact state
	 */
	public void updateArtifact(Object artifact) {
		if (fArtifact.equals(artifact)) {
			fArtifact = artifact;
		}
	}
}

Back to the top