Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: a599cdcad73e0f2fd9b19dab53f3f178e081dd6f (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
125
126
127
128
129
/*******************************************************************************
 * Copyright (c) 2007 Intel Corporation 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:
 * Intel Corporation - Initial API and implementation
 *******************************************************************************/
package org.eclipse.cdt.internal.core.settings.model;

import java.util.List;

import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry;
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
import org.eclipse.cdt.core.settings.model.ICSettingContainer;
import org.eclipse.cdt.core.settings.model.extension.CLanguageData;
import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultLanguageData;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.core.settings.model.util.EntryStore;

public class CLanguageSettingCache extends CDefaultLanguageData implements
		ICLanguageSetting, ICachedData {
	private ICResourceDescription fParent;
	protected EntryStore fResolvedEntriesStore;

	public CLanguageSettingCache(CLanguageData base, CFolderDescriptionCache folderCache) {
		fId = base.getId();
		fParent = folderCache;
		copySettingsFrom(base);
	}

	public CLanguageSettingCache(CLanguageData base, CFileDescriptionCache fileCache) {
		fId = base.getId();
		fParent = fileCache;
		copySettingsFrom(base);
	}

/*	public ICLanguageSettingEntry[] getResolvedSettingEntries() {
		// TODO Auto-generated method stub
		return getSettingEntries();
	}
*/
	public ICLanguageSettingEntry[] getResolvedSettingEntries(int kind) {
		ICLanguageSettingEntry[] entries = getSettingEntries(kind);
		if(entries.length != 0){
			if(fResolvedEntriesStore == null){
				fResolvedEntriesStore = new EntryStore();
			}
			
			ICLanguageSettingEntry[] resolved = fResolvedEntriesStore.getEntries();
			if(resolved.length == 0){
				resolved = CDataUtil.resolveEntries(entries, getConfiguration());
				fResolvedEntriesStore.storeEntries(kind, resolved);
			}
			
			entries = resolved;
		}
		return entries;
	}
	
	
	public ICLanguageSettingEntry[] getSettingEntries(int kind) {
//		int kinds[] = KindBasedStore.getSupportedKinds();
//		List list = new ArrayList();
//		for(int i = 0; i < kinds.length; i++){
//			ICLanguageSettingEntry entries[] = fStore.getEntries(kinds[i]);
//			for(int j = 0; j < entries.length; j++){
//				list.add(entries[j]);
//			}
//		}
//		return (ICLanguageSettingEntry[])list.toArray(new ICLanguageSettingEntry[list.size()]);
		return fStore.getEntries(kind);
	}
	
	public List getSettingEntriesList(int kind) {
//		int kinds[] = KindBasedStore.getSupportedKinds();
//		List list = new ArrayList();
//		for(int i = 0; i < kinds.length; i++){
//			ICLanguageSettingEntry entries[] = fStore.getEntries(kinds[i]);
//			for(int j = 0; j < entries.length; j++){
//				list.add(entries[j]);
//			}
//		}
//		return (ICLanguageSettingEntry[])list.toArray(new ICLanguageSettingEntry[list.size()]);
		return fStore.getEntriesList(kind);
	}
	

	public void setLanguageId(String id) {
		throw ExceptionFactory.createIsReadOnlyException();
	}

	public void setName(String name) {
		throw ExceptionFactory.createIsReadOnlyException();
	}

	public void setSettingEntries(int kind, List entriesList) {
		throw ExceptionFactory.createIsReadOnlyException();
	}

	public void setEntries(int kind, ICLanguageSettingEntry[] entries) {
		throw ExceptionFactory.createIsReadOnlyException();
	}

	public void setSettingEntries(int kind, ICLanguageSettingEntry[] entries) {
		throw ExceptionFactory.createIsReadOnlyException();
	}

	public boolean supportsEntryKind(int kind) {
		return (getSupportedEntryKinds() & kind) == kind;
	}

	public ICConfigurationDescription getConfiguration() {
		return fParent.getConfiguration();
	}

	public ICSettingContainer getParent() {
		return fParent;
	}

	public boolean isReadOnly() {
		return true;
	}

}

Back to the top